Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: CRC and Serial Port

by twerq (Deacon)
on Dec 05, 2001 at 01:47 UTC ( [id://129455]=note: print w/replies, xml ) Need Help??


in reply to CRC and Serial Port

about the checksum -- you obvously know more than I do about the other end that's sending you the data, but i've always done checksums on the whole record after zeroing the checksum, so you might end up having to pack it back up using the same unpack template...

...but for calculating the checksum itself, you might end up using unpack a third time

from perldoc -f unpack:
For example, the following computes the same number as the System V sum program: $checksum = do { local $/; # slurp! unpack("%32C*",<>) % 65535; };

--twerq

Replies are listed 'Best First'.
Rea: CRC and Serial Port
by baku (Scribe) on Dec 06, 2001 at 02:48 UTC

    If you want to process data one block at a time, set $/ to your field length. That will save you from waiting to slurp the entire "file" before processing it.

      true, you can pass a value reference to $/ which translates into a record length, but as far as I know, there's no way to tell it to read 12 "lines", where a line can be variable length.

      --twerq

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://129455]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found