accidue has asked for the wisdom of the Perl Monks concerning the following question:

Can someone please post me some example code that would read the serial port byte by byte, or line by line (\n) ? I've been trying with Device::SerialPort but am having no luck. This is under linux btw.

Replies are listed 'Best First'.
Re: Reading serial port byte by byte...
by benn (Vicar) on Mar 25, 2003 at 11:04 UTC
    What problems are you having with Device::SerialPort? This example code from the 'Tied Filehandles' section of the manual looks like what you describe - tie the serial port then use getc.
    $PortObj = tie (*FH, 'Device::SerialPort',$Config_File) || die "Can't +tie: $!\n"; $char = getc FH;
    Hope this helps.
Re: Reading serial port byte by byte...
by mamut (Sexton) on Mar 25, 2003 at 09:45 UTC
    Try open /dev/cua and read from it like from file :-) may be works
    -=- MamuT -=-
      I'll give that a try, but i'm not too sure becuase I forgot to mention - I need to be able to write to it too! eg. send command, get responce. Or receive data, send responce.