Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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?
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2017-02-24 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (359 votes). Check out past polls.