Show
Ignore:
Timestamp:
01/31/10 18:53:49 (15 years ago)
Author:
phil
Message:

- added output function for Voltages and Wattages to generate_rtos_stats ,
- added detection of read error in SolarFSM() with restart.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c

    r37 r39  
    104104 
    105105 
     106portTickType xLastSolarStateChangeTime; 
     107 
     108 
     109int solarReadErrors = 0; 
     110 
    106111/* pototype  section */ 
    107112 
     
    134139void initSolarFSM(void) 
    135140{ 
     141  xLastSolarStateChangeTime = xTaskGetTickCount(); 
    136142  xLastReadTime = xTaskGetTickCount(); 
    137143  solarState = SOL_NO_INIT; 
     
    315321  getUart3RxData(); 
    316322 
     323  /* did the SolarFSM get stuck during reading? */ 
     324  if (xTaskGetTickCount() > xLastSolarStateChangeTime + 5000) 
     325  { 
     326    /* something has gone wrong (possible Rx Timeout). restart, state SOL_NO_INIT */ 
     327    xLastSolarStateChangeTime = xTaskGetTickCount(); 
     328    initSolarFSM(); 
     329    solarReadErrors++; 
     330  } 
     331 
     332 
    317333  switch (solarState) 
    318334  { 
     
    323339       /* send init 1 */ 
    324340      send_uart3((unsigned char *)init1, sizeof(init1)); 
     341      xLastSolarStateChangeTime = xTaskGetTickCount(); 
    325342      solarState = SOL_SENT_INIT; /* now wait for reply */ 
    326343    break; 
     
    341358 
    342359      /* now ready to query channel 0 data in next state */ 
     360      xLastSolarStateChangeTime = xTaskGetTickCount(); 
    343361      solarState = SOL_CHAN; 
    344362    } 
     
    377395      case 6: 
    378396        /* we are through with all the channels, ready to send next init for next query round */ 
     397        xLastSolarStateChangeTime = xTaskGetTickCount(); 
    379398        solarState = SOL_FINISHED; 
    380399        break; 
     
    384403     if (solarState != SOL_FINISHED) 
    385404     { 
     405     xLastSolarStateChangeTime = xTaskGetTickCount(); 
    386406      solarState = SOL_CHAN_WAIT_REPLY; /* wait for reply if not finished */ 
    387407     } /* if */ 
     
    443463          currentChannel++; 
    444464          /* now ready to query channel data for next channel */ 
     465          xLastSolarStateChangeTime = xTaskGetTickCount(); 
    445466          solarState = SOL_CHAN; 
    446467        } 
     
    448469        { 
    449470          /* we received the finishing sequence */ 
     471          xLastSolarStateChangeTime = xTaskGetTickCount(); 
    450472          solarState = SOL_NO_INIT; /* restart the measurement cycle */ 
    451473        }