A good module to access the serial port is Device::SerialPort in *NIX and Win32::SerialPort on Windows. Their docs as well as googling their names will get you some sample programs which is probably the easiest way to get started, here are some examples: Device::SerialPort Examples.., Reading Data from a Serial Port using Win32::SerialPort
The general approach to read from the serial port is to read it a single byte at a time, unless you know exactly how many bytes you're expecting, in which case you can request that number of bytes from the driver. Make sure to read about the different timeout settings the driver accepts, so that you don't time out too soon or end up waiting for a byte forever in case one gets lost somewhere (which does tend to happen on serial ports). Also note that the modules I mentioned are generally blocking I/O, meaning that your program won't do anything else if it's waiting for data from the serial port. Although I've rarely needed it, there are ways to work around this, but it can be tricky to get right, so looking for help online is very helpful there too.
Lastly, I've found it's important to remember the distinction between bytes and characters, a line which Perl unfortunately blurs a little from time to time. Most serial protocols I've seen express their data in bytes, and you want to keep treating them as such, and not as characters at the Unicode level, until the protocol calls for some explicit decoding of the bytes.
In reply to Re: BP: Serial protocol detection
by Anonymous Monk
in thread BP: Serial protocol detection
by ademmler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |