@@ -16,7 +16,7 @@ slave.cbVector[CB_READ_INPUT_REGISTERS] = ReadAnalogIn;
16
16
Implement it:
17
17
18
18
``` 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 ) {
20
20
for (int i = 0; i < length; i++)
21
21
slave.writeRegisterToBuffer(i, analogRead(address + i));
22
22
}
@@ -82,6 +82,7 @@ A handler functions must return an uint8_t code and take the following as parame
82
82
- uint8_t fc - request function code
83
83
- uint16_t address - first register / first coil address
84
84
- uint16_t length - length of data
85
+ - void *callbackContext - callback context
85
86
86
87
Usable return codes:
87
88
@@ -152,7 +153,7 @@ void loop() {
152
153
}
153
154
154
155
// 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 ) {
156
157
if (slave.readCoilFromBuffer(0) == HIGH)
157
158
{
158
159
digitalWrite(address, HIGH);
@@ -194,7 +195,7 @@ void loop() {
194
195
}
195
196
196
197
// 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 ) {
198
199
// Write the result of analogRead() into the response buffer.
199
200
for (int i = 0; i < length; i++) {
200
201
slave.writeRegisterToBuffer(i, analogRead(address + i));
0 commit comments