Show
Ignore:
Timestamp:
10/19/10 20:56:18 (14 years ago)
Author:
phil
Message:

- changed DAY output on webpage to one line
- added checksum check for daily values
- output for invalid DAY values (or checksum error) is now 65535
- corrected previous day-of-month calculation in case of day 1

Files:

Legend:

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

    r70 r71  
    270270  for (i = 0; i < NUMBER_OF_SOLAR_CHANNELS; i++) 
    271271  { 
    272       dayRxYield[i] = 0; 
     272      dayRxYield[i] = 65535; /* default: invalid/unset value */ 
    273273  } /* for */ 
    274274 
     
    450450  unsigned char power; /* variable for conversions */ 
    451451  unsigned char checkDate; /* temp variable for day of month */ 
    452  
     452  unsigned char rxYieldChkSum; /* temp checksum for rx yield */ 
    453453 
    454454  /* always get Rx data */ 
     
    616616            else if  
    617617                 ((scDate[1] == 1) || 
    618                  (scDate[1] == 5) || 
    619                  (scDate[1] == 7) || 
    620                  (scDate[1] == 8) || 
    621                  (scDate[1] == 10) || 
    622                  (scDate[1] == 12)) 
     618                 (scDate[1] == 1+1) || 
     619                 (scDate[1] == 3+1) || 
     620                 (scDate[1] == 5+1) || 
     621                 (scDate[1] == 7+1) || 
     622                 (scDate[1] == 8+1) || 
     623                 (scDate[1] == 10+1)) 
    623624                 {  
    624625                    checkDate = 31; 
     
    660661      if (cmpResult == 0) 
    661662      { 
    662         /* we have got a match! */ 
    663         
    664           if (currentChannel <= 5) 
     663          /* we have got a match (i.e. expected frame received) ! */ 
     664           
     665          /* calculate the checksum of the received data */ 
     666 
     667          rxYieldChkSum = calculate_crc8(  (&(rxUART3[0])), (sizeof(yield_day_rsp)-2)); 
     668 
     669          if (rxYieldChkSum == rxUART3[17]) 
    665670          { 
    666  
    667  
    668               dayRxYield[currentChannel] = 
    669                 extractBinaryHexDigitString( &(rxUART3[0]), 13, 16 ); 
    670  
    671           } /* if */ 
     671            /* checksum is correct! */ 
     672 
     673            if (currentChannel <= 5) 
     674            { 
     675   
     676                /* convert and copy value */ 
     677                dayRxYield[currentChannel] = 
     678                  extractBinaryHexDigitString( &(rxUART3[0]), 13, 16 ); 
     679   
     680            } /* if */ 
     681            else 
     682            { 
     683              /* all channels done. nothing to do, we leave via SOL_QUERY_YIELD */ 
     684            } 
     685          } 
     686          else if (currentChannel <= 5) 
     687          { 
     688            /* valid channel index. but checksum is incorrect ! */ 
     689            dayRxYield[currentChannel] = 65535; /* invalid value */ 
     690          } 
    672691          else 
    673692          { 
    674             /* all channels done. nothing to do, we leave via SOL_QUERY_YIELD */ 
     693            /* checksum incorrect and channel index out of range. do nothing. */ 
    675694          } 
    676695 
     696          /* always move on to the next value... */ 
    677697 
    678698          currentChannel++; /* increment channel counter so we query the next channel in the next round */