Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an errormap, so that errors can be easily found based on their ID #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down