Skip to content

Commit

Permalink
#197 Do not try to send lppShortPacket if the Loco deck has not been …
Browse files Browse the repository at this point in the history
…initialized

This prevents a crash if no Loco deck is installed and a user tries to send data from the client to an anchor.
  • Loading branch information
krichardsson committed Feb 16, 2017
1 parent 8f416d5 commit aa892ae
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/deck/drivers/src/locodeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,17 @@ static lpsLppShortPacket_t lppShortPacket;

bool lpsSendLppShort(uint8_t destId, void* data, size_t length)
{
lppShortPacket.dest = destId;
lppShortPacket.length = length;
memcpy(lppShortPacket.data, data, length);
return xQueueSend(lppShortQueue, &lppShortPacket,0) == pdPASS;
bool result = false;

if (isInit)
{
lppShortPacket.dest = destId;
lppShortPacket.length = length;
memcpy(lppShortPacket.data, data, length);
result = xQueueSend(lppShortQueue, &lppShortPacket,0) == pdPASS;
}

return result;
}

bool lpsGetLppShort(lpsLppShortPacket_t* shortPacket)
Expand Down

0 comments on commit aa892ae

Please sign in to comment.