Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: parse data from serial port

by boftx (Deacon)
on Oct 15, 2013 at 05:36 UTC ( #1058238=note: print w/replies, xml ) Need Help??


in reply to parse data from serial port

Many, many moons ago (early 90s)I had reason to collect data from a PBX system that was sent out over an RS232 connection. I found that I had to read a line at a time instead of a fixed block in order to get reasonable data chunks to work with. It looks like you have a similar situation to that.

I haven't had a chance to grok Device::SerialPort yet, but I would suspect it has some kind of input function that is similar to readln that would be suitable.

Assuming that is the case, then it should be relatively simple to bring in a line at a time for parsing/storing and then processing the collected data whenever the closing "Checksum" entry is detected. Doing a split /\s+/ might come in handy for that. (I tend to be partial to dispatch tables for working with record types.)

The answer to the question "Can we do this?" is always an emphatic "Yes!" Just give me enough time and money.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058238]
help
Chatterbox?
NodeReaper snacks on some Soylent Green

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2016-12-06 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (115 votes). Check out past polls.