Skip to content

Commit c30d7ac

Browse files
committed
Incorporate API feedback from Tom, fixes for Modbus Server
1 parent 5d93ddc commit c30d7ac

File tree

10 files changed

+372
-362
lines changed

10 files changed

+372
-362
lines changed

examples/RTU/ModbusRTUClientToggle/ModbusRTUClientToggle.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void setup() {
3636

3737
void loop() {
3838
// for (slave) id 1: write the value of 0x01, to the coil at address 0x00
39-
if (!ModbusRTUClient.writeCoil(1, 0x00, 0x01)) {
39+
if (!ModbusRTUClient.coilWrite(1, 0x00, 0x01)) {
4040
Serial.print("Failed to write coil! ");
4141
Serial.println(ModbusRTUClient.lastError());
4242
}
@@ -45,7 +45,7 @@ void loop() {
4545
delay(1000);
4646

4747
// for (slave) id 1: write the value of 0x00, to the coil at address 0x00
48-
if (!ModbusRTUClient.writeCoil(1, 0x00, 0x00)) {
48+
if (!ModbusRTUClient.coilWrite(1, 0x00, 0x00)) {
4949
Serial.print("Failed to write coil! ");
5050
Serial.println(ModbusRTUClient.lastError());
5151
}

examples/RTU/ModbusRTUServerLED/ModbusRTUServerLED.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void setup() {
2828

2929
Serial.println("Modbus RTU Server LED");
3030

31-
// start the Modbus RTU server
31+
// start the Modbus RTU server, with (slave) id 1
3232
if (!ModbusRTUServer.begin(1, 9600)) {
3333
Serial.println("Failed to start Modbus RTU Server!");
3434
while (1);
@@ -47,7 +47,7 @@ void loop() {
4747
ModbusRTUServer.poll();
4848

4949
// read the current value of the coil
50-
int coilValue = ModbusRTUServer.readCoil(0x00);
50+
int coilValue = ModbusRTUServer.coilRead(0x00);
5151

5252
if (coilValue) {
5353
// coil value set, turn LED on

examples/TCP/WiFiModbusClientToggle/WiFiModbusClientToggle.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void loop() {
6969
// client connected
7070

7171
// write the value of 0x01, to the coil at address 0x00
72-
if (!modbusTCPClient.writeCoil(0x00, 0x01)) {
72+
if (!modbusTCPClient.coilWrite(0x00, 0x01)) {
7373
Serial.print("Failed to write coil! ");
7474
Serial.println(modbusTCPClient.lastError());
7575
}
@@ -78,7 +78,7 @@ void loop() {
7878
delay(1000);
7979

8080
// write the value of 0x00, to the coil at address 0x00
81-
if (!modbusTCPClient.writeCoil(0x00, 0x00)) {
81+
if (!modbusTCPClient.coilWrite(0x00, 0x00)) {
8282
Serial.print("Failed to write coil! ");
8383
Serial.println(modbusTCPClient.lastError());
8484
}

examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void loop() {
9797

9898
void updateLED() {
9999
// read the current value of the coil
100-
int coilValue = modbusTCPServer.readCoil(0x00);
100+
int coilValue = modbusTCPServer.coilRead(0x00);
101101

102102
if (coilValue) {
103103
// coil value set, turn LED on

keywords.txt

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,34 @@ begin KEYWORD2
2020
poll KEYWORD2
2121
end KEYWORD2
2222

23-
readCoil KEYWORD2
24-
readCoils KEYWORD2
25-
readDiscreteInput KEYWORD2
26-
readDiscreteInputs KEYWORD2
27-
readHoldingRegister KEYWORD2
28-
readHoldingRegisters KEYWORD2
29-
readInputRegister KEYWORD2
30-
readInputRegisters KEYWORD2
31-
writeCoil KEYWORD2
32-
writeCoils KEYWORD2
33-
writeHoldingRegister KEYWORD2
34-
writeHoldingRegisters KEYWORD2
35-
maskWriteRegister KEYWORD2
36-
writeAndReadRegisters KEYWORD2
23+
beginTransmission KEYWORD2
24+
write KEYWORD2
25+
endTransmission KEYWORD2
26+
requestFrom KEYWORD2
27+
available KEYWORD2
28+
read KEYWORD2
29+
30+
coilRead KEYWORD2
31+
discreteInputRead KEYWORD2
32+
holdingRegisterRead KEYWORD2
33+
inputRegisterRead KEYWORD2
34+
coilWrite KEYWORD2
35+
holdingRegisterWrite KEYWORD2
36+
registerMaskWrite KEYWORD2
3737
lastError KEYWORD2
3838

3939
configureCoils KEYWORD2
4040
configureDiscreteInputs KEYWORD2
4141
configureHoldingRegisters KEYWORD2
4242
configureInputRegisters KEYWORD2
43-
writeDiscreteInput KEYWORD2
44-
writeDiscreteInputs KEYWORD2
45-
writeInputRegister KEYWORD2
46-
writeInputRegisters KEYWORD2
43+
discreteInputWrite KEYWORD2
44+
inputRegisterWrite KEYWORD2
4745

4846
#######################################
4947
# Constants (LITERAL1)
5048
#######################################
49+
50+
COILS LITERAL1
51+
DISCRETE_INPUTS LITERAL1
52+
HOLIDING_REGISTERS LITERAL1
53+
INPUT_REGISTERS LITERAL1

0 commit comments

Comments
 (0)