Odrive Communication over UART

I am using firmware version 0.5.4 on ODrive3. I am trying to implement native communication over UART as per the documentation: ODrive Communication Protocol # | ODrive

I am creating the query packet, just a serial number request. I am using the JSON signature that I have sniffed from the USB communications.
F3 03 05 80 08 00 71 D2

F3 03 : First two bytes sequence
05 80 : Preceeding two as endpoint ID + Requesting a reply
08 00 : Expected reply size
71 D2 : Signature sniffed from USB

Than I am wrapping this packet using
AA 08 CRC8 : Header
8 bytes : Packet Itself
CRC16 : With reversed byte order …

But odrive is silent. I am not receiving a response.

I have set GPIO1 and 2 as GPIO_MODE_UART_A
Enabled uart using enable_uart_a (b is disabled)
uart0_protocol=STREAM_PROTOCOL_TYPE_FIBRE (I am not sure about this, is the FIBRE documented native protocol or an other type of communication???)

Do you have any ideas what can be wrong?

Hi,
in version 0.5.2, they refactored the native UART communication code so much that it is pretty much unusable now. So I’d suggest to use 0.5.1 (I do so too).
Another benefit is that odrivetool can connect via UART in 0.5.1 too, so you can test your connection with that first.
There is however a little bug in 0.5.1 that you have to fix first. You have to add these #ifdefs in Firmware/communication/interface_uart.cpp and then recompile the firmware:

// deadline_ms = timeout_to_deadline(PROTOCOL_SERVER_TIMEOUT_MS);
        // Process bytes in one or two chunks (two in case there was a wrap)
        if (new_rcv_idx < dma_last_rcv_idx) {
#ifdef UART_PROTOCOL_NATIVE
            uart4_stream_input.process_bytes(dma_rx_buffer + dma_last_rcv_idx,
                    UART_RX_BUFFER_SIZE - dma_last_rcv_idx, nullptr); // TODO: use process_all
#endif
#ifdef UART_PROTOCOL_ASCII
            ASCII_protocol_parse_stream(dma_rx_buffer + dma_last_rcv_idx,
                    UART_RX_BUFFER_SIZE - dma_last_rcv_idx, uart4_stream_output);
#endif
            dma_last_rcv_idx = 0;
        }
        if (new_rcv_idx > dma_last_rcv_idx) {
#ifdef UART_PROTOCOL_NATIVE
            uart4_stream_input.process_bytes(dma_rx_buffer + dma_last_rcv_idx,
                    new_rcv_idx - dma_last_rcv_idx, nullptr); // TODO: use process_all
#endif
#ifdef UART_PROTOCOL_ASCII
			ASCII_protocol_parse_stream(dma_rx_buffer + dma_last_rcv_idx,
                    new_rcv_idx - dma_last_rcv_idx, uart4_stream_output);
#endif
            dma_last_rcv_idx = new_rcv_idx;
        }

BTW to find out the JSON crc number you don’t have to sniff USB. You can run “odrivetool --verbose” and get the number in this string:
// Device reported JSON version ID: xxxxxxx
Then take the upper 16 bits of that 32 bit number.

Hope this helps :slight_smile:

Thank you for your quick reply,

I was just checking this thread ODrive ignores most requests in UART native mode - #13 by HerrNamenlos123
where you have also contributed.

I have added 200uS delays between bytes and now odrive is mostly responding. Of course I this is not a solution. I will try to downgrade to 0.5.1, Just need to check what functionality that I will be loosing by doing so.

Do you have any idea if this “bug” would resolved in the upcomming releases soon?

Thanks again…

It’s been over a year now. Is this bug still not fixed @Wetmelon ?