serialport / node-serialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
https://serialport.io
MIT License
5.82k stars 1.01k forks source link

Make a parser to pull data out from the middle of a known binary packet #1609

Closed reconbot closed 3 years ago

reconbot commented 6 years ago

We don't have a parser that makes this very common problem easy.

Holger-Will commented 5 years ago

i just wrote my first parser for a known protocol. i would be willing to help. In my case i parse enocean packets. https://github.com/enocean-js/enocean-js/blob/master/packages/node_modules/%40enocean-js/serialport-parser/src/serialport-parser.js

the packets come in starting with a sync byte, then a header which contains information about the length of the current packet and the location of the checksums.

i guess that this is probably most common packet design. What do you have in mind?

reconbot commented 5 years ago

This is a very common parsing challenge, I think a generalized parser that can be told how to find the length information and then emits the data packet would be very helpful. I like your use of a state machine.

Holger-Will commented 5 years ago

i just followed the reference implementation from the spec ;-) ...

would be nice to have a collection of some data packages, to generalize the algorithm in a useful way, and to have some data to test against.

I do not quite understand the packet structure from the issue you linked above. the author mentions that the packet length varies but it's not clear how to detect the different lengths.

would be great to have at least one packet of that type with a different length.unfortunately i can not comment on that issue anymore.

wendy2702 commented 5 years ago

Hi,

sorry for late reply.

Please let me know how i can help?

Holger-Will commented 5 years ago

do you have example packages of all different length and possibly information about the packet structure?

wendy2702 commented 5 years ago

Sorry i actually do not have examples for all different packages.

Do you speak German? Because the information about the packet structure is written in German.

Holger-Will commented 5 years ago

ja, deutsch geht! wenn Du mir die Info zukommen lassen könntest wäre das toll ;-)

wendy2702 commented 5 years ago

das Protokoll hier hier sehr gut beschrieben: https://www.symcon.de/forum/threads/2092-ComPort-und-Waterkotte-abfragen

Die Adressen sind hier aufgeführt: http://www.haustechnikdialog.de/Forum/t/6144/Waterkotte-5017-3-an-den-Computer-anschliessen?page=2

Und hier auch noch eine Beschreibung: https://www.linux-magazin.de/ausgaben/2010/06/selektive-waerme/

Leider liefert der Hersteller keine gesammelten Informationen so das man sich das zusammen suchen musste.