Changeset 39 for webserver/example/EnergyMeters/Source
- Timestamp:
- 01/31/10 18:53:49 (15 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
r37 r39 104 104 105 105 106 portTickType xLastSolarStateChangeTime; 107 108 109 int solarReadErrors = 0; 110 106 111 /* pototype section */ 107 112 … … 134 139 void initSolarFSM(void) 135 140 { 141 xLastSolarStateChangeTime = xTaskGetTickCount(); 136 142 xLastReadTime = xTaskGetTickCount(); 137 143 solarState = SOL_NO_INIT; … … 315 321 getUart3RxData(); 316 322 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 317 333 switch (solarState) 318 334 { … … 323 339 /* send init 1 */ 324 340 send_uart3((unsigned char *)init1, sizeof(init1)); 341 xLastSolarStateChangeTime = xTaskGetTickCount(); 325 342 solarState = SOL_SENT_INIT; /* now wait for reply */ 326 343 break; … … 341 358 342 359 /* now ready to query channel 0 data in next state */ 360 xLastSolarStateChangeTime = xTaskGetTickCount(); 343 361 solarState = SOL_CHAN; 344 362 } … … 377 395 case 6: 378 396 /* we are through with all the channels, ready to send next init for next query round */ 397 xLastSolarStateChangeTime = xTaskGetTickCount(); 379 398 solarState = SOL_FINISHED; 380 399 break; … … 384 403 if (solarState != SOL_FINISHED) 385 404 { 405 xLastSolarStateChangeTime = xTaskGetTickCount(); 386 406 solarState = SOL_CHAN_WAIT_REPLY; /* wait for reply if not finished */ 387 407 } /* if */ … … 443 463 currentChannel++; 444 464 /* now ready to query channel data for next channel */ 465 xLastSolarStateChangeTime = xTaskGetTickCount(); 445 466 solarState = SOL_CHAN; 446 467 } … … 448 469 { 449 470 /* we received the finishing sequence */ 471 xLastSolarStateChangeTime = xTaskGetTickCount(); 450 472 solarState = SOL_NO_INIT; /* restart the measurement cycle */ 451 473 }