Communication Protocol

What is the USB or UART communication protocol between the board and the PC? If I would like to design my own communication protocol, how can I modify the software?

There are two available protocols. One designed for machine use, which we call the “native protocol”, and one designed to be human readable, which we call the “ascii protocol”. You can check the following for more info:

1 Like

hi,How to use UART control, I have modified CONFIG_UART_PROTOCOL=native, connected GPIO1 and GPIO2 pins and GND. Is it connected to the PC via a USB to serial chip? If so, what command is executed on the git bash here terminal to start UART communication?

I would like to modify the UART protocol to apply to my control protocol and eventually control it via the bus, such as rs232 or rs485, using a simple check (non-CRC). Protocol.c is full of complex protocol processing and protocol.c file is an implementation of the processing used to receive and send data. Is the commands.c and legacy_commands.c file to convert the transmitted data to commands?

What device did you connect here?

I configured the CONFIG_UART_PROTOCOL to ASCII using the human readable protocol.Use the serial port tool on the PC to send the command p 0 -20000, but no response.Is there something wrong with my operation?

4 posts were split to a new topic: Where did the Arduino lib go?

Can somebody get me started on the native protocol, please. I believe to understand all, just worried about the details, CRC in particular.

Let’s say I am in message #2 and want to read the battery voltage. I would send:

0x02 0x00 0x01 0x00 0x04 0x00 0x?? 0x??

Little endian, meaning msg id 0x0002 is sent as 0x02 0x00, endpoint is 0x0001, expected result is a float, hence 0x0004 bytes long, payload does not exist and the last two bytes are the CRC. But how are they calculated?

The protocol.hpp talks about different algorithms and does not tell what all is included. I assume it starts with the first byte and includes everything except the last two bytes, the CRC to compare with?

Anybody, please? Just a little hint to get me running…

In my javascript version I worked from the python code. Its calculated based on the JSON read from endpoint 0:

var buf = new Buffer.alloc(2)
buf.writeInt16BE(calc_crc16(PROTOCOL_VERSION, operation.payload) )
self.json_crc = buf.readInt16LE(0)
json_crc16 = fibre.protocol.calc_crc16(fibre.protocol.PROTOCOL_VERSION, json_bytes)

Just learned something new, I believe: The UART is set to ASCII protocol in the firmware. I would need to compile the firmware and keep it current if others want to use the native protocol.


Then it is not usable.

Yes but this is configurable.


I feel stupid when asking but how do I activate the native protocol, packet or streaming, on the UART?

The odrv0.* properties allow to enable ASCII on the USB port but I can’t see anything to change the UART protocol!?!

It is done through the tup.config file during compilation

Is the information in this thread still valid for current versions of the firmware?

Should be. Need to make sure you are using the correct CRC.

I made a video discussing how it works that should help.