TAIST class assignment

Dependencies:   mbed

Fork of TAIST_modbus by Supachai Vorapojpisut

Revision:
1:d2e8a3c822f1
Parent:
0:f306cb0263a6
--- a/modbus.cpp	Wed Mar 14 06:17:48 2018 +0000
+++ b/modbus.cpp	Wed Mar 14 14:55:52 2018 +0000
@@ -19,16 +19,16 @@
             tmpbuf[1] = buf[i*2 + 1]; 
             frame[i] = strtoul(tmpbuf, NULL, 16);
         }
+        //printf("frame[0] is %d, frame[1] is %d", frame[0], frame[1]);
         tmpbuf[0] = buf[12]; tmpbuf[1] = buf[13]; 
         lrc = strtoul(tmpbuf, NULL, 16);
         for (i = 0; i < 6; i++) {
             sum += frame[i];
         }
-        if ((sum + lrc) == 0) {
+        if ((sum + lrc) == 256) {
             status = 1;
         }
     }
-    
     return status;    
 }
 
@@ -86,9 +86,12 @@
             }
             break;
         case END:
-            if (ch == '\n') {
-                if (process_buffer(buf, frame)) {
-                    if ((frame[0] == nodeId) && (frame[1] == FUNC_CODE)) {
+            if (ch == '\n') 
+            {
+                if (process_buffer(buf, frame)) 
+                {
+                    if ((frame[0] == nodeId) && (frame[1] == FUNC_CODE)) 
+                    {
                         status = 1;
                     }
                 }
@@ -100,4 +103,4 @@
     }
     
     return status;
-}
+}
\ No newline at end of file