Electronic – Data corruption while using RTOS queue services

freertoslpc1768

I am trying to create a gatekeeper task to display the sensor data over the screen via UART. The attributes are defined in the structure as follows,

typedef struct Peripheral_data
{
    volatile char data[5];
    char Source[15];
    char String[5];
    char Nextline[3];
}PeriData;
/****************************************************************************************************************

 An array of structures can be declared and initilized according to the need.

 ****************************************************************************************************************/
static PeriData Peripheral[2] =
{
        { "", "TMPSEN", "Temp:", "\r\n"},

        { "", "Light_Sensor", "Lumos", "\r\n"}

};

But on sending via the queue the Source[0] of Peripheral[0] is changing to

\0

from

T

I am attaching screenshots for reference.

Screenshot 1:
This picture shows the initilization of the structure at the beginning.enter image description here

Screenshot 2:
This picture shows the data present in Source variable for the structure one. Here the data indexed by the 0 in the Source variable is T. But automatically, after sending via the queue, the Source[0] for the first structure becomes zero sir. But sometimes this happens before sending via queue aswell.enter image description here

Could someone suggest me what could be the problemhere. Moreover I developed this code, around one month back and it ran seamlessly over the same board. The chip am using is lpc 1768.

But when I tried to run the same code now, the above mentioned problem is arising.

Best Answer

Your 'data' char array is 5 characters length. However, it seems that you tried to store a full integer in it (65519 in 2nd screenshot). Once you include '\0' character for the end of string, you end up with 6 characters. This 6th character is probably the one written at the beginning of the 2nd field.

Related Topic