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

How to read Exceptions from goburrow modbus slave library #5

Open
samminen opened this issue Feb 26, 2020 · 0 comments
Open

How to read Exceptions from goburrow modbus slave library #5

samminen opened this issue Feb 26, 2020 · 0 comments

Comments

@samminen
Copy link

Hello, I have both modbus slave and modbus master (implemented in GoLang) but I am not able to figure out how to get below list of exceptions when there a invalid operation read/write.

In modbus slave how to call func GetException(frame Framer) (exception Exception) ?
I am calling below function to read holding registers and handling err if any

result, err := client.ReadHoldingRegisters(req.StartAddress, req.Count)


client := mb.NewClient(handler.client)
result, err := client.ReadHoldingRegisters(req.StartAddress, req.Count)
if err != nil {
// Added close in since the keep alive will prevent it from ever reconnecting
level.Error(logger).Log("err: Modbus TCP Client Unavailable ", err.Error())
handler.client.Close()

				go buildResponseRawData(*handler, req.Type, "", result, err, &req.ResultsChan)
			} else {
				go buildResponseRawData(*handler, req.Type, req.Endian, result, nil, &req.ResultsChan)
			}

// Success operation successful.
Success Exception
// IllegalFunction function code received in the query is not recognized or allowed by slave.
IllegalFunction Exception = 1
// IllegalDataAddress data address of some or all the required entities are not allowed or do not exist in slave.
IllegalDataAddress Exception = 2
// IllegalDataValue value is not accepted by slave.
IllegalDataValue Exception = 3
// SlaveDeviceFailure Unrecoverable error occurred while slave was attempting to perform requested action.
SlaveDeviceFailure Exception = 4
// AcknowledgeSlave has accepted request and is processing it, but a long duration of time is required. This response is returned to prevent a timeout error from occurring in the master. Master can next issue a Poll Program Complete message to determine whether processing is completed.
AcknowledgeSlave Exception = 5
// SlaveDeviceBusy is engaged in processing a long-duration command. Master should retry later.
SlaveDeviceBusy Exception = 6
// NegativeAcknowledge Slave cannot perform the programming functions. Master should request diagnostic or error information from slave.
NegativeAcknowledge Exception = 7
// MemoryParityError Slave detected a parity error in memory. Master can retry the request, but service may be required on the slave device.
MemoryParityError Exception = 8
// GatewayPathUnavailable Specialized for Modbus gateways. Indicates a misconfigured gateway.
GatewayPathUnavailable Exception = 10
// GatewayTargetDeviceFailedtoRespond Specialized for Modbus gateways. Sent when slave fails to respond.
GatewayTargetDeviceFailedtoRespond Exception = 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant