HAL file operation

More
06 Jan 2011 16:54 #6478 by aike
HAL file operation was created by aike
Hi!
I need to open (close, append, read, write) file.
For example to store statistic, to collect and store some values e t c.
How can I do it in HAL? Is it possible?

Please Log in or Create an account to join the conversation.

More
06 Jan 2011 17:37 #6480 by andypugh
Replied by andypugh on topic Re:HAL file operation
aike wrote:

Hi!
I need to open (close, append, read, write) file.
For example to store statistic, to collect and store some values e t c.
How can I do it in HAL? Is it possible?


I believe so, have a look to see if sampler and halsampler do what you want:
www.linuxcnc.org/docview/html/man/man9/sampler.9.html

Please Log in or Create an account to join the conversation.

More
06 Jan 2011 22:22 #6488 by aike
Replied by aike on topic Re:HAL file operation
OK, I tested it.
How to flush FIFO to file every second?
The problem I use "loadusr halsampler -t FILENAME" and only after the end of EMC it flush all data to file
I use new thread called sampler-thread for 1 Sec (loadrt threads name1=sampler-thread period1=1000000000.

Please Log in or Create an account to join the conversation.

More
06 Jan 2011 23:04 #6492 by andypugh
Replied by andypugh on topic Re:HAL file operation
you need the realtime part too.

loadrt halsampler
addf halsampler sampler-thread

You also need to specify which pins you want halsampler to have, and then they need to be linked to other hal pins that you want to log.

Please Log in or Create an account to join the conversation.

More
09 Jan 2011 15:57 #6574 by aike
Replied by aike on topic Re:HAL file operation
andypugh wrote:

you need the realtime part too.

loadrt halsampler
addf halsampler sampler-thread

You also need to specify which pins you want halsampler to have, and then they need to be linked to other hal pins that you want to log.

I did it all. All works, the output in stdout or in file (if I assign it) present.
But there is one alittle problem. If I write to stdout, all other messages about the EMC also present.
If I write to file, then the file not writen at once. The EMC collect all data in cache and flush it only after the exit from EMC or if the buffer (may be 1024 bytes) becomes empty.
I need to get the stream, not buffered operation.

Please Log in or Create an account to join the conversation.

More
09 Jan 2011 16:11 #6575 by aike
Replied by aike on topic Re:HAL file operation
Here is my sample (my hal file)
#each second = 1000000000 nS
loadrt threads name1=sampler-thread period1=1000000000
loadrt sampler depth=3 cfg=ff
addf sampler.0 sampler-thread
#to file
loadusr halsampler -t A-MINMAX
net X.ferror-min <= minmax.0.min sampler.0.pin.0
net X.ferror-max <= minmax.0.max sampler.0.pin.1

Please Log in or Create an account to join the conversation.

More
09 Jan 2011 16:42 #6576 by andypugh
Replied by andypugh on topic Re:HAL file operation
aike wrote:

andypugh wrote:

I need to get the stream, not buffered operation.

Sorry, I am afraid I can't help there, I have never actually used the components, I just knew that they existed.

You could try a question to the mailing list.

Please Log in or Create an account to join the conversation.

More
09 Jan 2011 16:54 #6577 by psha
Replied by psha on topic Re:HAL file operation

I need to get the stream, not buffered operation.

Run halsampler process by hand, not from .hal file

Please Log in or Create an account to join the conversation.

Time to create page: 0.606 seconds
Powered by Kunena Forum