how to detect and interpret serial port data. I have "googled" a lot but I don't find a "general explanation". I have a couple of protocol specifications for serial devices, which I want to talk with and read from. The biggest hurdle for me is to get the "data stream" out of a continuous message
I've never seen such a tutorial, and I've been playing with serial ports for 30+ years. Mind you, I haven't gone looking for a long time either :)
There are basically two types of serial line protocol:
With this, the first 1, 2, or 4 characters from the stream identify how many more characters must be read for a complete, single message:
<0x1A>This is a complete message
With this, you have to keep reading until you see the specified terminator:
This is a complete message<0x03>
In general, the former is easier and more efficient to deal with at the lower level.
However, at the higher level, the latter allows you to use filetype line-oriented reads and writes provided that your libraries allow you to set the EOL character -- which Perl allows by the setting of $/ & $\.
In reply to Re: BP: Serial protocol detection
by BrowserUk
in thread BP: Serial protocol detection
by ademmler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |