- Timestamp:
- 10/17/10 18:13:03 (14 years ago)
- Files:
-
- webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (modified) (3 diffs)
- webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c (modified) (3 diffs)
- webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (modified) (4 diffs)
- webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs
r68 r70 14 14 </Memory3> 15 15 <Memory4> 16 <MemoryWindow autoEvaluate="0" addressText=" " numColumns="16" sizeText="" dataSize="1" radix="16" addressSpace="" />16 <MemoryWindow autoEvaluate="0" addressText="0x40005cc8" numColumns="16" sizeText="60" dataSize="1" radix="16" addressSpace="" /> 17 17 </Memory4> 18 18 <Project> 19 19 <ProjectSessionItem path="EnergyMetersEmbedded" name="unnamed" /> 20 20 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded" name="unnamed" /> 21 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;Demo Source" name="unnamed" /> 21 22 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;EnergyMeters" name="unnamed" /> 23 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;FreeRTOS.org Source" name="unnamed" /> 24 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;uIP Source" name="unnamed" /> 22 25 </Project> 23 26 <Register1> … … 39 42 <Watch1> 40 43 <Watches active="0" update="Three Seconds" > 41 <Watchpoint evalMode="2" linenumber="312" numelements="10" evalType="0" radix="16" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" />42 <Watchpoint evalMode="2" linenumber="72" numelements="10" evalType="0" radix="16" name="meterItems" expression="meterItems" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" />43 44 <Watchpoint linenumber="64" radix="-1" name="currentTime" expression="currentTime" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 44 45 <Watchpoint linenumber="547" radix="16" name="PINSEL0" expression="PINSEL0" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 46 <Watchpoint evalMode="2" linenumber="72" numelements="10" evalType="0" radix="16" name="meterItems" expression="meterItems" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 47 <Watchpoint evalMode="2" linenumber="312" numelements="10" evalType="0" radix="16" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 45 48 </Watches> 46 49 </Watch1> … … 55 58 <Watch4> 56 59 <Watches active="1" update="Twice a Second" > 57 <Watchpoint linenumber="948" radix="-1" name="carry" expression="carry" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 58 <Watchpoint evalMode="2" linenumber="111" numelements="11" evalType="0" radix="-1" name="meterItems" expression="meterItems" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/meters_isrs.c" /> 59 <Watchpoint linenumber="951" radix="-1" name="crcCHAR" expression="crcCHAR" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 60 <Watchpoint linenumber="381" radix="-1" name="cmpResult" expression="cmpResult" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 61 <Watchpoint linenumber="981" radix="-1" name="cmpValue" expression="cmpValue" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 62 <Watchpoint linenumber="940" radix="-1" name="crcLONG" expression="crcLONG" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 63 <Watchpoint linenumber="637" radix="-1" name="ch" expression="ch" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 64 <Watchpoint evalMode="2" linenumber="539" numelements="100" evalType="0" radix="-1" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 65 <Watchpoint linenumber="573" radix="-1" name="xLastSolarStateChangeTime" expression="xLastSolarStateChangeTime" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 66 <Watchpoint evalMode="2" linenumber="488" numelements="6" evalType="0" radix="10" name="chanWatt" expression="chanWatt" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 67 <Watchpoint evalMode="2" linenumber="485" numelements="6" evalType="0" radix="10" name="scDate" expression="scDate" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 68 <Watchpoint evalMode="2" linenumber="488" numelements="6" evalType="0" radix="11" name="chanVolt" expression="chanVolt" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 69 <Watchpoint evalMode="0" linenumber="396" evalType="1" radix="-1" name="uip_appdata" expression="uip_appdata" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/energymeters/arm7_lpc2368_rowley/webserver/httpd-cgi.c" /> 70 <Watchpoint linenumber="951" radix="-1" name="crcCHARinv" expression="crcCHARinv" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 71 <Watchpoint linenumber="109" radix="16" name="solarReadErrors" expression="solarReadErrors" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 72 <Watchpoint linenumber="969" radix="-1" name="staticCRC" expression="staticCRC" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 73 <Watchpoint linenumber="55" radix="16" name="solarState" expression="solarState" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 74 <Watchpoint evalMode="0" linenumber="428" evalType="0" radix="-1" name="init1" expression="init1" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 75 <Watchpoint linenumber="676" radix="-1" name="xLastTimeCheckTime" expression="xLastTimeCheckTime" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 76 <Watchpoint evalMode="0" linenumber="396" evalType="1" radix="-1" name="uip_appdata" expression="uip_appdata" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/energymeters/arm7_lpc2368_rowley/webserver/httpd-cgi.c" /> 60 <Watchpoint evalMode="2" linenumber="679" numelements="21" evalType="0" radix="-1" name="yield_day_rsp" expression="yield_day_rsp" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 61 <Watchpoint evalMode="2" linenumber="668" numelements="6" evalType="0" radix="16" name="dayRxYield" expression="dayRxYield" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 62 <Watchpoint evalMode="2" linenumber="669" numelements="100" evalType="0" radix="-1" name="rxUART3" expression="rxUART3" filename="d:/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 77 63 </Watches> 78 64 </Watch4> 79 65 <Files> 80 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\Philips_LPC230X_Startup.s" y="278" path="C:\Dokumente und Einstellungen\phil\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\Philips_LPC230X_Startup.s" left="0" selected="0" name="unnamed" top="261" /> 81 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\tasks.c" y="1133" path="D:\repo\webserver\example\EnergyMeters\Source\tasks.c" left="0" selected="0" name="unnamed" top="1105" /> 82 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd.c" y="9" path="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd.c" left="0" selected="0" name="unnamed" top="0" /> 83 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\LCD\portlcd.c" y="24" path="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\LCD\portlcd.c" left="0" selected="0" name="unnamed" top="9" /> 84 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\port.c" y="172" path="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\port.c" left="0" selected="0" name="unnamed" top="152" /> 85 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\MetersIncludes.h" y="0" path="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\MetersIncludes.h" left="0" selected="0" name="unnamed" top="21" /> 86 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\list.c" y="108" path="D:\repo\webserver\example\EnergyMeters\Source\list.c" left="0" selected="0" name="unnamed" top="89" /> 87 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\include\portable.h" y="105" path="D:\repo\webserver\example\EnergyMeters\Source\include\portable.h" left="0" selected="0" name="unnamed" top="89" /> 88 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portmacro.h" y="0" path="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portmacro.h" left="0" selected="0" name="unnamed" top="75" /> 66 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="40" debugPath="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" y="612" path="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" left="0" selected="1" name="unnamed" top="592" /> 67 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="29" debugPath="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\MetersIncludes.h" y="36" path="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\MetersIncludes.h" left="0" selected="0" name="unnamed" top="51" /> 89 68 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\main.c" y="115" path="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\main.c" left="0" selected="0" name="unnamed" top="99" /> 90 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" y="0" path="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" left="0" selected="0" name="unnamed" top="114" /> 91 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="29" debugPath="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" y="565" path="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" left="0" selected="1" name="unnamed" top="582" /> 92 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" y="216" path="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" left="0" selected="0" name="unnamed" top="26" /> 93 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\queue.c" y="132" path="D:\repo\webserver\example\EnergyMeters\Source\queue.c" left="0" selected="0" name="unnamed" top="132" /> 94 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\serial.c" y="226" path="D:\repo\webserver\example\EnergyMeters\Source\serial.c" left="0" selected="0" name="unnamed" top="210" /> 95 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\LPC230x.c" y="69" path="C:\Dokumente und Einstellungen\phil\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\LPC230x.c" left="0" selected="0" name="unnamed" top="53" /> 96 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\Meters_ISRs.c" y="12" path="D:\repo\webserver\example\EnergyMeters\Source\EnergyMeters\Meters_ISRs.c" left="0" selected="0" name="unnamed" top="0" /> 97 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\include\FreeRTOS.h" y="367" path="D:\repo\webserver\example\EnergyMeters\Source\include\FreeRTOS.h" left="0" selected="0" name="unnamed" top="353" /> 98 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\FreeRTOSConfig.h" y="81" path="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\FreeRTOSConfig.h" left="0" selected="0" name="unnamed" top="63" /> 69 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" y="216" path="D:\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" left="0" selected="0" name="unnamed" top="195" /> 70 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\queue.c" y="799" path="D:\repo\webserver\example\EnergyMeters\Source\queue.c" left="0" selected="0" name="unnamed" top="781" /> 71 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\repo\webserver\example\EnergyMeters\Source\tasks.c" y="1128" path="D:\repo\webserver\example\EnergyMeters\Source\tasks.c" left="0" selected="0" name="unnamed" top="1104" /> 72 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="21" debugPath="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" y="286" path="D:\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" left="0" selected="0" name="unnamed" top="278" /> 99 73 </Files> 100 <ARMCrossStudioWindow activeProject="EnergyMetersEmbedded" autoConnectTarget=" Macraigor Wiggler (20 Pin)" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388479" debugSearchPath="" buildConfiguration="ARM Flash Release" />74 <ARMCrossStudioWindow activeProject="EnergyMetersEmbedded" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388479" debugSearchPath="" buildConfiguration="ARM Flash Debug" /> 101 75 </session> webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/webserver/httpd-cgi.c
r69 r70 70 70 extern int solarReadCounter; 71 71 extern unsigned char scDate[6]; /* date received from solar count */ 72 73 74 75 extern int dayRxYield[NUMBER_OF_SOLAR_CHANNELS]; /* daily yield data */ 72 76 73 77 extern int resultValueRaw; /* last raw yield value */ … … 233 237 { 234 238 int i; 239 unsigned char k; 235 240 236 241 unsigned long long currentTime = getEpochTimeWithMs(); … … 280 285 } /* for */ 281 286 287 for (i = 0; i < NUMBER_OF_SOLAR_CHANNELS; i++) 288 { 289 sprintf( cCountBuf, "DAY %u %u\n", (int)i, dayRxYield[i] ); 290 strcat( uip_appdata, cCountBuf ); 291 } 292 293 strcat( uip_appdata, cCountBuf ); 282 294 283 295 webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h
r69 r70 2 2 void initMeterItems(void); 3 3 4 portCHAR checkRxOneByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned charCheckSumStartByte); 5 portCHAR checkRxTwoByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned charCheckSumStartByte ); 4 portCHAR checkRxOneByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned char CheckSumStartByte); 5 portCHAR checkRxTwoByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned char CheckSumStartByte ); 6 7 8 static unsigned char calculate_crc8(unsigned char * d_serdata_tuc, unsigned char nbytes); 6 9 7 10 int extractBinaryHexDigitString(unsigned char* srcDataStart, … … 12 15 13 16 unsigned long long getEpochTimeWithMs(void); 17 18 19 void send_yield_query_day(unsigned char channel /* 0 to 5 */, unsigned char day /* 1 to 31 */); 20 void send_yield_query_hour(unsigned char channel /* 0 to 5 */, unsigned char hour /* 0 to 23 */); 21 void send_yield_query_minute(unsigned char channel /* 0 to 5 */, unsigned char minute /* 0 to 59 */); 14 22 15 23 #define NUMBER_OF_METERS 6 /* the number of meters we use */ … … 24 32 25 33 #define METERS_INT_CHECK_INTERVAL_MS 100 /* how often (in ms) do we check if one of the I/O lines has triggered */ 34 35 36 #define NUMBER_OF_SOLAR_CHANNELS 6 /* number of solar channels */ 37 #define DAILY_RX_YIELD_LENGTH 9 /* length of the rx data */ 38 26 39 27 40 … … 50 63 extern int historyRemainTime; /* how many ticks have we left until the next history entry must be written? */ 51 64 65 /* bit values for calculate_crc8() */ 66 67 #define BIT0 (1U << 0) 68 #define BIT1 (1U << 1) 69 #define BIT2 (1U << 2) 70 #define BIT3 (1U << 3) 71 #define BIT4 (1U << 4) 72 #define BIT5 (1U << 5) 73 #define BIT6 (1U << 6) 74 #define BIT7 (1U << 7) 75 76 webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
r69 r70 103 103 104 104 105 int dayRxYield[NUMBER_OF_SOLAR_CHANNELS]; /* daily yield data */ 106 107 105 108 const unsigned char query_sc_time[] = "\x02\xB0\xF0\x03\x00\x04\xAB\xB9\x03"; // Zeit abfragen 106 109 const unsigned char query_sc_time_rsp[] = "\x02\xF0\xB0\x08\x00\x84\x00\x00\x00\x00\x00\x00\x00\x03"; // Zeit abfragen … … 120 123 //specification: unsigned char req_month_yield[] = "\x02\x31\x3c\x4d\x30\x31\x30\x30\x03"; // Frame for querying the yield. Will be filled in by solQueryYield() 121 124 122 // 02 31 3c 4d 30 30 30 30 30 31 fd 03 123 unsigned char req_month_yield[] = "\x02\x31\x3c\x4d\x30\x30\x30\x30\x30\x31\xfd\x03"; // Frame for querying the yield. Will be filled in by solQueryYield() 125 // 126 unsigned char req_month_yield[] = "\x02\x31\x3C\x6d\x30\x32\x30\x30\x30\x32\xff\x03"; // Frame for querying the monthly yield. Will be filled in by solQueryYield() 127 128 129 unsigned char req_minute_yield[] = "\x02\x31\x3C\x6D\x30\x32\x30\x30\x30\x32\x00\x03"; // Frame for querying the minutely yield. Will be filled in by solQueryYield() 130 const unsigned char yield_minute_rsp[] = "\x02\x31\x6D\x30\x31\x30\x30\x30\x32\x30\x30\x30\x30\x30\x32\x41\x44\xC8\x03\x03"; 131 const unsigned char yield_minute_r_m[] = "\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF"; 132 133 134 unsigned char req_day_yield[] = "\x02\x31\x3c\x44\x30\x32\x30\x30\x30\x32\x00\x03"; // Frame for querying the minutely yield. Will be filled in by solQueryYield() 135 const unsigned char yield_day_rsp[] = "\x02\x31\x44\x30\x31\x30\x30\x30\x32\x30\x30\x30\x30\x30\x32\x41\x44\xC8\x03\x03"; 136 const unsigned char yield_day_r_m[] = "\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF"; 137 138 139 unsigned char req_hour_yield[] = "\x02\x31\x3c\x68\x30\x32\x30\x30\x30\x32\x00\x03"; // Frame for querying the minutely yield. Will be filled in by solQueryYield() 140 const unsigned char yield_hour_rsp[] = "\x02\x31\x68\x30\x31\x30\x30\x30\x32\x30\x30\x30\x30\x30\x30\x30\x30\x30\x03\x03"; 141 const unsigned char yield_hour_r_m[] = "\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF"; 142 143 144 145 146 124 147 125 148 // tt (time) values: m=minute , h = hour, D = day, M = month (\x31), Y = year … … 129 152 // ad: unit address 130 153 // r1 to r7: result binary coded hex 131 // ad tt cc m1 m2 r1 r2 r3 r4 r5 r6 r7 ck 132 //specification: unsigned char yield_month_rsp[] = "\x02\x31\x4d\x30\x00\x00\x09\x0c\x04\x0a\x26\x86\xcd\x00\x03"; /* exp. query yield response. Will be filled in by solQueryYield() */ 133 //specification: unsigned char yield_month_r_m[] = "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff"; /* exp. query yield seq response mask. Will be filled in by solQueryYield() */ 134 135 // 02 31 4d 30 30 30 30 30 31 30 30 30 30 31 35 44 43 9a 03 03 136 // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 137 unsigned char yield_month_rsp[] = "\x02\x31\x4d\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03"; /* exp. query yield response. Will be filled in by solQueryYield() */ 138 unsigned char yield_month_r_m[] = "\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff"; /* exp. query yield seq response mask. Will be filled in by solQueryYield() */ 154 155 156 // 02 31 4d 30 30 30 30 30 31 30 30 30 30 31 35 44 43 157 // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 158 unsigned char yield_month_rsp[] = "\x02\x31\x4d\x33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03"; /* exp. query yield response. Will be filled in by solQueryYield() */ 159 unsigned char yield_month_r_m[] = "\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff"; /* exp. query yield seq response mask. Will be filled in by solQueryYield() */ 139 160 140 161 … … 229 250 { 230 251 int i; 252 int k; 253 231 254 xLastSolarStateChangeTime = xTaskGetTickCount(); 232 255 xLastTimeCheckTime = xTaskGetTickCount(); … … 243 266 244 267 /* do not invalidate history here so we do not lose all data */ 268 269 /* init daily rx yield array with 0 */ 270 for (i = 0; i < NUMBER_OF_SOLAR_CHANNELS; i++) 271 { 272 dayRxYield[i] = 0; 273 } /* for */ 245 274 246 275 … … 417 446 void solarFSM(void) 418 447 { 448 unsigned char i; 419 449 int cmpResult; 450 unsigned char power; /* variable for conversions */ 451 unsigned char checkDate; /* temp variable for day of month */ 420 452 421 453 … … 537 569 538 570 currentChannel = 0; /* start yield scan on channel 0 */ 539 solarState = SOL_QUERY_YIELD; / * change state: time response received, now init and query the channels */571 solarState = SOL_QUERY_YIELD; //xxxxxxx SOL_NO_INIT; //SOL_QUERY_YIELD; /* change state: time response received, now init and query the channels */ 540 572 } 541 573 else … … 552 584 /* first, fill in data for tx */ 553 585 // TODO 554 555 556 // req_month_yield[4] = 0x30 + 1; // channel 557 // req_month_yield[8] = 0x30 + 0; // month MSB (binary coded hex) 558 // req_month_yield[9] = 0x30 + 4; // month LSB (binary coded hex) 559 560 /* then, calculate the CRC for tx */ 561 (void)checkRxOneByteCheckSum(&(req_month_yield[0]), 1, 7, 8); 562 /* checksum now in calculatedCrc1Byte */ 563 564 565 // crc 566 //req_month_yield[7] = calculatedCrc1Byte; /* fill in checksum */ 567 568 resetUart3RxBuf(); 569 send_uart3((unsigned char *)req_month_yield, sizeof(req_month_yield)); 570 571 solarState = SOL_QUERY_YIELD_WAIT_REPLY; /* change state: now wait for response */ 586 587 588 if (currentChannel >= 6) 589 { 590 currentChannel = 0; 591 solarState = SOL_NO_INIT; /* we are done with all the channels. go ahead */ 592 } 593 else 594 { 595 /* query the next channel */ 596 597 checkDate = scDate[2]-1; /* we query the previous day */ 598 599 if (checkDate == 0) 600 { 601 /* first day of month */ 602 603 /* check new month */ 604 if (scDate[1] == 3) 605 { 606 /* looking for end of february? handle leap years */ 607 if ((scDate[0] % 4) == 0) 608 { 609 checkDate = 29; /* leap year */ 610 } 611 else 612 { 613 checkDate = 28; /* not a leap year */ 614 } 615 } 616 else if 617 ((scDate[1] == 1) || 618 (scDate[1] == 5) || 619 (scDate[1] == 7) || 620 (scDate[1] == 8) || 621 (scDate[1] == 10) || 622 (scDate[1] == 12)) 623 { 624 checkDate = 31; 625 } 626 else 627 { 628 checkDate = 30; 629 } 630 } 631 632 send_yield_query_day(/* channel: */ currentChannel, /* day: (yesterday) */ checkDate ); 633 xLastSolarStateChangeTime = xTaskGetTickCount(); 634 solarState = SOL_QUERY_YIELD_WAIT_REPLY; /* query next channel. change state: now wait for response */ 635 636 } 637 638 //send_yield_query_minute(/* channel: */ 1, /* minute: */ 40 ); 639 640 // hour is broken... ?! 641 //send_yield_query_hour(/* channel: */ 1, /* hour: */ 11 ); 642 643 572 644 573 645 break; /* end of case SOL_QUERY_YIELD */ … … 576 648 577 649 578 579 cmpResult = checkUart3Received(yield_month_rsp, yield_month_r_m, sizeof(yield_month_rsp)-1); 650 // cmpResult = checkUart3Received(yield_minute_rsp, yield_minute_r_m, sizeof(yield_minute_rsp)-1); 651 652 // the query for hour is broken... ?! 653 //cmpResult = checkUart3Received(yield_hour_rsp, yield_hour_r_m, sizeof(yield_hour_rsp)-1); 654 655 cmpResult = checkUart3Received(yield_day_rsp, yield_day_r_m, sizeof(yield_day_rsp)-1); 656 580 657 581 658 … … 584 661 { 585 662 /* we have got a match! */ 586 587 588 resultValueRaw = extractBinaryHexDigitString( &(rxUART3[0]), 589 9, /* first byte of binary hex string */ 590 16 /* last byte of binary hex string */ 591 ); 592 593 594 595 solarState = SOL_NO_INIT; /* go ahead */ 596 663 664 if (currentChannel <= 5) 665 { 666 667 668 dayRxYield[currentChannel] = 669 extractBinaryHexDigitString( &(rxUART3[0]), 13, 16 ); 670 671 } /* if */ 672 else 673 { 674 /* all channels done. nothing to do, we leave via SOL_QUERY_YIELD */ 675 } 676 677 678 currentChannel++; /* increment channel counter so we query the next channel in the next round */ 679 xLastSolarStateChangeTime = xTaskGetTickCount(); 680 solarState = SOL_QUERY_YIELD; /* go ahead */ 597 681 } 598 #if 0599 currentChannel++; /* next channel */600 601 if (currentChannel >= 6)602 {603 solarState = SOL_NO_INIT; /* change state: last channel done */604 } /* if */605 else606 {607 solarState = SOL_QUERY_YIELD; /* scan next channel */608 } /* else */609 #endif610 682 611 683 break; /* end of case SOL_QUERY_YIELD_WAIT_REPLY */ … … 1012 1084 1013 1085 1014 portCHAR checkRxOneByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned char CheckSumStartByte)1086 portCHAR checkRxOneByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned char CheckSumStartByte) 1015 1087 { 1016 1088 portCHAR retVal; /* return value */ … … 1020 1092 int x; 1021 1093 1022 unsigned long crcLONG = 0;1094 unsigned long crcLONG; 1023 1095 unsigned char crcCHAR; 1024 1096 unsigned char crcCHARinv; 1025 unsigned char carry = 0; 1097 unsigned char carry; 1098 1099 crcLONG = 0; 1100 crcCHAR = 0; 1101 crcCHARinv = 0; 1102 carry = 0; 1103 1026 1104 1027 1105 /* use bytes 1 to 13 for the checksum */ … … 1029 1107 { 1030 1108 1031 /* overflow? */1032 // if (((portSHORT)crc + (portSHORT)(dataStart[x])) > 0xFF)1033 // {1034 // carry++;1035 // }1036 1037 1109 crcLONG = (crcLONG + dataStart[x]); /* add and truncate to 8 bit */ 1038 1110 } … … 1040 1112 carry = (unsigned char)(((crcLONG & 0xFF00) >> 8)); 1041 1113 1042 crcCHAR = (unsigned char)(crcLONG & 0xFF); 1043 1044 crcCHAR = (unsigned char)(crcCHAR + carry); 1114 crcCHAR = ((unsigned char)crcLONG) + carry; 1045 1115 crcCHARinv = (unsigned char)(~crcCHAR); 1046 1116 … … 1048 1118 calculatedCrc1Byte = crcCHARinv; /* save calculated CRC (for use in case of checksum generation) */ 1049 1119 1050 if (crcCHARinv == dataStart[ charCheckSumStartByte])1120 if (crcCHARinv == dataStart[CheckSumStartByte]) 1051 1121 { 1052 1122 retVal = 1; /* checksum OK, data is valid */ … … 1060 1130 1061 1131 1062 portCHAR checkRxTwoByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned char CheckSumStartByte )1132 portCHAR checkRxTwoByteCheckSum(unsigned char* dataStart, unsigned char firstByte, unsigned char lastByte, unsigned char CheckSumStartByte ) 1063 1133 { 1064 1134 unsigned short cmpValue; … … 1077 1147 1078 1148 1079 cmpValue = ((((unsigned short)dataStart[ charCheckSumStartByte+1])<<8) | dataStart[charCheckSumStartByte]);1149 cmpValue = ((((unsigned short)dataStart[CheckSumStartByte+1])<<8) | dataStart[CheckSumStartByte]); 1080 1150 1081 1151 calculatedCrc2Byte = staticCRC; /* save calculated CRC (for use in case of checksum generation) */ … … 1132 1202 1133 1203 } /* extractBinaryHexDigitString() */ 1204 1205 1206 static unsigned char calculate_crc8(unsigned char * d_serdata_tuc, unsigned char nbytes) 1207 { 1208 unsigned char i; 1209 unsigned char j; 1210 unsigned char d_currbyte_tuc; 1211 unsigned char d_crc_tuc; 1212 1213 /* start with BISISTX and repeat the checksum calculation for all bytes until CHKS8 (excl.) */ 1214 d_crc_tuc = 0; // init the checksum 1215 1216 for( j = 1; j < (nbytes-2); j ++ ) 1217 { 1218 1219 d_currbyte_tuc = d_serdata_tuc[ j ]; 1220 1221 for( i = 8; i > 0; i -- ) 1222 { 1223 /* if current bit != 0 */ 1224 if (( (d_crc_tuc ^ d_currbyte_tuc) & BIT0 ) != 0) 1225 { 1226 d_crc_tuc ^= 0x18; 1227 d_crc_tuc >>= 1; 1228 d_crc_tuc |= BIT7; 1229 } 1230 else 1231 { 1232 d_crc_tuc >>= 1; 1233 } 1234 d_currbyte_tuc >>= 1; // prepare for next databit 1235 } /* for */ 1236 } // this byte is finished 1237 1238 /* checksum is complete now - result always ORed with 0x80 and then compare */ 1239 /* calculated and received checksum */ 1240 d_crc_tuc |= BIT7; 1241 return d_crc_tuc; 1242 } 1243 1244 1245 void send_yield_query_day(unsigned char channel /* 0 to 5 */, unsigned char day /* 1 to 31 */) 1246 { 1247 unsigned char newChkSum; 1248 1249 req_day_yield[5] = 0x30 + channel; // channel 1250 1251 1252 /* convert day to binary coded hex */ 1253 if (day > 15) 1254 { 1255 req_day_yield[8] = 0x31; /* hex MSB day is 1 */ 1256 day = day - 16; /* decrease day (is now remainder */ 1257 } 1258 else 1259 { 1260 req_day_yield[8] = 0x30; /* hex MSB day is 0 */ 1261 } 1262 req_day_yield[9] = 0x30 + day; /* hex LSB day */ 1263 1264 newChkSum = calculate_crc8( (&(req_day_yield[0])), (sizeof(req_day_yield)-1)); 1265 req_day_yield[10] = newChkSum; /* fill in checksum */ 1266 1267 resetUart3RxBuf(); 1268 send_uart3((unsigned char *)req_day_yield, sizeof(req_day_yield)); 1269 1270 } /* prepare_yield_query_day() */ 1271 1272 1273 void send_yield_query_hour(unsigned char channel /* 0 to 5 */, unsigned char hour /* 0 to 23 */) 1274 { 1275 1276 unsigned char newChkSum; 1277 unsigned char hourMSB; 1278 unsigned char hourLSB; 1279 1280 req_hour_yield[5] = 0x30 + channel; // channel 1281 1282 1283 hourMSB = hour % 16; 1284 hourLSB = hour - hourMSB; 1285 1286 req_hour_yield[8] = 0x30 + hourMSB; // minute MSB (binary coded hex) 1287 req_hour_yield[9] = 0x30 + hourLSB; // minute LSB (binary coded hex) 1288 1289 newChkSum = calculate_crc8( (&(req_hour_yield[0])), (sizeof(req_hour_yield)-1)); 1290 1291 // crc 1292 req_hour_yield[10] = newChkSum; /* fill in checksum */ 1293 1294 resetUart3RxBuf(); 1295 send_uart3((unsigned char *)req_hour_yield, sizeof(req_hour_yield)); 1296 1297 1298 1299 } /* prepare_yield_query_hour() */ 1300 1301 1302 void send_yield_query_minute(unsigned char channel /* 0 to 5 */, unsigned char minute /* 0 to 59 */) 1303 { 1304 unsigned char newChkSum; 1305 unsigned char minuteMSB; 1306 unsigned char minuteLSB; 1307 1308 req_minute_yield[5] = 0x30 + channel; // channel 1309 1310 1311 minuteMSB = minute % 16; 1312 minuteLSB = minute - minuteMSB; 1313 1314 req_minute_yield[6] = 0x30 + minuteMSB; // minute MSB (binary coded hex) 1315 req_minute_yield[7] = 0x30 + minuteLSB; // minute LSB (binary coded hex) 1316 1317 newChkSum = calculate_crc8( (&(req_minute_yield[0])), (sizeof(req_minute_yield)-1)); 1318 1319 // crc 1320 req_minute_yield[10] = newChkSum; /* fill in checksum */ 1321 1322 resetUart3RxBuf(); 1323 send_uart3((unsigned char *)req_minute_yield, sizeof(req_minute_yield)); 1324 1325 1326 } /* prepare_yield_query_minute() */