Skip to content

Commit 5d7fe2d

Browse files
committed
RTU: Add _onRequest on illegal function
1 parent 0bc538d commit 5d7fe2d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Modbus.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ void Modbus::slavePDU(uint8_t* frame) {
431431
break;
432432

433433
default:
434-
exceptionResponse(fcode, EX_ILLEGAL_FUNCTION);
434+
ex = _onRequest(fcode, {frame + 1});
435+
if (ex != EX_PASSTHROUGH) {
436+
exceptionResponse(fcode, EX_ILLEGAL_FUNCTION);
437+
}
435438
return;
436439
}
437440
}

src/Modbus.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class Modbus {
153153
uint16_t andMask;
154154
uint16_t orMask;
155155
};
156+
uint8_t* data;
156157
RequestData(TAddress r1, uint16_t c1) {
157158
reg = r1;
158159
regCount = c1;
@@ -168,6 +169,9 @@ class Modbus {
168169
andMask = m1;
169170
orMask = m2;
170171
};
172+
RequestData(uint8_t* d) {
173+
data = d;
174+
};
171175
};
172176

173177
struct frame_arg_t {

0 commit comments

Comments
 (0)