Psychopoulet / split-frames

Split Buffer frames from streams
ISC License
5 stars 3 forks source link

ETB support #27

Closed mreis1 closed 1 year ago

mreis1 commented 1 year ago

According to the protocol, certain commands might be returned in multiple blocks. Those are then delimited by ETB being ETX used to delimit the latest block.

-----ENQ ------>
<----ACK --------

STX -- DATA -- DLE ETB LRC --->
<---------- ACK ----------------

STX -- DATA -- DLE ETB LRC --->
<---------- ACK ----------------

STX -- DATA -- DLE ETX LRC --->
<---------- ACK ----------------

----------- EOT ---------------->

ETB 0x17

The ETB management is necessary for messages of more than 248 bytes. The maximum message size (blocks concatenation) is 1024 bytes.

Psychopoulet commented 1 year ago

this package is only designed to compile full-filled frame, I don't think I'm able to add some half-filled frame with checkpoints like that

Psychopoulet commented 1 year ago

but you can use a Splitter like this and concat data :

new Splitter({ "startWith": STX, "endWith": [ Buffer.from([ DLE, ETB ]), Buffer.from([ DLE, ETX ]) ], "specifics": { "ack": ACK, }, "controlBits": "end+1" })