Simple UART communication protocol

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/

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:

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

5 Likes

@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!

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 =)

1 Like

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.

@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

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…

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