# Simple UART communication protocol

**URL:** <https://forum.xod.io/t/simple-uart-communication-protocol/1243>\
**Category:** Look What I’ve Done\
**Created:** [October 18, 2018, 11:48am UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243 "2018-10-18T11:48:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabbapeople](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/gabbapeople/32/1517_2.png) [@gabbapeople](https://forum.xod.io/u/gabbapeople)\
**Post date:** [October 18, 2018, 11:48am UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/1 "2018-10-18T11:48:22Z")

</div>

Hi everyone!

Check out my new library for creating a simple communication protocol for a UART interface. I use byte packages for data transfer and I found this library very useful in my projects.

[https://xod.io/libs/gabbapeople/simple-byte-protocol/](https://xod.io/libs/gabbapeople/simple-byte-protocol/)

You can try this library in cases when you need to get only exact values from a large data flow through a UART.

To read more follow the quick start guide:

> **[Simple UART communication protocol in XOD – Max Danilin – Medium](https://medium.com/@gpeople/simple-uart-communication-protocol-in-xod-9ce67cc69d3c)**
>
> You can use this library to create own simple byte communication protocols. Using own protocol you can transfer byte packets of data from one device to another without fear of breakage or loss. You…

If something doesn’t work please leave a comment. Your feedback is valuable to me.

---

<div class="post-metadata">

**Author:** ![dox](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/dox/32/424_2.png) [@dox](https://forum.xod.io/u/dox)\
**Post date:** [October 24, 2018, 1:20pm UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/2 "2018-10-24T13:20:02Z")

</div>

@gabbapeople

Thanks for the tutorial! Perhaps you can can help me with my problem:  
I want to do the same thing like shown in this tutorial but **without** HEADER, HEAD and CHECKSUM node. Just sending three bytes and receiving three bytes. I tried to modificate the examples in xod/uart but it was not working at all. A modification of this example was also not possible when I left the HEAD-pin blank.  
Any help is apreciated. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![gabbapeople](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/gabbapeople/32/1517_2.png) [@gabbapeople](https://forum.xod.io/u/gabbapeople)\
**Post date:** [October 24, 2018, 8:43pm UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/3 "2018-10-24T20:43:18Z")

</div>

Blank `HEAD` pin, it still contains some byte.

For your example is better to use three `write-byte` nodes from `xod/uart` sequentially.

In fact:

- the `packet` node creates a simple byte array. For example (`uint8_t array[size]`).
- the `add-head` node fills the `[0]` element of the array. (`array[0] = head`).
- the `add-byte-to-packet` fills the `[1]`, `[1+i]`, … `[size-1]` array elements for `i = 0; i < size-1`;
- the `add-checksum` fills the `[size-1]` array element.

Thus, sending 3 bytes only by the `packet` and `add-byte-to-packet` nodes requires some changes in C++ implementation.

I will return to work on the library as soon as possible and make examples that are similar to yours. Meanwhile, you can try to do it yourself =)

---

<div class="post-metadata">

**Author:** ![dox](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/dox/32/424_2.png) [@dox](https://forum.xod.io/u/dox)\
**Post date:** [October 26, 2018, 7:56am UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/4 "2018-10-26T07:56:09Z")

</div>

Hello @gabbapeople!

I don’t know why my previous projects did not work. I used two Nanos; one for sending and one for receiving. Now I used three `write-byte` nodes how you suggested and a Serial-to-USB Converter as receiver. This will work for me and I have immediate control of the result on my terminal software. Next step is the other way round: I will use three `receive-byte` nodes and send some bytes from the terminal program.

---

<div class="post-metadata">

**Author:** ![robertspark](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@robertspark](https://forum.xod.io/u/robertspark)\
**Post date:** [December 5, 2019, 5:02pm UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/5 "2019-12-05T17:02:23Z")

</div>

@gabbapeople

Etiquette question…

Would I be allowed to use some of the code within these modules of the gabbapeople/simple-byte-protocol  
library?

I am trying (attempting) to create some CANBUS nodes / library and the use of byte to packet is useful with canbus

Thanks either way

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [December 5, 2019, 5:30pm UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/6 "2019-12-05T17:30:56Z")

</div>

I think we are all here to help each other out & none of the code is copy-writed, so re-use should not be a problem. The biggest question is how best to reuse it.

The “best” way is probably just to include the node & note that your library depends on the additional library, but that dependency is going to be annoying for everyone trying to use your library if it is only using a single node.

You can also duplicate the node in your own library; ideally adding comment indicating where you found the code originally. This means you will not get updates for bug fixes (or changes in functionality that might break your code). Copying many nodes from another library rather than just depending on the additional library would probably be bad form…

---

<div class="post-metadata">

**Author:** ![robertspark](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@robertspark](https://forum.xod.io/u/robertspark)\
**Post date:** [December 5, 2019, 8:20pm UTC](https://forum.xod.io/t/simple-uart-communication-protocol/1243/7 "2019-12-05T20:20:46Z")

</div>

My plan was just to copy the byte \>\> packet. And packet nodes (or at least parts of their internal code)

It was not a wholesale copy of all nodes given the header structure is different… But the byte to packet node did provide an easy way to input 1 to 8 bytes into the data packet of a canbus message
