'How to print char buffer on FreeRtos returned by function xQueueReceive
I am using Free RTOS for a project.
I have a higher priority task appending char buffers to a Free RTOS queue and a smaller priority task popping the char buffers from the queue and printing them.
QueueHandle_t xQueue1 = xQueueCreate(10,50);
//higher priority task
for(;;){
char buffer[50];
sprintf(buffer, "%s, %d\n", t1[i].name, tman_tick);
if( xQueue1 != 0 ){
if( xQueueSend( xQueue1,( void * ) &buffer,( TickType_t ) 0 ) != pdPASS ){
/* Failed to post the message, even after 10 ticks. */
}
}
}
//lower priority task
for(;;){
void * xStructure;
char *ptemp;
if( xQueueReceive( xQueue1,& (xStructure),( TickType_t ) 10 ) == pdPASS ){
/* xStructure now contains a copy of xMessage. */
printf("ENTERS HERE\n");
ptemp = (char *)xStructure;
printf("HERE TOO\n");
printf("%s\n", ptemp);
}
}
I think everything is working except the last print. It print "ENTERS HERE" and "HERE TOO", but after the conversion to a char array, it can not print the ptemp and I don't know why. Am I doing the conversion in a wrong way?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
