nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

CAN Bus driver will not exit.

Open davids5 opened this issue 4 years ago • 1 comments

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.

  1. Remove the code. - While it attempts an orderly shut down it will hang.
  2. Allow the loops to try once to flush. Then time out and force the close resetting the HW and SW FIFO
  3. 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.

davids5 avatar Jun 15 '21 15:06 davids5

Any progress with this issue?

Igor-Misic avatar Jan 28 '22 13:01 Igor-Misic

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.

TimJTi avatar Aug 10 '23 08:08 TimJTi