modified for NuMaker_PFM series

Dependents:   NuMaker-mbed-modbus-sample NuMaker_NuWicam_Lite NuMaker-mbed-modbus-sample

Fork of Modbus by Wayne Lin

Revision:
2:6ee56c002f64
Parent:
0:274eb57e1df3
Child:
3:419ee4c5e10f
--- a/mbrtu.cpp	Tue Aug 09 08:21:33 2016 +0000
+++ b/mbrtu.cpp	Thu Aug 18 08:24:37 2016 +0000
@@ -27,6 +27,7 @@
  *
  * File: $Id: mbrtu.c,v 1.18 2007/09/12 10:15:56 wolti Exp $
  */
+#include "mbed.h"
 
 /* ----------------------- System includes ----------------------------------*/
 #include "stdlib.h"
@@ -153,7 +154,14 @@
     eMBErrorCode    eStatus = MB_ENOERR;
 
     ENTER_CRITICAL_SECTION(  );
-    assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX );
+    //assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX ); //Wayne's workaround
+    if ( usRcvBufferPos >= MB_SER_PDU_SIZE_MAX )
+    {
+        //printf("usRcvBufferPos < MB_SER_PDU_SIZE_MAX - %d %d \r\n", usRcvBufferPos, MB_SER_PDU_SIZE_MAX );
+        eStatus = MB_EIO;
+        usRcvBufferPos = 0;
+        return eStatus;
+    }
         
     /* Length and CRC check */
     if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN )