Skip to content

Commit ad1a485

Browse files
committed
Renaming Ambiguous Functions
Hreg() -> hreg()/setHreg() Ireg() -> ireg()/setIreg() Ists() -> ists()/setIsts() Coil() -> coil()/setCoil()
1 parent 8d90be5 commit ad1a485

File tree

4 files changed

+219
-130
lines changed

4 files changed

+219
-130
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Modbus-Arduino",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"keywords": "modbus, server, slave, rtu, tcp",
55
"description": "A library that allows your Arduino to communicate via Modbus protocol, acting as a slave. Application layer library (OSI 7), used by all implementations over serial line and TCP/IP.",
66
"homepage": "https://github.com/epsilonrt/modbus-arduino",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Modbus-Arduino
2-
version=1.0.0
2+
version=1.1.0
33
author=Pascal Jean aka epsilonrt,André Sarmento Barbosa
44
maintainer=epsilonrt
55
sentence=A library that allows your Arduino to communicate via Modbus protocol, acting as a slave.

src/Modbus.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void Modbus::addReg (word address, word value) {
4848
}
4949
}
5050

51-
bool Modbus::Reg (word address, word value) {
51+
bool Modbus::setReg (word address, word value) {
5252
TRegister * reg;
5353
//search for the register address
5454
reg = this->searchRegister (address);
@@ -62,7 +62,7 @@ bool Modbus::Reg (word address, word value) {
6262
}
6363
}
6464

65-
word Modbus::Reg (word address) {
65+
word Modbus::reg (word address) {
6666
TRegister * reg;
6767
reg = this->searchRegister (address);
6868
if (reg) {
@@ -77,12 +77,12 @@ void Modbus::addHreg (word offset, word value) {
7777
this->addReg (offset + 40001, value);
7878
}
7979

80-
bool Modbus::Hreg (word offset, word value) {
81-
return Reg (offset + 40001, value);
80+
bool Modbus::setHreg (word offset, word value) {
81+
return setReg (offset + 40001, value);
8282
}
8383

84-
word Modbus::Hreg (word offset) {
85-
return Reg (offset + 40001);
84+
word Modbus::hreg (word offset) {
85+
return reg (offset + 40001);
8686
}
8787

8888
#ifndef USE_HOLDING_REGISTERS_ONLY
@@ -98,38 +98,38 @@ void Modbus::addIreg (word offset, word value) {
9898
this->addReg (offset + 30001, value);
9999
}
100100

101-
bool Modbus::Coil (word offset, bool value) {
102-
return Reg (offset + 1, value ? 0xFF00 : 0x0000);
101+
bool Modbus::setCoil (word offset, bool value) {
102+
return setReg (offset + 1, value ? 0xFF00 : 0x0000);
103103
}
104104

105-
bool Modbus::Ists (word offset, bool value) {
106-
return Reg (offset + 10001, value ? 0xFF00 : 0x0000);
105+
bool Modbus::setIsts (word offset, bool value) {
106+
return setReg (offset + 10001, value ? 0xFF00 : 0x0000);
107107
}
108108

109-
bool Modbus::Ireg (word offset, word value) {
110-
return Reg (offset + 30001, value);
109+
bool Modbus::setIreg (word offset, word value) {
110+
return setReg (offset + 30001, value);
111111
}
112112

113-
bool Modbus::Coil (word offset) {
114-
if (Reg (offset + 1) == 0xFF00) {
113+
bool Modbus::coil (word offset) {
114+
if (reg (offset + 1) == 0xFF00) {
115115
return true;
116116
}
117117
else {
118118
return false;
119119
}
120120
}
121121

122-
bool Modbus::Ists (word offset) {
123-
if (Reg (offset + 10001) == 0xFF00) {
122+
bool Modbus::ists (word offset) {
123+
if (reg (offset + 10001) == 0xFF00) {
124124
return true;
125125
}
126126
else {
127127
return false;
128128
}
129129
}
130130

131-
word Modbus::Ireg (word offset) {
132-
return Reg (offset + 30001);
131+
word Modbus::ireg (word offset) {
132+
return reg (offset + 30001);
133133
}
134134
#endif
135135

@@ -277,7 +277,7 @@ void Modbus::readRegisters (word startreg, word numregs) {
277277
word i = 0;
278278
while (numregs--) {
279279
//retrieve the value from the register bank for the current register
280-
val = this->Hreg (startreg + i);
280+
val = this->hreg (startreg + i);
281281
//write the high byte of the register value
282282
_frame[2 + i * 2] = val >> 8;
283283
//write the low byte of the register value
@@ -291,13 +291,13 @@ void Modbus::readRegisters (word startreg, word numregs) {
291291
void Modbus::writeSingleRegister (word reg, word value) {
292292
//No necessary verify illegal value (EX_ILLEGAL_VALUE) - because using word (0x0000 - 0x0FFFF)
293293
//Check Address and execute (reg exists?)
294-
if (!this->Hreg (reg, value)) {
294+
if (!this->setHreg (reg, value)) {
295295
this->exceptionResponse (MB_FC_WRITE_REG, MB_EX_ILLEGAL_ADDRESS);
296296
return;
297297
}
298298

299299
//Check for failure
300-
if (this->Hreg (reg) != value) {
300+
if (this->hreg (reg) != value) {
301301
this->exceptionResponse (MB_FC_WRITE_REG, MB_EX_SLAVE_FAILURE);
302302
return;
303303
}
@@ -339,7 +339,7 @@ void Modbus::writeMultipleRegisters (byte * frame, word startreg, word numoutput
339339
word i = 0;
340340
while (numoutputs--) {
341341
val = (word) frame[6 + i * 2] << 8 | (word) frame[7 + i * 2];
342-
this->Hreg (startreg + i, val);
342+
this->setHreg (startreg + i, val);
343343
i++;
344344
}
345345

@@ -389,7 +389,7 @@ void Modbus::readCoils (word startreg, word numregs) {
389389
word i;
390390
while (numregs--) {
391391
i = (totregs - numregs) / 8;
392-
if (this->Coil (startreg)) {
392+
if (this->coil (startreg)) {
393393
bitSet (_frame[2 + i], bitn);
394394
}
395395
else {
@@ -446,7 +446,7 @@ void Modbus::readInputStatus (word startreg, word numregs) {
446446
word i;
447447
while (numregs--) {
448448
i = (totregs - numregs) / 8;
449-
if (this->Ists (startreg)) {
449+
if (this->ists (startreg)) {
450450
bitSet (_frame[2 + i], bitn);
451451
}
452452
else {
@@ -499,7 +499,7 @@ void Modbus::readInputRegisters (word startreg, word numregs) {
499499
word i = 0;
500500
while (numregs--) {
501501
//retrieve the value from the register bank for the current register
502-
val = this->Ireg (startreg + i);
502+
val = this->ireg (startreg + i);
503503
//write the high byte of the register value
504504
_frame[2 + i * 2] = val >> 8;
505505
//write the low byte of the register value
@@ -518,13 +518,13 @@ void Modbus::writeSingleCoil (word reg, word status) {
518518
}
519519

520520
//Check Address and execute (reg exists?)
521-
if (!this->Coil (reg, (bool) status)) {
521+
if (!this->setCoil (reg, (bool) status)) {
522522
this->exceptionResponse (MB_FC_WRITE_COIL, MB_EX_ILLEGAL_ADDRESS);
523523
return;
524524
}
525525

526526
//Check for failure
527-
if (this->Coil (reg) != (bool) status) {
527+
if (this->coil (reg) != (bool) status) {
528528
this->exceptionResponse (MB_FC_WRITE_COIL, MB_EX_SLAVE_FAILURE);
529529
return;
530530
}
@@ -571,7 +571,7 @@ void Modbus::writeMultipleCoils (byte * frame, word startreg, word numoutputs, b
571571
word i;
572572
while (numoutputs--) {
573573
i = (totoutputs - numoutputs) / 8;
574-
this->Coil (startreg, bitRead (frame[6 + i], bitn));
574+
this->setCoil (startreg, bitRead (frame[6 + i], bitn));
575575
//increment the bit index
576576
bitn++;
577577
if (bitn == 8) {

0 commit comments

Comments
 (0)