Index: /webserver/example/EnergyMeters/Source/serial.c
===================================================================
--- /webserver/example/EnergyMeters/Source/serial.c (revision 37)
+++ /webserver/example/EnergyMeters/Source/serial.c (revision 72)
@@ -224,5 +224,5 @@
- unsigned int baud = 57600;
+ unsigned int baud = 2400;
unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud);
Index: /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
===================================================================
--- /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 71)
+++ /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 72)
@@ -929,5 +929,5 @@
{
- unsigned int baud = 57600;
+ unsigned int baud = 2400;
unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud);
@@ -1203,19 +1203,40 @@
)
{
+ unsigned char currentChar;
+ unsigned char conversionError = 0;
unsigned char x;
int resultValue = 0; /* initial value */
unsigned char round = 0; /* which digit? 0 = LSB */
- unsigned char currentCharValue;
+ int currentCharValue;
/* go through the bytes backwards (least significant to most significant) */
for (x = lastSrcByte; x >= firstSrcByte; x--)
{
-
- currentCharValue = (srcDataStart[x]) - 0x30;
+ currentChar = srcDataStart[x];
+ if ((currentChar < 0x30) || (currentChar > 0x46))
+ {
+ conversionError = 1;
+ }
+ else if (currentChar <= 0x39)
+ {
+ // 0x0 to 0x9
+ currentCharValue = (srcDataStart[x]) - 0x30;
+ }
+ else
+ {
+ // 0xA to 0xF
+ currentCharValue = 0xA + ((srcDataStart[x]) - 0x41);
+ }
resultValue = resultValue + (currentCharValue << (4 * round));
round++;
} /* for */
+
+ /* if a conversion error occurred, nullify the result */
+ if (conversionError == 1)
+ {
+ resultValue = 0xFFFF;
+ }
return resultValue;
Index: /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs
===================================================================
--- /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (revision 71)
+++ /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (revision 72)
@@ -21,4 +21,5 @@
+
@@ -40,8 +41,8 @@
+
+
+
-
-
-
@@ -55,19 +56,25 @@
-
+
+
+
+
-
+
+
+
-
+
-
-
+
+
-
+
+