Hello all,
I don't know if this is a known issue or not, but I thought I would throw it out to the masses for discussion. Recently I discovered the CAN SendMessage() function hanging within my MOD5234 project despite the example CAN software operating without issue (ruling out HW error). Debugging the issue further, I added debug statements within the canif.cpp source code, recompiled the CAN library, and observed what happened. The result was the SendMessage function hanging on this snippit of code:
// wait while mb is busy */
while ( pmb->bStatus & 0x0100 )
{
asm (" nop");
}
As I further diagnosed the issue, I realized the SendMessage() function identified an available channel despite it already being open by a call to RegisterCanRxFifo() elsewhere in the code. I register two Rx channels in the main body of code, confirmed by IsChannelFree(). I then kick off three OSTaskCreate to listen on three separate UDP ports and taken action upon receiving appropriate packets. Prior to calling SendMessage() within one of the tasks, I checked to see the IsChannelFree() status and it reports all channels free; rather bizarre since two of them are already spoken for as Rx channels. Since SendMessage() defaults to Channel 0 for transmission, it sees it as free and then blocks on checking the bStatus because it is already being used.
Perhaps it is a subtle OSTask issue that I am unaware of, but has anyone encountered this or have justification for why it is happening?
The work around I have implemented is to simply call SendMessage() with a channel argument one more than the known open channels, but that just doesn't sit well with me...
Any thoughts/info would be appreciated!
Thanks,
- Mark