# Decoding COBS package

**URL:** <http://forum.vvvv.org/t/decoding-cobs-package/22810>\
**Category:** question\
**Created:** [August 2, 2024, 9:41am UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810 "2024-08-02T09:41:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![katzengold](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@katzengold](http://forum.vvvv.org/u/katzengold)\
**Post date:** [August 2, 2024, 9:41am UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/1 "2024-08-02T09:41:35Z")

</div>

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](https://www.dropbox.com/scl/fi/6ivjhw2ik5kf3j7lv6vlh/cobs_encode-decode_01.v4p?rlkey=k80jvtxmu4ft0m7yax83sj9f4&dl=0)

COBS documentation:

> **[Consistent Overhead Byte Stuffing (COBS)](https://blog.mbedded.ninja/programming/serialization-formats/consistent-overhead-byte-stuffing-cobs/)**
>
> The encoding and decoding process for packetizing (framing) data using Consistent Overhead Byte Stuffing (COBS).

 ![image](http://forum.vvvv.org/uploads/default/original/3X/2/7/27c27c1145f1bfd91c43417822f9afbd99c94435.png)

---

<div class="post-metadata">

**Author:** ![bjoern](http://forum.vvvv.org/user_avatar/forum.vvvv.org/bjoern/32/17774_2.png) [@bjoern](http://forum.vvvv.org/u/bjoern)\
**Post date:** [August 2, 2024, 9:44am UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/2 "2024-08-02T09:44:21Z")

</div>

> [@katzengold](#):
>
> My patch for decoding is working

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

---

<div class="post-metadata">

**Author:** ![katzengold](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@katzengold](http://forum.vvvv.org/u/katzengold)\
**Post date:** [August 2, 2024, 9:47am UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/3 "2024-08-02T09:47:01Z")

</div>

[https://www.dropbox.com/scl/fi/6ivjhw2ik5kf3j7lv6vlh/cobs\_encode-decode\_01.v4p?rlkey=k80jvtxmu4ft0m7yax83sj9f4&dl=0](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…)

---

<div class="post-metadata">

**Author:** ![bjoern](http://forum.vvvv.org/user_avatar/forum.vvvv.org/bjoern/32/17774_2.png) [@bjoern](http://forum.vvvv.org/u/bjoern)\
**Post date:** [August 2, 2024, 10:00am UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/4 "2024-08-02T10:00:39Z")

</div>

for preservation purposes:  
[cobs\_encode-decode\_01.zip](http://forum.vvvv.org/uploads/short-url/t0WOg745tv3VZ6vvuULTMDZAfQT.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_.

---

<div class="post-metadata">

**Author:** ![katzengold](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@katzengold](http://forum.vvvv.org/u/katzengold)\
**Post date:** [August 2, 2024, 10:08am UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/5 "2024-08-02T10:08:20Z")

</div>

> [@bjoern](#):
>
> Any reason you are not using gamma? Even just taking a cursory glance I am pretty sure it would be a lot easier.

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…

---

<div class="post-metadata">

**Author:** ![bjoern](http://forum.vvvv.org/user_avatar/forum.vvvv.org/bjoern/32/17774_2.png) [@bjoern](http://forum.vvvv.org/u/bjoern)\
**Post date:** [August 2, 2024, 12:24pm UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/6 "2024-08-02T12:24:45Z")

</div>

Gave it a quick go. Using the old VL integration was a blast from the past.  
It’s using [COBS.NET](https://github.com/OctSquid/COBS.NET). Had to reference the lib directly since there is some bug with nuget packages…

[COBS.7z](http://forum.vvvv.org/uploads/short-url/5LVCLkrT1YRRqLPMuUfCYw3WhlS.7z) (16.8 KB)

---

<div class="post-metadata">

**Author:** ![katzengold](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@katzengold](http://forum.vvvv.org/u/katzengold)\
**Post date:** [August 2, 2024, 1:08pm UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/7 "2024-08-02T13:08:58Z")

</div>

May thanks Björn!

---

<div class="post-metadata">

**Author:** ![katzengold](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@katzengold](http://forum.vvvv.org/u/katzengold)\
**Post date:** [August 2, 2024, 2:07pm UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/9 "2024-08-02T14:07:31Z")

</div>

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](http://forum.vvvv.org/uploads/default/original/3X/a/5/a5fec9e4fd743d91aa264822fb347328e38d0c42.png)

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.

---

<div class="post-metadata">

**Author:** ![bjoern](http://forum.vvvv.org/user_avatar/forum.vvvv.org/bjoern/32/17774_2.png) [@bjoern](http://forum.vvvv.org/u/bjoern)\
**Post date:** [August 2, 2024, 4:43pm UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/10 "2024-08-02T16:43:41Z")

</div>

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](https://vvvv.org/documentation/vvvv-specialists-available-for-hire)).

---

<div class="post-metadata">

**Author:** ![joreg](http://forum.vvvv.org/user_avatar/forum.vvvv.org/joreg/32/19824_2.png) [@joreg](http://forum.vvvv.org/u/joreg)\
**Post date:** [August 5, 2024, 10:55pm UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/11 "2024-08-05T22:55:48Z")

</div>

> [@bjoern](#):
>
> the forum doesn’t allow uploads of _.v4p_.

fixed, thanks.

---

<div class="post-metadata">

**Author:** ![system](http://forum.vvvv.org/user_avatar/forum.vvvv.org/system/32/1_2.png) [@system](http://forum.vvvv.org/u/system)\
**Post date:** [August 5, 2025, 10:55pm UTC](http://forum.vvvv.org/t/decoding-cobs-package/22810/12 "2025-08-05T22:55:54Z")

</div>

Closed on August 5, 2025, 10:55pm UTC

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
