Open vincentabraham opened 2 years ago
I've written the following program in main.c:
TaskHandle_t vTask1Handle = NULL; TaskHandle_t vTask2Handle = NULL; QueueHandle_t myQueue; void vTask1(void* p); void vTask2(void* p); void vTask1(void* p) { char myTxBuff[30]; myQueue = xQueueCreate( 1, // Size of the queue sizeof(myTxBuff) // Size of each block ); sprintf(myTxBuff, "Message 1"); xQueueSend( myQueue, (void*) myTxBuff, (TickType_t) 0 ); sprintf(myTxBuff, "Message 2"); xQueueOverwrite( myQueue, (void*) myTxBuff ); vTaskDelay(pdMS_TO_TICKS(1000)); printf("Data Waiting to be read: %d\r\n", uxQueueMessagesWaiting(myQueue)); //vTaskDelay(pdMS_TO_TICKS(1000)); printf("Spaces Available: %d\r\n", uxQueueSpacesAvailable(myQueue)); while(1) { ; } } void vTask2(void* p) { char myRxBuff[30]; while(1) { vTaskDelay(pdMS_TO_TICKS(1000)); if(myQueue != 0){ if(xQueuePeek(myQueue, (void*)myRxBuff, (TickType_t)0)){ printf("Data Received: %s\r\n", myRxBuff); } } } } int main(void) { xTaskCreate(vTask1, // Function that the task executes "Task 1", // Name 1024, // Stack Size (void*)0, // Parameters 1, // Priority &vTask1Handle); // Task Handler xTaskCreate(vTask2, // Function that the task executes "Task 2", // Name 1024, // Stack Size (void*)0, // Parameters 1, // Priority &vTask2Handle); // Task Handler vTaskStartScheduler(); while(1) { ; } return 0; }
However, this is the output I get: How could I get the strings to print properly? It seems like if there are more than one lines to print, then this happens.
I've written the following program in main.c:
However, this is the output I get: How could I get the strings to print properly? It seems like if there are more than one lines to print, then this happens.