# SocketCAN API on a RTOS

**URL:** <https://forum.opencyphal.org/t/socketcan-api-on-a-rtos/750>\
**Category:** Applications & Usage\
**Created:** [February 10, 2020, 3:56pm UTC](https://forum.opencyphal.org/t/socketcan-api-on-a-rtos/750 "2020-02-10T15:56:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![PetervdPerk](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@PetervdPerk](https://forum.opencyphal.org/u/PetervdPerk)\
**Post date:** [February 28, 2020, 9:49am UTC](https://forum.opencyphal.org/t/socketcan-api-on-a-rtos/750/6 "2020-02-28T09:49:31Z")

</div>

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](https://github.com/PetervdPerk-NXP/incubator-nuttx/tree/SocketCAN). 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

---

_[View the full topic](https://forum.opencyphal.org/t/socketcan-api-on-a-rtos/750)._
