console.c: fail to understand some code
Posted: Fri Apr 17, 2015 3:18 pm
Hi everybody,
I'm currently trying to translate the Crazyflie 2.0 firmware in ADA. Looking deeper in the code, I don't understand this piece of code, located in console.c:
I don't understand the purpose of the 'fullMsg' static variable, and why we replace some data we want to send by these characters when the CRTP Tx queue has only one free packet.
Could you explain this to me, please?
I'm currently trying to translate the Crazyflie 2.0 firmware in ADA. Looking deeper in the code, I don't understand this piece of code, located in console.c:
Code: Select all
static const char fullMsg[] = "<F>\n";
// ...
int consolePutchar(int ch)
{
int i;
// ...
if (ch == '\n' || messageToPrint.size >= CRTP_MAX_DATA_SIZE)
{
if (crtpGetFreeTxQueuePackets() == 1)
{
for (i = 0; i < sizeof(fullMsg) && (messageToPrint.size - i) > 0; i++)
{
messageToPrint.data[messageToPrint.size - i] =
(uint8_t)fullMsg[sizeof(fullMsg) - i - 1];
}
}
consoleSendMessage();
}
xSemaphoreGive(synch);
}
return (unsigned char)ch;
}
Could you explain this to me, please?
