Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 Master read/write Hreg #13

Open
wants to merge 323 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
323 commits
Select commit Hold shift + click to select a range
6ecb4ae
Stability fixes
emelianov Jun 19, 2018
5671c35
Switch to std::vector
emelianov Jun 19, 2018
a20223d
Documentation changes
emelianov Jun 20, 2018
6436f96
ModbusIP header cleanup
emelianov Jun 20, 2018
388e441
Set zerro base for remote registers addressing
emelianov Jun 20, 2018
201cbef
adsReg fix
emelianov Jun 21, 2018
fa8e15d
Documentation fixes
emelianov Jun 21, 2018
b80b8ad
Documentation changes
emelianov Jun 21, 2018
df06680
Modbus Master implementation
emelianov Jun 21, 2018
7d41657
Mistype correction
emelianov Jun 21, 2018
499c235
Mistype correction
emelianov Jun 21, 2018
b6b6f36
Update README.md
emelianov Jun 21, 2018
4120aff
Wrong bit-array processing fix (get/setMultipleBits)
emelianov Jun 21, 2018
e067c66
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Jun 22, 2018
3395334
Global regs definition
emelianov Jul 12, 2018
33a92ac
Comments and address expansion core types
emelianov Jul 12, 2018
b44974d
Add TAddress +/++/+= overloads
emelianov Jul 13, 2018
1fb57ba
Expand register addressing to 0..65535
emelianov Jul 13, 2018
b4fe581
Experimental: ModbusSerial (slave)
emelianov Jul 13, 2018
382c0e2
Examples: Callback removed changes made by exident
emelianov Jul 13, 2018
22ffd6e
Experimental: ModbusSerial (slave)
emelianov Jul 16, 2018
abc75a9
Add destructors for Modbus and TTransaction
emelianov Jul 23, 2018
863bf3d
Bugfix and API change and expansion
emelianov Sep 6, 2018
c949444
Remove ModbusSerial.*
emelianov Sep 6, 2018
6b604d6
Implement remote slave read/wirte for all register's types
emelianov Sep 7, 2018
7f6d72c
Remove ModbusSerial.*
emelianov Sep 7, 2018
4f25bf3
Add multiple registers fix, API change (pull/push regs)
emelianov Sep 10, 2018
3ce4da6
ESP32 compile error fix
emelianov Sep 10, 2018
ae7cf36
push\pull code cleanup after last API changes
emelianov Sep 11, 2018
bed2be8
Implement pullHregToIreg, pullCoilToIsts, pushIstsToCoil, pushIregToHreg
emelianov Sep 11, 2018
c847929
Optimize std::vector processing
emelianov Sep 11, 2018
52f6775
Extend removeCoil/Hreg/... to remove multiple registers
emelianov Sep 11, 2018
fbc03dd
Add methods
emelianov Sep 11, 2018
f571171
Quick fix for new API
emelianov Sep 30, 2018
d1a51ae
Callback API extended to support multiple handlers for event
emelianov Oct 1, 2018
a7fac3a
Update Master.ino
PeterEmbedded Oct 2, 2018
1bac4ff
Update AnalogInput.ino
PeterEmbedded Oct 2, 2018
aef3e45
Merge pull request #6 from PeterEmbedded/patch-2
emelianov Oct 3, 2018
e2b49a6
Merge pull request #5 from PeterEmbedded/patch-1
emelianov Oct 3, 2018
fa7c273
Mistype fix
emelianov Oct 3, 2018
86e74c7
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Oct 3, 2018
59f4a02
Finishing with multiple callbacks on event
emelianov Oct 3, 2018
83eefda
Add HReg read example
emelianov Oct 5, 2018
50c8e3a
Wrong byte order in read/writeHreg, read/writeIreg fixed
emelianov Oct 17, 2018
d3227fc
Static client's array
emelianov Oct 22, 2018
7c2e57a
add Modbus Unit parameter to master calls
emelianov Nov 9, 2018
9a0044e
Add Modbus unit parameter to read/write/pull/push. Remove responce wa…
emelianov Jan 6, 2019
a875376
Add autoConnect for read/write/pull/push
emelianov Jan 6, 2019
8326ade
Add autoConnect for read/write/pull/push
emelianov Jan 6, 2019
00d4cab
Merge remote-tracking branch 'origin/alternate'
Jan 11, 2019
0a877cd
2.0
emelianov Jan 11, 2019
a691ae9
Change comments
emelianov Jan 11, 2019
da61893
Docs changes
emelianov Jan 11, 2019
c0394b5
Fix examples
emelianov Jan 11, 2019
1368f41
Fix crash on disconnect (with 2.5.x)
emelianov Jan 19, 2019
522012e
Fix readCoil/Hreg/Ists/Ireg
emelianov Jan 25, 2019
e5c7341
2.0.1
emelianov Jan 25, 2019
f601525
Fix master write multile Hregs/Coils. Change TCP flushing
emelianov Feb 2, 2019
56754f5
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Feb 2, 2019
e909c88
Disconnect initial implementation
emelianov Feb 2, 2019
20a78c5
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Feb 2, 2019
604d170
2.1 BETA
emelianov Feb 3, 2019
a09c4ce
dropTransaction()/clean() refactoring
emelianov Feb 4, 2019
b9079e6
Fix writeMiltipleBits for array
emelianov Feb 4, 2019
fa75989
Update examples
emelianov Feb 4, 2019
a0e2ef8
Limit incoming connections to one per IP
emelianov Feb 4, 2019
3b1cbe2
Switch to leonardo/mega
emelianov Feb 15, 2019
1514c9b
Comments added
emelianov Mar 20, 2019
9cadf5d
Remove useless ->stop() lines
emelianov May 13, 2019
6f4b2e8
ModbusRTU slave initial draft
emelianov May 15, 2019
8c9be05
Update doc
emelianov May 17, 2019
0434de9
ModbusRTU task() refactoring
emelianov May 19, 2019
b831d96
Merge slave and master to ModbusRTU
emelianov May 20, 2019
c124733
Move CRC table to PROGMEM
emelianov May 20, 2019
45b6bc6
Move crc routine inside ModbusRTU class, test Master methods added, t…
emelianov May 20, 2019
b516b71
Master readCoil tested
emelianov May 20, 2019
5ca5e30
Switch to templates, add HardwareSerial support
emelianov May 21, 2019
176560a
Add rest of master methods
emelianov May 21, 2019
6d72132
Add ModbusRTU examples
emelianov May 21, 2019
9d4e89d
Fix mistype
emelianov May 21, 2019
28b477c
Extract write to rawSend() routine. Use internal TX enable control fo…
emelianov May 21, 2019
cc71d82
Fix count of processing regs/coils/etc according to Modbus Spacification
emelianov May 21, 2019
bcb97b5
Fix read/pullCoils/Ists number limitation. Cleanup.
emelianov May 21, 2019
ee37310
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov May 21, 2019
3ae9d12
Fix rawSend()
emelianov May 22, 2019
1b3dcd4
Revert to no-template
emelianov May 23, 2019
def5cf3
ReadMe update
emelianov May 23, 2019
98e4cd3
Update RTU examples
emelianov May 23, 2019
470d75d
Remove SoftwareSerial for ESP32
emelianov May 23, 2019
bc33337
API documentation update
emelianov May 23, 2019
254495c
Update README.md
emelianov May 23, 2019
88f9d0d
Update README.md
emelianov May 23, 2019
acdd0cd
Update README.md
emelianov May 23, 2019
0a8c57d
Allow use just begin(&Serial1) on already initialized port
emelianov May 24, 2019
0192e53
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov May 24, 2019
caae81b
Update serial init in examples
emelianov May 26, 2019
767bed1
Generalize eventSource() and implement it for RTU.
emelianov May 29, 2019
b2ff7d1
Generalize eventSource() and implement it for RTU.
emelianov May 29, 2019
184c246
sendRaw(): Move delyay() after txPin LOW
emelianov May 29, 2019
d4fcd12
Change .begin() API call
emelianov May 30, 2019
628b4ba
Notes added
emelianov May 30, 2019
bd14f46
Use correct field separator in keywords.txt
per1234 May 30, 2019
b49c9a6
Merge pull request #16 from per1234/keywords-separator
emelianov May 31, 2019
36ac832
Text update
emelianov Jun 6, 2019
7b5fda9
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Jun 6, 2019
1c5eced
Replace magin number for buffer size
emelianov Jul 5, 2019
3ae7f9e
Allow to change TCP port for master/slave
emelianov Jul 8, 2019
b38a946
Include byteswap.h only for ESP32
emelianov Sep 3, 2019
1099bca
Fix cleanup() crash. Thanks to Darius. Fix task() crash on wrong packet.
emelianov Sep 5, 2019
accc431
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Sep 5, 2019
3fd2be8
task() error processing fixes
emelianov Sep 6, 2019
34e2386
task() cleanup
emelianov Sep 6, 2019
51c09d4
Misc
emelianov Sep 6, 2019
3417582
task(): Dramaticly increase data exchange rate
emelianov Sep 6, 2019
0bfb9da
ESP32-related build fixes
emelianov Oct 14, 2019
5820a06
ModbusIP task(): Limit execution time & fix possible deadlock
emelianov Oct 15, 2019
6daf1cc
Fix write multiple Hregs. Refactor internal *MultipleWords()
emelianov Nov 25, 2019
24f3446
Fix crash on no callback function on read\write remote. Thanks to Kru…
emelianov Dec 2, 2019
8051f00
Write Coil(s)/Hreg(s) tests added
emelianov Dec 2, 2019
f8677ae
Read Coils/Hregs/Iregs/Istss tests added
emelianov Dec 3, 2019
caaa3ad
3.0.0
emelianov Dec 5, 2019
9b8ddf2
ESP32: Add critical section to escape possible timouts
emelianov Mar 16, 2020
1a142ea
TAddress != operator added
emelianov May 17, 2020
c177eed
Support non ESP devices (#40)
brainelectronics May 17, 2020
f19f7d9
ModburRTU: setBaudrate() rewrite
emelianov May 18, 2020
696b6f7
Add incoming packet output to serial for debug
emelianov Jun 8, 2020
b4b6b2d
README update
emelianov Jun 8, 2020
00e6e0c
README update
emelianov Jun 8, 2020
b026296
Remove code duplication in masterPDU
emelianov Jun 14, 2020
95b26c8
ModbusIP: master/slave => client/server
emelianov Jun 17, 2020
e735a3b
ReadMe update
emelianov Jun 17, 2020
615b401
ModbusRTU: ESP32 possible recive fix
emelianov Jun 18, 2020
82c23e1
ESP32: Drop mutex in task as it were resulting stability problems
emelianov Jun 25, 2020
69597f4
ModbusRTU task(): reduce timeout possibility due to rare task() calls
emelianov Jul 3, 2020
c2c3eee
ModbusIP task(): reduce timeout possibility due to rare task() calls
emelianov Jul 3, 2020
b760f74
Put back global registers removed by mistake
emelianov Jul 3, 2020
b52b1ec
3.0.1
emelianov Jul 13, 2020
34e4e73
Update README.md
emelianov Jul 15, 2020
d524a53
ModbusTCP Client: ESP32 fix unexpected transaction timeout
emelianov Aug 16, 2020
79a9690
Merge branch '3.0.1'
emelianov Aug 16, 2020
038efd0
Merge branch 'master' of https://github.com/emelianov/modbus-esp8266
emelianov Aug 16, 2020
9dd7379
4.0.0.DEVEL
emelianov Aug 17, 2020
609164e
Add Modbus read/write file block support
emelianov Aug 17, 2020
68ea8c4
W5x00 Ethernet support (not tested)
emelianov Aug 18, 2020
dbd1f70
no-STL build support (not completly tested)
emelianov Aug 20, 2020
e7c1299
Modbus/TCP Security implemantation and API funcs
emelianov Aug 28, 2020
cd31f7b
ModbusRTU: Add inverse logic support for transmit control
emelianov Sep 4, 2020
526b974
Add request callback
emelianov Oct 1, 2020
6905a0e
ModbusRTU class slight refactoring
emelianov Oct 3, 2020
544562e
Cleanup code style
emelianov Oct 6, 2020
9520b2d
Cleanup code style and fix bugs
emelianov Oct 10, 2020
70ca04f
W5x00 @ESP8266
emelianov Oct 12, 2020
0895bb8
API extension
emelianov Oct 12, 2020
54d2887
Fixed compatibility with Ethernet library
emelianov Oct 13, 2020
1d8541a
ModbusRTU stability improvment
emelianov Oct 25, 2020
d5f3444
Critical fixes
emelianov Oct 26, 2020
dc53a69
Fixes
emelianov Oct 27, 2020
8504e01
ModbusRTU: Fix possible data loss and slight .task() optimezation
emelianov Oct 27, 2020
c145238
Fix bridge example
emelianov Oct 29, 2020
980cbb4
Fix bridge example
emelianov Oct 29, 2020
4bad435
ModbusRTU: Fix packet loss after sending attempt on busy bus
emelianov Oct 29, 2020
fca1dbc
ModbusRTU: Fix packet loss after sending attempt on busy bus
emelianov Oct 29, 2020
e247944
ModbusTCP: Free buffers after request have sent
emelianov Oct 29, 2020
cd2d9e4
Rewrite all callbacks to be std::function
emelianov Nov 8, 2020
f3f0567
3.0.4
emelianov Nov 8, 2020
499c230
Fixed wrong onRequest/onRequestSuccess location
emelianov Nov 13, 2020
ac78bff
ModbusRTU Stability fixes
emelianov Nov 29, 2020
7273f82
Server: Fix callback called twice on register read
emelianov Dec 5, 2020
5f1feef
Port changes from 3.0.6
emelianov Dec 6, 2020
ba4ecac
W5x00: Support for ESP32, Client example
emelianov Dec 11, 2020
c3048ec
4.0.0 Development release
emelianov Dec 11, 2020
452a368
Create README.md
emelianov Dec 11, 2020
644f727
Fix __bswap_16 rename
emelianov Dec 11, 2020
91f88c4
ESP32: Correct task switch blocking.
emelianov Dec 16, 2020
ce75293
ESP32 RTU-Concurent Example: Change Binary to Mutex
emelianov Dec 16, 2020
2e16b36
ModbusTCP Client: Fix persistent connection error in some situations
emelianov Dec 27, 2020
096fab3
Full Bridge helping changes (stage #1)
emelianov Jan 6, 2021
83e8fd5
Fix add register on pull. Fix TLS.
emelianov Feb 12, 2021
b018f8a
Move Adruino Due to STL
emelianov Feb 13, 2021
400309f
Merge branch 'master' of github.com:emelianov/modbus-esp8266
emelianov Feb 13, 2021
6ced153
Temprary disable Arduino Due STL due to PlatformIO incompatibility
emelianov Feb 13, 2021
c65b059
Fix compile error issue #112
emelianov Mar 25, 2021
89f9a5e
Add EX_SLAVE_FAILURE on multiplr registers write error
emelianov Apr 13, 2021
18a9bf5
Change on request callback API
emelianov Jun 9, 2021
735f020
Fix Esp32 crash and master broadcast ID failure
TienHuyIoT Jun 27, 2021
8bd7840
Fix memory leak on broadcast with transactional callback
emelianov Jul 3, 2021
0251110
Fix ESP32 RTU
emelianov Jul 18, 2021
b82a733
Merge branch 'master' of github.com:emelianov/modbus-esp8266
emelianov Jul 18, 2021
803e762
FC_READWRITE_REGS implementation
emelianov Jul 19, 2021
e100eef
Slave core refactoring
emelianov Jul 21, 2021
6066bbf
Fix links in README.md (#137)
escherstair Jul 30, 2021
ecd3167
Delete ModbusRTU.cpp
emelianov Aug 1, 2021
4d49276
Documentation changes
emelianov Aug 1, 2021
99ba73f
Revert ModbusRTU.cpp
emelianov Aug 1, 2021
4558b58
ESP32-Concurent.ino Modifications (#132)
TienHuyIoT Aug 1, 2021
8fc1066
Documentation update
emelianov Aug 3, 2021
b6b765d
Update README.md
emelianov Aug 3, 2021
1bcd3b3
Prapare for release
emelianov Aug 4, 2021
4bd4136
Documentation fix
emelianov Aug 4, 2021
f7c1fa3
Fix broken link and typo in example/RTU/Readme (#138)
emerout Aug 5, 2021
fe5d4a8
Create FUNDING.yml
emelianov Aug 16, 2021
f14d0e2
Finalize FW-Update example
emelianov Aug 17, 2021
f9c9942
ESP32: Removed taskENTER_CRITICAL and vTaskSuspendAll()
emelianov Sep 30, 2021
4a4456e
ESP32: Removed taskENTER_CRITICAL and vTaskSuspendAll()
emelianov Oct 2, 2021
68409fe
fix warning (#161)
vondraussen Oct 29, 2021
5187564
4.0.0
emelianov Nov 2, 2021
e48d76c
Fix pushCoil and pushIstsToCoil (#162)
emelianov Nov 4, 2021
0cef4f5
Millis to Micros in RTU (#170)
gonzabrusco Jan 4, 2022
375a006
Fix example mistype
emelianov Jan 4, 2022
c2dfbbf
Merge branch 'master' of github.com:emelianov/modbus-esp8266
emelianov Jan 4, 2022
0ae379f
4.1.0.DEV (#174)
emelianov Jan 4, 2022
e71a4ac
Raw callback (#175)
emelianov Jan 4, 2022
a19f589
Merge branch 'master' of github.com:emelianov/modbus-esp8266
emelianov Jan 4, 2022
6cd22d0
Fix merge defects
emelianov Jan 5, 2022
4c55818
'-' => '_' in filenames
emelianov Jan 12, 2022
dfb1ce8
Minor changes:
emelianov Mar 8, 2022
9b859db
Add Multipe ID response example
emelianov Mar 8, 2022
7a213b3
_ to - in examples
emelianov Mar 8, 2022
8ee8935
4.1.0-RC1
emelianov Mar 11, 2022
7b4b42a
Correct indentation (#190)
mako777 Mar 13, 2022
861f0d9
ModbusTCP: Fix Raw callback processing
emelianov Mar 27, 2022
b7aeef0
ModbusTCP to ModbusRTU example added
emelianov Apr 10, 2022
6600ea5
4.1.0 release
emelianov Apr 17, 2022
2f14138
Memory leak, examples and API fixes
emelianov May 9, 2022
69f3d07
Replace magic number with constants
emelianov May 22, 2022
e80ecf5
Update ESP32-Concurent.ino (#217)
alepiva Jun 25, 2022
b9c5a25
Fix typo (#218)
Jun 28, 2022
6d98023
Fix typo (#219)
Jun 28, 2022
336d56c
ModbusEthernet: Portenta and ESP32 boards build fix
emelianov Jun 30, 2022
dc1a79a
TCP-to-RTU example: Fix cbTcpRaw
emelianov Jul 22, 2022
e0aa79b
TCP-to-RTU example: Fix timeout processing
emelianov Jul 23, 2022
b79129f
Minor grammar / typos (#249)
alexbarcelo Oct 12, 2022
d79deb2
Respond EX_ILLEGAL_ADDRESS on non-existent reg
emelianov Jan 1, 2023
2996663
README update
emelianov Jan 3, 2023
4383e1a
Fix deadlinks in example docs #272 (#275)
rob040 Mar 31, 2023
644c324
Fix Slave answer with malformed packet #268
emelianov Apr 1, 2023
4ae0f7d
STM32 Ethernet and simular workaround #278
emelianov Apr 1, 2023
0bc538d
txPin to txEnablePin, direct to txEnableDirect #266
emelianov Apr 1, 2023
ea2bd0e
Uncomment the explicit stop() method call to allow sockets cleanups (…
emelianov Apr 3, 2023
df666c6
Fixed error: modbus-esp8266/src/Modbus.cpp:318:25: error: comparison …
ArekKubacki Oct 14, 2023
5d7fe2d
RTU: Add _onRequest on illegal function
emelianov Oct 29, 2023
1489bcb
Merge branch 'master' of github.com:emelianov/modbus-esp8266
emelianov Oct 29, 2023
16a4094
chore: correct comment in modbus client example (#342)
basisbit May 2, 2024
304912a
correction of TCP debug (#326)
alepiva May 2, 2024
2eb5abe
- Added const (#313)
lmartorella May 2, 2024
ad1c39f
- Allow to change MODBUSRTU_TIMEOUT from project (#315)
lmartorella May 2, 2024
0cedf6a
Merge branch 'master' of github.com:emelianov/modbus-esp8266
emelianov May 4, 2024
500dbba
onGetRemove/onSetRemove fix
emelianov May 11, 2024
a5872af
begin with re/de warning fix
emelianov May 11, 2024
73f1911
Update TCP-to-RTU-Simulator.ino (#361)
smilexs4 Oct 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://paypal.me/modbus?locale.x=en_US
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode/arduino.json
.vscode/c_cpp_properties.json
.vscode/*
src/ModbusSerial.cpp
src/ModbusSerial.h
Empty file removed .gitmodules
Empty file.
1 change: 1 addition & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Moved to [documentation](documentation)
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(COMPONENT_ADD_INCLUDEDIRS src)
set(COMPONENT_SRCS "src/Modbus.cpp" "src/ModbusRTU.cpp")
set(COMPONENT_PRIV_REQUIRES arduino)
register_component()


2 changes: 2 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Copyright (c) 2015, Andr� Sarmento Barbosa
2017, Alexander Emelianov ([email protected])
All rights reserved.


Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Expand Down
201 changes: 129 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,129 @@
Modbus Library for ESP8266
==========================

This library allows your ESP8266 to communicate via Modbus protocol. The Modbus is a master-slave protocol
used in industrial automation and can be used in other areas, such as home automation.

The Modbus generally uses serial RS-232 or RS-485 as physical layer (then called Modbus Serial) and TCP/IP via Ethernet or WiFi (Modbus IP).

In the current version the library allows the ESP8266 operate as a slave, supporting Modbus IP via wireless network. For more information about Modbus see:

http://pt.wikipedia.org/wiki/Modbus http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf

Features
========

<ul>
<li>Operates as a slave</li>
<li>Supports Modbus IP (TCP, not keep-alive)</li>
<li>Reply exception messages for all supported functions</li>
<li>Modbus functions supported:</li>
<ul>
<li>0x01 - Read Coils</li>
<li>0x02 - Read Input Status (Read Discrete Inputs)</li>
<li>0x03 - Read Holding Registers</li>
<li>0x04 - Read Input Registers</li>
<li>0x05 - Write Single Coil</li>
<li>0x06 - Write Single Register</li>
<li>0x0F - Write Multiple Coils</li>
<li>0x10 - Write Multiple Registers</li>
</ul>
</ul>

<b>Notes:</b>

1. When using Modbus IP the transport protocol is TCP (port 502) and the connection is terminated to each transmitted message, that is, is not a keep-alive type connection.

2. The offsets for registers are 0-based. So be careful when setting your supervisory system or your testing software. For example, in ScadaBR (http://www.scadabr.com.br)
offsets are 0-based, then, a register configured as 100 in the library is set to 100 in ScadaBR. On the other hand, in the CAS Modbus Scanner
(http://www.chipkin.com/products/software/modbus-software/cas-modbus-scanner/) offsets are 1-based, so a register configured as 100 in library should be 101 in this software.

3. Early in the library Modbus.h file there is an option to limit the operation
to the functions of Holding Registers, saving space in the program memory.
Just comment out the following line:

```
#define USE_HOLDING_REGISTERS_ONLY
```
Thus, only the following functions are supported:
<ul>
<li>0x03 - Read Holding Registers</li>
<li>0x06 - Write Single Register</li>
<li>0x10 - Write Multiple Registers</li>
</ul>


How to
======

```
This README is under development, for now, see the examples of the library.
```

Contributions
=============
http://github.com/andresarmento/modbus-esp8266<br>
prof (at) andresarmento (dot) com

License
=======
The code in this repo is licensed under the BSD New License. See LICENSE.txt for more info.

# Modbus Library for Arduino
### ModbusRTU, ModbusTCP and ModbusTCP Security

For detailes on the library usage visit [documentation](documentation) section.

## Features

* Supports all Arduino platforms
* Operates in any combination of multiple instances of
* [Modbus RTU server](examples/RTU)
* [Modbus RTU client](examples/RTU)
* Modbus TCP server for [ESP8266/ESP32](examples/TCP-ESP) and [Ethernet library](examples/TCP-Ethernet)
* Modbus TCP client for [ESP8266/ESP32](examples/TCP-ESP) and [Ethernet library](examples/TCP-Ethernet)
* [MODBUS/TCP Security server (ESP8266)](examples/TLS)
* [MODBUS/TCP Security client (ESP8266/ESP32)](examples/TLS)
* Modbus functions supported:
* 0x01 - Read Coils
* 0x02 - Read Input Status (Read Discrete Inputs)
* 0x03 - Read Holding Registers
* 0x04 - Read Input Registers
* 0x05 - Write Single Coil
* 0x06 - Write Single Register
* 0x0F - Write Multiple Coils
* 0x10 - Write Multiple Registers
* 0x14 - Read File Record
* 0x15 - Write File Record
* 0x16 - Mask Write Register
* 0x17 - Read/Write multiple registers
* [Callbacks](examples/Callback) driven design
* Real life complex examples:
* [ESP8266/ESP32 firmware update over Modbus](examples/Files)
* [ModbusRTU to ModbusTCP bridge](examples/Bridge)

## Notes

1. The offsets for registers are 0-based. So be careful when setting your supervisory system or your testing software. For example, in [ScadaBR](http://www.scadabr.com.br) offsets are 0-based, then, a register configured as 100 in the library is set to 100 in ScadaBR. On the other hand, in the [CAS Modbus Scanner](http://www.chipkin.com/products/software/modbus-software/cas-modbus-scanner/) offsets are 1-based, so a register configured as 100 in library should be 101 in this software.
2. RS-485 transivers based on MAX-485 is working on at least up to 115200. XY-017/XY-485 working only up to 9600 for some reason.

For more information about Modbus see:

* [Modbus (From Wikipedia, the free encyclopedia)](http://pt.wikipedia.org/wiki/Modbus)
* [MODBUS APPLICATION PROTOCOL SPECIFICATION V1.1b3](https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf)
* [MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b](http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf)
* [MODBUS over Serial Line Specification and Implementation Guide V1.02](http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
* [MODBUS/TCP Security Protocol Specification](https://modbus.org/docs/MB-TCP-Security-v21_2018-07-24.pdf)

## Last Changes

```diff
// 4.1.1
+ Protocol: Fix wrong error code responce on non-existent register
+ ModbusTCP: Fix potential memory leak
+ API: cbEnable/cbDisable functionality extended
+ ESP-IDF: CMakeList.txt added
+ Examples: TCP-to-RTU fixed
// 4.1.0
+ API: Raw Modbus frame processing functionality
+ ModbusRTU: Precise inter-frame interval control
+ Examples: True ModbusRTU to ModbusTCP Server bridge
+ Examples: ModbusRTU respond to multiple ID from single device
+ ModbusRTU: Add direction control pin for Stream
+ STL: Add Reg count limitation to vector limit of 4000 (for ESP8266 and ESP32)
+ Settings: Added MODBUSIP_CONNECTION_TIMEOUT (ESP32 only)
+ Settings: Set MODBUSIP_MAX_CLIENTS = 8 for ESP32
+ ModbusTCP: Make using DNS names optional feature
+ ModbusRTU: Add separate RE/DE pins control optional feature
+ API: Drop support of Ethernet library v1
+ Examples: Teknic ClearCore ArduinoWrapper examples added
+ Examples: ModbusTCP to ModbusRTU example added
+ ModbusRTU: Flush extra delay optional feature
// 4.0.0
+ Support of all Arduino boards
+ ModbusTLS: ESP8266 Client/Server and ESP32 Client
+ ModbusTCP: ModbusEthernet - WizNet W5x00, ENC28J60 Ethernet library support
+ 0x14 - Read File Records function
+ 0x15 - Write File Records function
+ Examples: FW update over Modbus fullfunctional example
+ 0x16 - Write Mask Register function+ Test: 0x16
+ 0x17 - Read/Write Registers function
+ ModbusRTU: ESP32 SoftwareSerial support
+ Build with no STL dependency (switchable)
+ API: ModbusIP => ModbusTCP
+ API: Access control callback for individual Modbus function
+ API: Master/Slave => Client/Server according to [PRESS RELEASE](https://modbus.org/docs/Client-ServerPR-07-2020-final.docx.pdf)
+ Lot of code refacting and small fixes
```

## Roadmap

```diff
// 4.2.0
- API: Alternative CRC calulation (reduced memory footprint)
- ModbusRTU: Static buffer allocation
- Test: Frame accuracy to specefication
- Buffer/packet size limitation support
- Slave/Server: slavePDU use early exit by return where possible
- Master/Client: Check frame size against header data where possible
- Master/Client: Additional responce data validation
- Free global registers and callbacks on remove last Modbus instance
- Test: push/pull functions
- ModbusTCP: Refactor connect by dns name (using native implementation for ESP32 etc)
// 4.3.0
- ModbusTLS: ESP32 Server
- Test: TLS ESP32 Server
- Test: TLS ESP32 Client
- Examples: TLS Certificate test Role extension and Alt-Name
- Examples: TLS Add example explanation
- ModbusTCP: ModbusAsyncTCP
- API: Extend API to allow custom Modbus commands
- Examples: Basic file operations
- Examples: Revising
```
## Contributions

https://github.com/emelianov/modbus-esp8266

[email protected]

Original version:

https://github.com/andresarmento/modbus-esp8266

https://github.com/andresarmento/modbus-arduino

prof (at) andresarmento (dot) com

## License

The code in this repo is licensed under the BSD New License. See LICENSE.txt for more info.
83 changes: 0 additions & 83 deletions README_pt_BR.md

This file was deleted.

8 changes: 0 additions & 8 deletions TODO.txt

This file was deleted.

Loading