Index: /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
===================================================================
--- /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 70)
+++ /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 71)
@@ -270,5 +270,5 @@
for (i = 0; i < NUMBER_OF_SOLAR_CHANNELS; i++)
{
- dayRxYield[i] = 0;
+ dayRxYield[i] = 65535; /* default: invalid/unset value */
} /* for */
@@ -450,5 +450,5 @@
unsigned char power; /* variable for conversions */
unsigned char checkDate; /* temp variable for day of month */
-
+ unsigned char rxYieldChkSum; /* temp checksum for rx yield */
/* always get Rx data */
@@ -616,9 +616,10 @@
else if
((scDate[1] == 1) ||
- (scDate[1] == 5) ||
- (scDate[1] == 7) ||
- (scDate[1] == 8) ||
- (scDate[1] == 10) ||
- (scDate[1] == 12))
+ (scDate[1] == 1+1) ||
+ (scDate[1] == 3+1) ||
+ (scDate[1] == 5+1) ||
+ (scDate[1] == 7+1) ||
+ (scDate[1] == 8+1) ||
+ (scDate[1] == 10+1))
{
checkDate = 31;
@@ -660,19 +661,38 @@
if (cmpResult == 0)
{
- /* we have got a match! */
-
- if (currentChannel <= 5)
+ /* we have got a match (i.e. expected frame received) ! */
+
+ /* calculate the checksum of the received data */
+
+ rxYieldChkSum = calculate_crc8( (&(rxUART3[0])), (sizeof(yield_day_rsp)-2));
+
+ if (rxYieldChkSum == rxUART3[17])
{
-
-
- dayRxYield[currentChannel] =
- extractBinaryHexDigitString( &(rxUART3[0]), 13, 16 );
-
- } /* if */
+ /* checksum is correct! */
+
+ if (currentChannel <= 5)
+ {
+
+ /* convert and copy value */
+ dayRxYield[currentChannel] =
+ extractBinaryHexDigitString( &(rxUART3[0]), 13, 16 );
+
+ } /* if */
+ else
+ {
+ /* all channels done. nothing to do, we leave via SOL_QUERY_YIELD */
+ }
+ }
+ else if (currentChannel <= 5)
+ {
+ /* valid channel index. but checksum is incorrect ! */
+ dayRxYield[currentChannel] = 65535; /* invalid value */
+ }
else
{
- /* all channels done. nothing to do, we leave via SOL_QUERY_YIELD */
+ /* checksum incorrect and channel index out of range. do nothing. */
}
+ /* always move on to the next value... */
currentChannel++; /* increment channel counter so we query the next channel in the next round */
Index: /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c
===================================================================
--- /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c (revision 70)
+++ /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c (revision 71)
@@ -285,11 +285,8 @@
} /* for */
- for (i = 0; i < NUMBER_OF_SOLAR_CHANNELS; i++)
- {
- sprintf( cCountBuf, "DAY %u %u\n", (int)i, dayRxYield[i] );
- strcat( uip_appdata, cCountBuf );
- }
-
+
+ sprintf( cCountBuf, "DAY %u %u %u\n", dayRxYield[0], dayRxYield[1], dayRxYield[2] );
strcat( uip_appdata, cCountBuf );
+
Index: /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs
===================================================================
--- /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (revision 70)
+++ /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (revision 71)
@@ -21,6 +21,4 @@
-
-
@@ -42,8 +40,8 @@
+
+
+
-
-
-
@@ -58,17 +56,18 @@
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+