File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
modbus/src/main/java/com/digitalpetri/modbus Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 3
3
import com .digitalpetri .modbus .Crc16 ;
4
4
import com .digitalpetri .modbus .ModbusRtuFrame ;
5
5
import com .digitalpetri .modbus .TimeoutScheduler .TimeoutHandle ;
6
+ import com .digitalpetri .modbus .exceptions .ModbusCrcException ;
6
7
import com .digitalpetri .modbus .exceptions .ModbusException ;
7
8
import com .digitalpetri .modbus .exceptions .ModbusExecutionException ;
8
9
import com .digitalpetri .modbus .exceptions .ModbusResponseException ;
@@ -169,7 +170,7 @@ private void onFrameReceived(ModbusRtuFrame frame) {
169
170
if (!verifyCrc16 (frame )) {
170
171
transport .resetFrameParser ();
171
172
172
- promise .future .completeExceptionally (new ModbusException ( "CRC mismatch" ));
173
+ promise .future .completeExceptionally (new ModbusCrcException ( frame ));
173
174
return ;
174
175
}
175
176
Original file line number Diff line number Diff line change
1
+ package com .digitalpetri .modbus .exceptions ;
2
+
3
+ import com .digitalpetri .modbus .ModbusRtuFrame ;
4
+ import java .io .Serial ;
5
+
6
+ public class ModbusCrcException extends ModbusException {
7
+
8
+ @ Serial
9
+ private static final long serialVersionUID = -5350159787088895451L ;
10
+
11
+ private final ModbusRtuFrame frame ;
12
+
13
+ public ModbusCrcException (ModbusRtuFrame frame ) {
14
+ super ("CRC mismatch" );
15
+
16
+ this .frame = frame ;
17
+ }
18
+
19
+ /**
20
+ * Get the frame that caused the exception.
21
+ *
22
+ * @return the frame that caused the exception.
23
+ */
24
+ public ModbusRtuFrame getFrame () {
25
+ return frame ;
26
+ }
27
+
28
+ }
You can’t perform that action at this time.
0 commit comments