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
Diff: ModbusSlave232.cpp
- Revision:
- 1:35fdc7056f66
- Parent:
- 0:6262fc7582a9
- Child:
- 2:5318159b5eab
--- 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