The code for Task 2 is below:
Code: Select all
xTaskCreatePinnedToCore( logWiFiDeviceData, // Task function
"TaskForLoggingWiFiDeviceData", // Task name
10000, // Stack size in words
NULL, // Parameter passed as input to task
0, // Task priority (0 is the lowest priority)
NULL, // Task handle
0 ); // Core ID
Code: Select all
void logWiFiDeviceData( void* parameter )
{
wifiDevicePayload payload;
for(;;)
{
for ( size_t i = 0; i < cg_queueSizeBetweenReceiveAndLog; ++i )
{
xQueueReceive( g_queueBetweenReceiveAndLog, &payload, portMAX_DELAY );
if ( strcmp( payload.mac, DESIRED_DEVICE_MAC_ADDRESS ) == 0 )
{
Serial.println( "MAC matched!" );
Serial.print( "Slave ID = " );
Serial.println( payload.slaveID );
Serial.print( "MAC = " );
Serial.println( payload.mac );
Serial.print( "RSSI = " );
Serial.println( payload.rssi );
Serial.print( "Packet ID = " );
Serial.println( payload.packetID );
}
}
vTaskDelay( 1 / portTICK_PERIOD_MS );
}
} // logWiFiDeviceData
The struct wifiDevicePayload is defined as:
[code]
typedef struct
{
char mac[100] = {0};
uint32_t packetID;
int8_t rssi;
int8_t slaveID;
} __attribute__((packed)) wifiDevicePayload;
[/code]
My question is: why are the information of payload.slaveID, payload.rssi, payload.packetID(which are type of int8_t, int8_t, uint32_t, respectively) got lost when transmitted by the Queue?
I am sure that the three members have non-zero values before sending into the Queue. They should be something like:
MAC matched!
Slave ID = 4
MAC = 38:10:D5:5C:58:62
RSSI = -76
packetID = 3465
I really can't figure out why I got this result and have nothing to do with this weird issue.....
Please help me...Any help is greatly appreciated!