drivers/cc2420: Implemented missing drop case#10416
Conversation
drivers/cc2420/cc2420.c
Outdated
| DEBUG("cc2420: recv: packet of length %i in RX FIFO\n", (int)len); | ||
| if (max_len != 0) { | ||
| /* dropping frame was requested */ | ||
| cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); |
There was a problem hiding this comment.
AFAIS since the second cc2420_strobe is in the else block, this function will only get called once. Thus, the FIFO won't be flushed properly.
I guess that could be solved putting both cc2420_strobe in the end and adding return statement with the length here.
|
BTW we should indeed document the silicon bug (see CC2420 datasheet, section 14.3) in another PR :) |
Maybe that should be done first and rebase this PR on it? I believe a static inline function to flush the FIFO will be more readable and less surprising instead of having two times the same command. This static inline function can be documented properly. |
Agreed! Could you open a PR? I can also do it, let me know ;) |
|
Today I'm too busy to attend to it. Feel free to create the PR. Otherwise I can do it tomorrow. |
Ok, I will then. |
The netdev_driver_t::recv implementation of the cc2420 does not provide the drop feature. This commit adds it.
As decided in RIOT-OS#10413 when netdev_driver_t::recv() is called with a too small buffer the incoming frame should be dropped and `-ENOBUFS` returned. This commit makes cc2420 compliant.
|
From docs: With this PR:
So, this fixes the initial issue |
jia200x
left a comment
There was a problem hiding this comment.
I don't have hardware to test, but I'm OK giving an untested ACK
@jia200x you do! |
|
oh yes, I do 😅 |
|
Tested on Zolertia Z1 and seems to work OK. I modified the rx buffer to 30 bytes. I send ~100 packets (40 bytes) and they are dropped with -ENOBUFS. Then, sending ~100 packets (<= 30 bytes) still work. Also the |
|
All green. GO. Thanks for your contribution! |
Contribution description
The netdev_driver_t::recv implementation of the cc2420 does not provide the drop feature. This PR adds it.
Testing procedure
It would be nice to add a test application for this, as many drivers are affected...
Issues/PRs references
#10410
Update 1: Removed warning about possible regression. Double flushing of the RX FIFO is indeed required and now is properly documented as to #10725. This PR was updated to perform double flushing of the RX FIFO using the new inline function in #10725