CAN Bus driver will not exit.
If the CAN bus connector is not connected to the bus. The queued writes can fill the SW FIFO and HW FIFO. The device will not close and will be hung here: https://github.com/apache/incubator-nuttx/blob/master/drivers/can/can.c#L532-L542
I would like feedback on some possible solutions.
- Remove the code. - While it attempts an orderly shut down it will hang.
- Allow the loops to try once to flush. Then time out and force the close resetting the HW and SW FIFO
- Add IOCTLs akin to: TCIFLUSH (CANIOC_IFLUSH) - flushes data received but not read. TCOFLUSH (CANIOC_OFLUSH)) - flushes data written but not transmitted. TCIOFLUSH (CANIOC_IOFLUSH) -flushes both data received but not read, and data written but not transmitted. FIONWRITE (CANIOC_FIONWRITE) - Number bytes in send queue (FIFO)
The last solution would allow the application to decide if it should linger on close.
Any progress with this issue?
As per email list discussion I will take a look at what's involved in implementing the IOCTL proposal as it "feels" right; probably in the next few weeks.
Probably need additional IOCTLs to get RX and TX buffer status as well as other information - that will make for a much more thorough CAN implementation without recourse to using things such as Socket CAN.