Skip to content

Commit 5b41b05

Browse files
authored
Update README.md (#103)
Updated README.md to reflect changes that have been made in issue #97. All callback functions must now include a fourth parameter of type void*.
1 parent 225a557 commit 5b41b05

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ slave.cbVector[CB_READ_INPUT_REGISTERS] = ReadAnalogIn;
1616
Implement it:
1717

1818
```c
19-
void ReadAnalogIn(uint8_t fc, uint16_t address, uint16_t length) {
19+
void ReadAnalogIn(uint8_t fc, uint16_t address, uint16_t length, void *callbackContext) {
2020
for (int i = 0; i < length; i++)
2121
slave.writeRegisterToBuffer(i, analogRead(address + i));
2222
}
@@ -82,6 +82,7 @@ A handler functions must return an uint8_t code and take the following as parame
8282
- uint8_t fc - request function code
8383
- uint16_t address - first register / first coil address
8484
- uint16_t length - length of data
85+
- void *callbackContext - callback context
8586
8687
Usable return codes:
8788
@@ -152,7 +153,7 @@ void loop() {
152153
}
153154
154155
// Handel Force Single Coil (FC=05).
155-
uint8_t writeDigitalOut(uint8_t fc, uint16_t address, uint16_t length) {
156+
uint8_t writeDigitalOut(uint8_t fc, uint16_t address, uint16_t length, void *callbackContext) {
156157
if (slave.readCoilFromBuffer(0) == HIGH)
157158
{
158159
digitalWrite(address, HIGH);
@@ -194,7 +195,7 @@ void loop() {
194195
}
195196

196197
// Handle Read Input Registers (FC=04).
197-
uint8_t readAnalogIn(uint8_t fc, uint16_t address, uint16_t length) {
198+
uint8_t readAnalogIn(uint8_t fc, uint16_t address, uint16_t length, void *callbackContext) {
198199
// Write the result of analogRead() into the response buffer.
199200
for (int i = 0; i < length; i++) {
200201
slave.writeRegisterToBuffer(i, analogRead(address + i));

0 commit comments

Comments
 (0)