Index: /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c =================================================================== --- /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 57) +++ /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 58) @@ -165,5 +165,4 @@ int i; xLastSolarStateChangeTime = xTaskGetTickCount(); - xLastSolarHistoryAdvance = xTaskGetTickCount(); xLastReadTime = xTaskGetTickCount(); solarState = SOL_NO_INIT; @@ -172,16 +171,11 @@ currentChannel = 0; - /* set data to invalid value */ + /* set recent data item to invalid value */ chanWatt[0] = SOLAR_FSM_INVALID_VALUE; chanWatt[1] = SOLAR_FSM_INVALID_VALUE; chanWatt[2] = SOLAR_FSM_INVALID_VALUE; - /* invalidate history */ - for (i = 0; i < SOLAR_WATT_HISTORYSIZE; i++) - { - SolarHistory[i][0] = SOLAR_FSM_INVALID_VALUE; - SolarHistory[i][1] = SOLAR_FSM_INVALID_VALUE; - SolarHistory[i][2] = SOLAR_FSM_INVALID_VALUE; - } + /* do not invalidate history here so we do not lose all data */ + } /* initSolarFSM */ @@ -711,6 +705,18 @@ static portTASK_FUNCTION( vSolar_Task, pvParameters ) { + int i; init_serial3(); + + /* invalidate history */ + for (i = 0; i < SOLAR_WATT_HISTORYSIZE; i++) + { + SolarHistory[i][0] = SOLAR_FSM_INVALID_VALUE; + SolarHistory[i][1] = SOLAR_FSM_INVALID_VALUE; + SolarHistory[i][2] = SOLAR_FSM_INVALID_VALUE; + } + + xLastSolarHistoryAdvance = xTaskGetTickCount(); + initSolarFSM(); Index: /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c =================================================================== --- /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c (revision 57) +++ /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c (revision 58) @@ -250,12 +250,13 @@ strcat( uip_appdata, cCountBuf ); - for (i = 0; i < SOLAR_WATT_HISTORYSIZE; i++) + for (i = SOLAR_WATT_HISTORYSIZE; i > 0; i--) { + /* print history in reverse direction */ sprintf( cCountBuf, "SH %u %u %u %u\r\n", - (SOLAR_WATT_HISTORY_STEPSIZE * i), - SolarHistory[i][0], - SolarHistory[i][1], - SolarHistory[i][2] + ((SOLAR_WATT_HISTORY_STEPSIZE) * (i-1)), + SolarHistory[i-1][0], + SolarHistory[i-1][1], + SolarHistory[i-1][2] ); strcat( uip_appdata, cCountBuf );