Decoding COBS package

Hello!
I need to use COBS encoding for sending and receving data over RS-232 node.
COBS will escape any ‘0’ characters with a pointer to the next escaped character.
I managed to patch the encoding side.
On the decoding side i need to iterate through a spread ( read an index as a pointer, read the index indicated by that pointer etc.)
Is there an elegant / spreadable way of doing this?
My patch for decoding is working, but needs [n] copies of some nodes, for the [n] possible occurences of ‘0’. So it’s not very flexible.

patch:
https://www.dropbox.com/scl/fi/6ivjhw2ik5kf3j7lv6vlh/cobs_encode-decode_01.v4p?rlkey=k80jvtxmu4ft0m7yax83sj9f4&dl=0

COBS documentation:
https://blog.mbedded.ninja/programming/serialization-formats/consistent-overhead-byte-stuffing-cobs/

Adding you patch will most likely help to get a better understanding of the problem.

https://www.dropbox.com/scl/fi/6ivjhw2ik5kf3j7lv6vlh/cobs_encode-decode_01.v4p?rlkey=k80jvtxmu4ft0m7yax83sj9f4&dl=0

(Chrome won’t let me upload files other than .jpg…)

for preservation purposes:
cobs_encode-decode_01.zip (4.0 KB)

Any reason you are not using gamma? Even just taking a cursory glance I am pretty sure it would be a lot easier.

OT:
@joreg the forum doesn’t allow uploads of .v4p.

I need to reuse & extend old beta patches for a new project. I am a sporadic vvvv user, so didn’t have time to learn gamma and port…

Gave it a quick go. Using the old VL integration was a blast from the past.
It’s using COBS.NET. Had to reference the lib directly since there is some bug with nuget packages…

COBS.7z (16.8 KB)

May thanks Björn!

Works fine,
but here’s a (another) catch.
I will receive multiple raw COBS packets per frame with the Tokenizer.
When i process them, AsValue serializes the packets into one spread.
Which breaks the decoding and also looses the identification of packets.
I thought I would receive a ‘spread of spreads’ ( spread of packets).

Am i missing something obvious here?
Or should I be doing stuff like this in a VL ( integration) node?
image

I mean probably moving to gamma would be a good idea,
as the whole project will involve processing different and varying message types from/to a Rs485 Node Network via an Arduino, and (probably MIDI) data from Max,
so something like events and some state based logic, on top of continuously controlling parameters vvvv-Style.

Sorry, don’t have any more spare time to spend. If no one else steps up and you have some budget ping me (or maybe someone else on this list).

fixed, thanks.