From d36bf4b1bb7870f0ee46f6cbd1cf40b2231f622c Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 25 Sep 2017 16:38:16 +0200 Subject: [PATCH] Added an errormap, so that errors can be easily found based on their ID --- message.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/message.go b/message.go index 076c9d4..b9bb932 100644 --- a/message.go +++ b/message.go @@ -89,6 +89,22 @@ var ( GatewayTargetDeviceFailedToRespondError = Error{Code: 11, msg: "gateway target device failed to respond"} ) +// ErrorMap is a map where all the implemented Modbus errors are stored, which +// their ID as the key. This makes is easy to ge the error based on the +// errorcode +var ErrorMap = map[int]Error{ + 1: IllegalFunctionError, + 2: IllegalAddressError, + 3: IllegalDataValueError, + 4: SlaveDeviceFailureError, + 5: AcknowledgeError, + 6: SlaveDeviceBusyError, + 7: NegativeAcknowledgeError, + 8: MemoryParityError, + 10: GatewayPathUnavailableError, + 11: GatewayTargetDeviceFailedToRespondError, +} + // Value is a value an integer ranging from range of -32768 through 65535. type Value struct { v int