[PD] parse a serial stream

nward04 at qub.ac.uk nward04 at qub.ac.uk
Mon Oct 16 22:22:03 CEST 2006


Hi,
Ive come up with a way to parse out packets from a serial datastream 
that works but is possibly the ugliest thing Ive ever done and Id 
wonder about its resilience.
If anyone could have a look and advise a better way of doing this I'd 
really appreciate it.
Essentially each packet of the data looks like so
7E 42 FF FF 06 7D 5D 0D 01 XX XX XX XX XX XX XX XX XX XX XX XX CRC CRC

where the first XX XX represents a 10-bit ADC value in little endian 
format (LSB MSB) from sensor 1.
There are 6 sensors in total.

I put together a patch based on searching for 7e 42 FF FF. 7E and FF 
will never appear in the data part Im promised.

I have no control over the data stream format as thats handled by 
another guy.

Anyway my approach uses [route] and loads of [spigot] to look for the 
7E 42 FF FF and when it finds it bang a [repack] that has been 
"buffering" the data.
That goes to [unpack] to unpack the bytes.

Any pointers to a nicer way would be great. Ive attached the monster.
Thanks
Nick


-------------- next part --------------
A non-text attachment was scrubbed...
Name: serial2.pd
Type: application/octet-stream
Size: 6948 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20061016/b3262660/attachment.obj>


More information about the Pd-list mailing list