Index: /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c =================================================================== --- /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 77) +++ /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 78) @@ -715,5 +715,5 @@ } - send_yield_query_hour(/* channel: */ currentChannel, /* hour: last hour */ checkHour ); + send_yield_query_hour(/* channel: */ currentChannel, /* hour: last hour */ checkHour-1 ); xLastSolarStateChangeTime = xTaskGetTickCount(); solarState = SOL_QUERY_LASTHOUR_YIELD_WAIT_REPLY; /* query next channel. change state: now wait for response */ @@ -1370,5 +1370,5 @@ unsigned char newChkSum; - req_day_yield[5] = 0x30 + channel; // channel + req_day_yield[5] = 0x30 + channel; // channel ( 0 to 5 ) @@ -1394,5 +1394,5 @@ unsigned char hourLSB; - req_hour_yield[5] = 0x30 + channel; // channel + req_hour_yield[5] = 0x30 + channel; // channel ( 0 to 5 ) @@ -1422,5 +1422,5 @@ unsigned char minuteLSB; - req_minute_yield[5] = 0x30 + channel; // channel + req_minute_yield[5] = 0x30 + channel; // channel ( 0 to 5 ) @@ -1445,9 +1445,25 @@ { - *outLSB = convertSingleDigit(inValue & 0xF); - *outMSB = convertSingleDigit(((inValue >> 4) & 0xF)); + *outLSB = convertSingleDigitHex(inValue & 0xF); + *outMSB = convertSingleDigitHex(((inValue >> 4) & 0xF)); } -unsigned char convertSingleDigit(unsigned char inValue) + +void convert_uchar_to_2_byte_decencoding(unsigned char inValue, unsigned char * outMSB, unsigned char * outLSB) +{ + + unsigned char msb; + unsigned char lsb; + + lsb = (inValue % 10); /* remainder of division by 10 */ + msb = (inValue - lsb) / 10; + + /* now convert to ASCII chars */ + *outLSB = 0x30 + lsb; + *outMSB = 0x30 + msb; +} + + +unsigned char convertSingleDigitHex(unsigned char inValue) { unsigned char retVal; @@ -1511,3 +1527,3 @@ return retVal; -} /* convertSingleDigit() */ +} /* convertSingleDigitHex() */ Index: /webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h =================================================================== --- /webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (revision 77) +++ /webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (revision 78) @@ -3,5 +3,7 @@ void convert_uchar_to_2_byte_hexencoding(unsigned char inValue, unsigned char * outMSB, unsigned char * outLSB); -unsigned char convertSingleDigit(unsigned char inValue); +unsigned char convertSingleDigitHex(unsigned char inValue); + +void convert_uchar_to_2_byte_decencoding(unsigned char inValue, unsigned char * outMSB, unsigned char * outLSB);