ArduSat/libcsp — pull request #31 by bryanyw (2014-04-11 03:37:02+00:00)
Title: error fixes in CSP code

@jtrutna @jcappaert @mconst-nanosatisfi , please check to see if my changes to the CSP base make sense.

While running my test code, I came across two critical issues in the CSP which appear to be broken.

1. csp_transaction was not freeing the packet buffer when returning with no-reply-expected. The result is that any csp_transaction that we may call with the argument of inlen = 0 (which tells the function to return immediately after sending) was not freeing its buffer. If a sufficient amount of transactions in this style were made, the system would use up all of its CSP buffers. As a result, all the system transactions would fail, we would see "Out of buffers" warning issued.

I have not done an analysis of every transaction to see if there were inherent risks in our code.

I don't believe that this was an intentional design of CSP. (...If it was, it is a dumb design). The buffer grabbing and releasing occurs within the call to csp_transaction_persistent, which would lead me to believe that the intention is to return to the original state, buffer-wise, before returning (which it wasn't).

This was solved by simply freeing the buffer before returning in the instance of no-reply-expected.

2. csp_sleep_ms for FreeRTOS is improperly defined. An extra x1000 multiplier was causing the input parameters to be treated with the units of seconds. This is less critical but certainly misleading when expecting a command to return a lot earlier than it is.