hubo / hubo-ach

Low level controller for the Hubo 2 and Hubo 2+ platforms designed by Daniel M. Lofaro. The system is based on the IPC called ACH by Neil Dantam and Mike Stilman.
Other
5 stars 18 forks source link

Potential error after flushCan #54

Open ndantam opened 11 years ago

ndantam commented 11 years ago

It looks like the purpose of flushCan() is to discard any previously received messages before performing some queries with the JMCs. However, if we receive some extra CAN message during those queries, this will break.

Fortunately, decodeParamFrame() does some message validation to ensure that it has the proper IDs. However, rather than discard spurious messages, decodeParamFrame() prints an error and bails out.

I think the right behavior here is validate IDs for each received CAN frame, and discard that frame if the IDs don't match. Only if we do not receive a correct response from the JMC before some timeout should we abort (or maybe even retry). This would also make the flushCan() function unnecessary.