An update about implementing SocketCAN onto NuttX.
Initial SocketCAN implementation is working on a S32K148EVB. We can create a PF_CAN socket and read/write to it. I’m supporting both CAN and CAN FD.
Below are some preliminary results from the NuttX SocketCAN implementation, please do note this is on S32K148 with a Cortex-M4 @ 80Mhz compared to the K64 with a Cortex-M4 @ 120Mhz used for the Zephyr tests. The receive latency has been decreased compared to the Zephyr implementation and the transmit latency is a bit worse, however I’ve already found the problem why the transmit latency is higher and can probably reduce it to 30-40us however this needs some further testing.
Preliminary results | Transmit | Receive |
---|---|---|
NuttX SocketCAN | 67us | 26us |
NuttX SocketCAN FD | 71us | 30us |
If you’re interested in the code it’s located on SocketCAN NuttX. Current implementation has been mostly focused on getting all required features to work and I didn’t look specifically in performance and network scheduling.
There’s still a lot of work on my todo list to make it fully SocketCAN compliant, please find the list of missing features below.
Missing features (TODO list)
- CAN & CAN FD bitrate configuration (autobaud)
- Socket socktopt filtering support
- Self-receive loopback support
- Filter/error mask support
- Multi-CAN device
- Avoid priority inversion (Here I’ve to investigate how NuttX network scheduling works)
- Avoid buffer bloat
- Implementing specific UAVCAN socket options e.g. frame timestamping, transmitted frame removal from tx mailbox