ArduSat/libcsp — pull request #29 by bryanyw (2014-04-03 23:03:38+00:00)
Title: fixed ISR to loop mailboxes until no more servicable events.

@jtrutna @jcappaert @JoelSpark @mconst-nanosatisfi

Fix CAN ISR to loop through mailboxes more than once to assure that no more serviceable events (e.g. rx data) have come in in the meantime.

If not, data will sit there, and will only be serviced upon receipt of new data (i.e. a new ISR).
After that point, the old data will be too old (the CSP request may have timed out), and the next set of incoming data may also be ignored (causing persistent failures).

This is likely to address the following observations seen during integration tests, (although I haven't been able to fully recreate the scenarios, so I can't say it verifiably):
- "out of order MORE frame received" (though this can also happen if there is legitimate load on the system or large burst of data that the ISR cannot handle in time).
- CSP port inversion. What actually is happening is that that CSP messages (such as pings) toggle between 62 and 63 as their source port. The "inversion" scenario is possibly the receipt of "last message's data" from the CAN mailbox. This is also why persistent timeouts would go hand in hand with the witnessing of the inversion.

Above scenarios were captured in: https://gist.github.com/bryanyw/764de2e0e462adaba775 (this was with the original ISR before I had fixed it.)

Special thanks to @mconst-nanosatisfi for schooling me in the ways of ISRs :-)

Changes
- improve ISR to loop until no new serviceable events are detected.
- added more diagnostic info to certain warnings, so if they do occur, we have a little more visibility into what happened.
- reindentation of code...that's why all the diffs :(

The true test will be if the CAN drivers can handle the extra load of encryption....