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();