Have issue with certain integer values during conversion to a string randomly gain in value or refuse to follow the originating variable changes as the tStat is being printed. The local variable is reading the correct integer value but the value being sent into the Cloud is not the same and or intermittently follows the local variable suggesting the integer conversion function is breaking down.
This is isolated to integers of type short (s16) or (ucChar8) that go amuck during conversion possibly in ustrtoul().
When trying to add code to zero the two idle tStat values in UARTprintf() as to NULL the stuck integer tStat values, the pseudo tStat name value directly effects the value of the exported variable back into the sending variable data. That ain't supposed to happen in the real world.
The CCS compiler is linking s16 and uChar8 typedef stuct pseudo names data (bidirectional) to the original integer pointing to the local host exported variable name in (*.h). It is possible to zero the typedef struct by using it's pseudo name that is linked to the local variable being printed. That infers the typedef struct integer conversion routines may be causing the problem.
Other integer values such as ul32 or ui32 do not have this problem as does s16 or ucChar8.
Pseudo named tStat:
tStat g_sMotorAmps =
{"Motoramps", &g_sMotorCurrent, "motoramps", INT, WRITE_ONLY};
tStat g_sMotorStatus =
{"Motorstatus", &g_ucMotorStatus, "motorstatus", INT, WRITE_ONLY};
Do some INT conversions:
else if((psStat->eValueType == INT) ||
(psStat->eValueType == HEX))
{
StatIntVal(*psStat) = ustrtoul(pcInputValue, NULL, 0); //was 0 auto radix
}
else if((psStat->eValueType) == INT)
{
//
// If this is an integer value, just print the value as text into the
// destination string.
//
usprintf(pcValueString, "%i", StatIntVal(*psStat)); //was %d
/* Zero the value of the previous usprintf integer passed to UARTprintf(). /*
StatIntVal(*psStat) = 0x00000000; //6.13.2015
}
Print the integer values that have been converted into strings:
//
// Loop over all statistics in the list.
for(ui32Index = 0; psStats[ui32Index] != NULL; ui32Index++)
{
//UARTprintf("\n");
if(psStats[ui32Index]->pcName)
{
// For each statistic, print the name and current value to the UART.
pcStatName = psStats[ui32Index]->pcName;
StatPrintValue(psStats[ui32Index], pcStatValue);
UARTprintf("> %25s= %4s\n", pcStatName, pcStatValue);
}