The idea is making a two columns array, where the first column keeps different alarm messages available, while the second column keeps the state-variables of the corresponding error.
Later on, only active errors, which has it's state-variable flag set, will be sent in the SMS (and the number of active errors).
Unfortunately my code did not work, and I therefor ask you for some help.
void vehicle_thinkcity_fault_prepmsg(void)
{
rom char vehicle_thinkcity_fault_txttable[][] =
{
"MnyFailCel", // -> tc_bit_manyfailedcells;
"Crash", // -> tc_bit_crash;
"GenErr", // -> tc_bit_generalerr;
"IsoErr", // -> tc_bit_isoerr;
"IntIso", // -> tc_bit_intisoerr;
"ExtIso", // -> tc_bit_extisoerr;
"ThermIso", // -> tc_bit_thermalisoerr;
"EmgEPO", // -> tc_bit_epoemerg;
"ChgWaitTemp", // -> tc_bit_chgwaittemp;
"ReachEOC", // -> tc_bit_reacheocplease;
"WaitOkTpDcg", // -> tc_bit_waitoktmpdisch;
"CrgWaitTp2", // -> tc_bit_chgwaitttemp2;
"NoChgCur", // -> tc_bit_nochgcurr;
"ChgOverVolt", // -> tc_bit_chgovervolt;
"ChgOverCur", // -> tc_bit_chgovercurr;
""
};
rom char vehicle_thinkcity_fault_vartable[] =
{
tc_bit_manyfailedcells,
tc_bit_crash,
tc_bit_generalerr,
tc_bit_isoerr,
tc_bit_intisoerr,
tc_bit_extisoerr,
tc_bit_thermalisoerr,
tc_bit_epoemerg,
tc_bit_chgwaittemp,
tc_bit_reacheocplease,
tc_bit_waitoktmpdisch,
tc_bit_chgwaitttemp2,
tc_bit_nochgcurr,
tc_bit_chgovervolt,
tc_bit_chgovercurr
};
char *s;
int k;
int errcount = 0 ;
s = strchr(net_scratchpad, 0);
s = stp_rom(s, "Act err:");
//additional info for error-print
if (tc_pack_failedcells != 0)
{
s = stp_i(s, "\rFailCel:", tc_pack_failedcells);
errcount++;
}
// end additional info
for (k = 0; vehicle_thinkcity_fault_txttable[k][0] != 0; k++)
{
if (vehicle_thinkcity_fault_vartable[k] != 0)
{
s = stp_i(s, "\r", vehicle_thinkcity_fault_txttable[k]);
k++;
errcount++;
}
}
s = stp_i(s, "\rTot err: ", errcount);
}
Best regards
Håkon