sawtooth has asked for the wisdom of the Perl Monks concerning the following question:
The problem with this is that if one of the first 3 bytes is a 0x0a, the match will return too few bytes and mess the whole thing up. Also, if the fourth byte is anything other than 0x0a, we have a problem that we need to know about. So what I need to do is count the number of bytes as they stream in, and check every fourth byte to confirm that it is indeed a 0x0a. This would be easily done if I were reading a file using the READ function. But since I am reading a real-time datastream from the COM port instead, I am puzzled about how to do this. I have tried assigning the COM port a filehandle (with OPEN) and READing that, but of course the COM port is locked by then by the serialport module.$ob->are_match("-re", '\x{0a}');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting bytes in an input stream instead of a file
by dsheroh (Monsignor) on Jun 06, 2006 at 20:23 UTC | |
|
Re: Counting bytes in an input stream instead of a file
by sgifford (Prior) on Jun 06, 2006 at 21:04 UTC | |
|
Re: Counting bytes in an input stream instead of a file
by GrandFather (Saint) on Jun 06, 2006 at 20:42 UTC |