Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Losing bytes with Device::SerialPort ?

by zentara (Archbishop)
on Dec 21, 2005 at 12:07 UTC ( #518292=note: print w/replies, xml ) Need Help??

in reply to Losing bytes with Device::SerialPort ?

You didn't show your code, but since it's the first character which gets corrupted, it reminded of another serial-port example I have, in which the author claimed you need to change the CR to a newline.
$ob = Device::SerialPort->new($PORT) || die "Can't Open $PORT: $!"; $ob->baudrate(9600) || die "failed setting baudrate"; $ob->parity("none") || die "failed setting parity"; $ob->databits(8) || die "failed setting databits"; $ob->stty_icrnl(1) || die "failed setting convert cr to new line"; $ob->handshake("none") || die "failed setting handshake"; $ob->write_settings || die "no settings";

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Losing bytes with Device::SerialPort ?
by Anonymous Monk on Dec 21, 2005 at 20:50 UTC

    thanks for the tip, but unfortunately it doesn't help. Any other idea ? Why do I loose first byte - I start recevieing right away...

    Exposing more code :

    $port = '/dev/ttyS0'; $ob = Device::SerialPort->new ($port); $ob->user_msg(1); # misc. warnings $ob->error_msg(1); # hardware and data errors $ob->baudrate(19200); $ob->parity("none"); $ob->databits(8); $ob->stopbits(1); $ob->handshake('none'); $ob->stty_icrnl(1) || die "failed setting convert cr to new line"; $ob->read_interval(0) if ($OS_win); $ob->read_const_time(10000); #$ob->read_const_time(500); # 500 milliseconds = 0.5 seconds $ob->read_char_time(1); # avg time between read char $ob->write_settings || die "no settings";

    Is buffering enabled by default ?

    Thanks in advance,


      I'm not able to test serial stuff, so I'm making wild guesses. :-) It sure sounds like a setting is off somewhere, here is another example How can I log a record with Ctrl-C as EOL from a serial port?

      Have you had sucess using some other method, like trying to cat the /dev/ttyS0 ? Or can you capture good data any other way?

      I'm not really a human, but I play one on earth. flash japh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://518292]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2018-01-20 19:59 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.