Hello,
I am looking to send packets of real time accelerometer data over uart to my PC via uart. The packets are similar to the code shown below where the data array is a buffer full of the accelerometer samples:
Hello,
I am looking to send packets of real time accelerometer data over uart to my PC via uart. The packets are similar to the code shown below where the data array is a buffer full of the accelerometer samples:
Hi Matt
I am a bit unsure what it is you need help with.
Are you asking how to convert your packet struct to a byte array so you can pass it to the UART API's?
Or are you looking for a way to packetize the UART stream?
Best regards
Torbjørn
Hi Torbjørn,
Thanks for your response.
I was looking for the best way to packetize sensory data from my nrf5340 so that it could be passed over UART to my PC.
I came up with a work around using uart_tx thought deliberately writing out the struct elements into the byte array but I was wondering if there was an api that could packetize a struct similar to that one over UART.
Thanks,
Matt
Hi Matt
There is an implementation of Slip in Zephyr, which is essentially a protocol for handling UART packetization, but the Zephyr implementation doesn't seem very generic:
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/net/slip.c
Possibly you could use this library as a starting point, and modify it to fit your requirements better, by replacing the net_pkt struct with a struct of your own.
Essentially Slip uses the standard method of using a dedicated 8-bit value to signal the end of a packet, and using a different 8-bit value as an escape character, which you can use whenever one of these dedicated values show up in the data that you want to send.
Best regards
Torbjørn
Hi Matt
There is an implementation of Slip in Zephyr, which is essentially a protocol for handling UART packetization, but the Zephyr implementation doesn't seem very generic:
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/net/slip.c
Possibly you could use this library as a starting point, and modify it to fit your requirements better, by replacing the net_pkt struct with a struct of your own.
Essentially Slip uses the standard method of using a dedicated 8-bit value to signal the end of a packet, and using a different 8-bit value as an escape character, which you can use whenever one of these dedicated values show up in the data that you want to send.
Best regards
Torbjørn