sasikalaswathi wrote on Tuesday, October 15, 2019:
Hi Richard,
I created the queue item size of 100 bytes, Inside the send function sent 100 bytes successfully. Inside the receive function, char array was declared as size of 50 bytes.
While running the above configured program, program hangs at the hardfault handler function hits.
You told one thing about the queue receive function in above post,
There is no way for that function to know how big the buffer is, so it can’t check for that.
But here, it hangs at the hardfault handler.
I tried the same in the case of 10 bytes of queue item size. But at that time, no fault received. Eventhough the buffer size of 8 bytes, then anyway 10 bytes was received.
The code: for reference.
Global_Queue=xQueueCreate(1,100);
if( Global_Queue != NULL )
{
xTaskCreate( send_task, “Task 1”, 512,NULL, 1,NULL );
xTaskCreate( receive_task, “Task 12”, 512, NULL, 1, NULL );
vTaskStartScheduler();
}
void send_task(void *p)
{
BaseType_t xStatus;
const char buffer2[100]=“Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1Task1END\r\n”;
while(1)
{
xStatus = xQueueSend(Global_Queue,&buffer2,1);
if(xStatus==pdPASS)
{
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_7,0);
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_8,1);
}
}
}
void receive_task(void *p)
{
char rx[50];
BaseType_t xStatus;
const TickType_t xTicksToWait = pdMS_TO_TICKS( 1UL );
while(1)
{
xStatus = xQueueReceive(Global_Queue, &rx,xTicksToWait);
if(xStatus == pdPASS)
{
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_7,1);
}
}
}