Hi,

I'm implementing the CAN statistics in Nuttx but I have some doubts about
where to increase the drop counter. The data that is not accepted by the
application is handled in the `can_datahandler` function. As the function
documentation says, this function may be called either from the data
receive logic if it cannot buffer the data, or from the CAN event logic if
there is no listener in place ready to receive the data. I see it being
called from two places, from  the execution path
can_input->can_in->can_callback->can_data_event->can_datahandler (in
`can_data_event` there is a comment saying that the drop counter has to be
increased there if can_datahanlder fails to store the frame) and from
can_recvfrom_eventhandler->can_newdata->can_datahandler. Should I increase
the drop counter in both cases? whenever can_datahandler is called and
fails to store the data in the readahead linked list? Even when there is no
listener in place?

Also, I see two different paths in can_input function:
1. If the device already has a iobuffer assigned (dev->d_iob != NULL), the
first execution path previously described is executed:
can_input->can_in->can_callback->can_data_event->can_datahandler (assuming
that `devif_conn_event` fails to send data to the listener). As I said, if
`can_datahandler` fails to store the frame in the readahead linked list,
the drop counter is increased.

2. If the device doesn't have a iobuffer assigned (dev->d_iob == NULL),
`can_input` calls `netdev_input` to try to get an iobuffer from the free
buffers list (g_iob_freelist). If it succeeds and gets a buffer from the
list, it calls `can_in` and the same path as in case 1 is taken but, if
there are no more io buffers available in the list, `netdev_input` fails. I
think I should also increase the drop counter in this case. Am I right?

Thanks

Javier Casas MarĂ­n
Geotab

Senior Embedded Systems Developer

Direct
Toll-free

Visit


+34 900 535 371
www.geotab.com/es

Twitter <https://twitter.com/geotab> | Facebook
<https://www.facebook.com/Geotab> | YouTube
<https://www.youtube.com/user/MyGeotab> | LinkedIn
<https://www.linkedin.com/company/geotab/>

Reply via email to