@@ -12,42 +12,60 @@ import (
1212)
1313
1414const (
15- // Bit access
15+ // FuncCodeReadDiscreteInputs for bit wise access
1616 FuncCodeReadDiscreteInputs = 2
17- FuncCodeReadCoils = 1
18- FuncCodeWriteSingleCoil = 5
17+ // FuncCodeReadCoils for bit wise access
18+ FuncCodeReadCoils = 1
19+ // FuncCodeWriteSingleCoil for bit wise access
20+ FuncCodeWriteSingleCoil = 5
21+ // FuncCodeWriteMultipleCoils for bit wise access
1922 FuncCodeWriteMultipleCoils = 15
2023
21- // 16-bit access
22- FuncCodeReadInputRegisters = 4
23- FuncCodeReadHoldingRegisters = 3
24- FuncCodeWriteSingleRegister = 6
25- FuncCodeWriteMultipleRegisters = 16
24+ // FuncCodeReadInputRegisters 16-bit wise access
25+ FuncCodeReadInputRegisters = 4
26+ // FuncCodeReadHoldingRegisters 16-bit wise access
27+ FuncCodeReadHoldingRegisters = 3
28+ // FuncCodeWriteSingleRegister 16-bit wise access
29+ FuncCodeWriteSingleRegister = 6
30+ // FuncCodeWriteMultipleRegisters 16-bit wise access
31+ FuncCodeWriteMultipleRegisters = 16
32+ // FuncCodeReadWriteMultipleRegisters 16-bit wise access
2633 FuncCodeReadWriteMultipleRegisters = 23
27- FuncCodeMaskWriteRegister = 22
28- FuncCodeReadFIFOQueue = 24
34+ // FuncCodeMaskWriteRegister 16-bit wise access
35+ FuncCodeMaskWriteRegister = 22
36+ // FuncCodeReadFIFOQueue 16-bit wise access
37+ FuncCodeReadFIFOQueue = 24
2938)
3039
3140const (
32- ExceptionCodeIllegalFunction = 1
33- ExceptionCodeIllegalDataAddress = 2
34- ExceptionCodeIllegalDataValue = 3
35- ExceptionCodeServerDeviceFailure = 4
36- ExceptionCodeAcknowledge = 5
37- ExceptionCodeServerDeviceBusy = 6
38- ExceptionCodeMemoryParityError = 8
39- ExceptionCodeGatewayPathUnavailable = 10
41+ // ExceptionCodeIllegalFunction error code
42+ ExceptionCodeIllegalFunction = 1
43+ // ExceptionCodeIllegalDataAddress error code
44+ ExceptionCodeIllegalDataAddress = 2
45+ // ExceptionCodeIllegalDataValue error code
46+ ExceptionCodeIllegalDataValue = 3
47+ // ExceptionCodeServerDeviceFailure error code
48+ ExceptionCodeServerDeviceFailure = 4
49+ // ExceptionCodeAcknowledge error code
50+ ExceptionCodeAcknowledge = 5
51+ // ExceptionCodeServerDeviceBusy error code
52+ ExceptionCodeServerDeviceBusy = 6
53+ // ExceptionCodeMemoryParityError error code
54+ ExceptionCodeMemoryParityError = 8
55+ // ExceptionCodeGatewayPathUnavailable error code
56+ ExceptionCodeGatewayPathUnavailable = 10
57+ // ExceptionCodeGatewayTargetDeviceFailedToRespond error code
4058 ExceptionCodeGatewayTargetDeviceFailedToRespond = 11
4159)
4260
43- // ModbusError implements error interface.
44- type ModbusError struct {
61+ // Error implements error interface.
62+ type Error struct {
4563 FunctionCode byte
4664 ExceptionCode byte
4765}
4866
4967// Error converts known modbus exception code to error message.
50- func (e * ModbusError ) Error () string {
68+ func (e * Error ) Error () string {
5169 var name string
5270 switch e .ExceptionCode {
5371 case ExceptionCodeIllegalFunction :
0 commit comments