In my experience, getting serial ports working with the higher-level reading functions (also timeouts and graceful closing of the ports) can be quite finicky. In fact, in a recent script I wrote that does something similar to yours, I just read the port one byte at a time and do the buffering myself, it's not the most elegant but it's robust. The code resembles the "EXAMPLE" in Device::SerialPort.
However, from perlvar:
HANDLE->autoflush( EXPR ) ... This has no effect on input buffering. See getc for that.
I don't see you writing to the port anywhere. So I don't think "autoflush" is the right term here, and perhaps you need to explain your problem better: In regards to what is being read/written from the port, what exactly is the expected behaviour, and what behaviour are you getting instead? Perhaps a short sample would help?
How can I create a filehandle for this module that it will always return me the last line from the serial port output?
By "last", do you mean "most recent"? I see a couple of options: Keep the port closed until you actually want to read; continually read the port and just remember the most recent line; or try the lookclear method from Device::SerialPort (although the docs are a little unclear to me whether lookclear will do what you need).
In reply to Re: serial port tied filehandle autoflush
by Anonymous Monk
in thread serial port tied filehandle autoflush
by kkaiser
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |