Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ModbusRTU-RS232 FoodComputerARM-alpha
Revision 1:35fdc7056f66, committed 2016-07-22
- 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
--- 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