1. Is it possible to pass an array of uint8_t values ?
I have tried the following:
Code: Select all
ble_parser_queue = xQueueCreate(10, sizeof(uint8_t*));
xTaskCreate(BLE_parser_task,"BLE_parser_task",10000,NULL,1,NULL);
Code: Select all
static void BLE_parser_task(void *argument)
{
uint8_t* data_received;
for(;;)
{
if (xQueueReceive(ble_parser_queue, &data_received, 0) == pdTRUE) {
printf("data_received[0] = %u\n",data_received[0]);
}
else{
printf("no data received yet \n");
}
vTaskDelay(1000/portTICK_RATE_MS);
}
}
Code: Select all
uint8_t test_data[5] = {1,2,3,4,5};
xQueueSend(ble_parser_queue, &test_data, 10);
2. I have tried a different approch and I pass the structure of the data to the queue which contains my uint8_t* data and data length.
The problem is, inside my ble_parser_task, I am not able to read back the array information. I think I have an idea of what might be happening - the stack memory is cleared.
Code: Select all
struct ble_message_s{
uint8_t* payload;
uint8_t length;
};
uint8_t data_to_send2[5] = {1,2,3,4,5};
ble_message_s message;
message.payload = data_to_send2;
message.length = sizeof(data_to_send2);
xQueueSend(ble_parser_queue,&message, 10);