This library meant to allow mbed boards (tested on F401RE) to act as modbus slave. I don't own this work, I just made some simple modifications so that it runs on mbed. My modification were labeled with "afdhal". Summary: Modified modbus Arduino library for mbed. See readme for more details. Feel free to use it as you want. Special thanks to the original authors.

Dependents:   ModbusRTU-RS232 FoodComputerARM-alpha

Files at this revision

API Documentation at this revision

Comitter:
AfdhalAtiffTan
Date:
Fri Jul 22 09:44:55 2016 +0000
Parent:
0:6262fc7582a9
Child:
2:5318159b5eab
Commit message:
Added small comments.

Changed in this revision

ModbusSlave232.cpp Show annotated file Show diff for this revision Revisions of this file
ModbusSlave232.h Show annotated file Show diff for this revision Revisions of this file
readme.txt Show annotated file Show diff for this revision Revisions of this file
--- a/ModbusSlave232.cpp	Thu Jul 21 19:48:35 2016 +0000
+++ b/ModbusSlave232.cpp	Fri Jul 22 09:44:55 2016 +0000
@@ -1,4 +1,7 @@
 /* 		
+ Modified by Afdhal: arduino library so that it can be used on mbed.
+ 
+ Original message:
  Modbus over serial line - RTU Slave Arduino Sketch 
  
  By Juan Pablo Zometa : jpmzometa@gmail.com
@@ -48,6 +51,7 @@
 
 
 //#include "Arduino.h" //afdhal
+
 #include "millis.h"
 #include "MODSERIAL.h" //afdhal
 MODSERIAL pc(USBTX, USBRX); // tx, rx //afdhal
@@ -279,8 +283,8 @@
         int bytes_received = 0;
 
         /* FIXME: does Serial.available wait 1.5T or 3.5T before exiting the loop? */
-        //while (Serial.available()) { //afdhal
-        while (pc.readable()) { //afdhal
+        //while (Serial.available()) { 	//afdhal
+        while (pc.readable()) { 		//afdhal
                 received_string[bytes_received] = pc.getc(); //Serial.read(); //afdhal
                 //Serial.print(received_string[bytes_received], DEC);
                 bytes_received++;
@@ -536,7 +540,7 @@
 
 	
 	//Serial.begin(baud); //afdhal
-	pc.baud(baud);
+	pc.baud(baud); //afdhal
 
      switch (parity) {
         case 'e': // 8E1
@@ -650,7 +654,4 @@
                 break;                                
         }      
         
-}
-
-
-
+}
\ No newline at end of file
--- a/ModbusSlave232.h	Thu Jul 21 19:48:35 2016 +0000
+++ b/ModbusSlave232.h	Fri Jul 22 09:44:55 2016 +0000
@@ -50,7 +50,7 @@
 	
 private:
   unsigned char slave;
-  //char txenpin;
+  //char txenpin; //afdhal
 
   unsigned int crc(unsigned char *buf, unsigned char start, unsigned char cnt);
   void build_read_packet(unsigned char function, unsigned char count, unsigned char *packet);
--- a/readme.txt	Thu Jul 21 19:48:35 2016 +0000
+++ b/readme.txt	Fri Jul 22 09:44:55 2016 +0000
@@ -1,7 +1,7 @@
 I found this modbus arduino library from:
 https://www.cooking-hacks.com/documentation/tutorials/modbus-module-shield-tutorial-for-arduino-raspberry-pi-intel-galileo/
 
-Then, I modify the library so that it is compatible with my mbed enabled Nucleo F401RE by using MODSERIAL:
+Then, I made a small modification to the library so that it is compatible with my mbed enabled Nucleo F401RE by using MODSERIAL:
 https://developer.mbed.org/users/Sissors/code/MODSERIAL/
 
 and Millis library:
@@ -15,4 +15,6 @@
 Andy Kirkham 
 Erik Olieman
 Lee Yaping
-and all others that I missed
\ No newline at end of file
+and all others that I missed
+
+Feel free to use it as you like. ;)
\ No newline at end of file