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

Add extended description for CIPStatus, replace couple of hardcoded 0 and 6 to proper CIPStatus for readability. #28

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
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
26 changes: 13 additions & 13 deletions cip_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,23 +389,23 @@ func (s CIPStatus) String() string {
case CIPStatus_OK:
return "OK"
case CIPStatus_ConnectionFailure:
return "ConnectionFailure"
return "Connection failure - A connection related service failed along the connection path."
case CIPStatus_ResourceUnavailable:
return "ResourceUnavailable"
return "Resource unavailable - Resources needed for the object to perform the requested service were unavailable"
case CIPStatus_InvalidParameterValue:
return "InvalidParameterValue"
case CIPStatus_PathSegmentError:
return "PathSegmentError"
return "Path segment error - The path segment identifier or the segment syntax was not understood by the processing node."
case CIPStatus_PathDestinationUnknown:
return "PathDestinationUnknown"
return "Path destination unknown - The path is referencing an object class, instance or structure element that is not known or is not contained in the processing node. Path processing shall stop when a path destination unknown error is encountered"
case CIPStatus_PartialTransfer:
return "PartialTransfer"
case CIPStatus_ConnectionLost:
return "ConnectionLost"
case CIPStatus_ServiceNotSupported:
return "ServiceNotSupported"
return "Service not supported - The requested service was not implemented or was not defined for this Object Class/Instance"
case CIPStatus_InvalidAttributeValue:
return "InvalidAttributeValue"
return "Invalid attribute value - Invalid attribute data detected"
case CIPStatus_AttributeListError:
return "AttributeListError"
case CIPStatus_AlreadyInRequestedMode:
Expand All @@ -415,7 +415,7 @@ func (s CIPStatus) String() string {
case CIPStatus_ObjectAlreadyExists:
return "ObjectAlreadyExists"
case CIPStatus_AttributeNotSettable:
return "AttributeNotSettable"
return "Attribute not settable - A request to modify a non-modifiable attribute was received."
case CIPStatus_PrivilegeViolation:
return "PrivilegeViolation"
case CIPStatus_DeviceStateConflict:
Expand All @@ -425,13 +425,13 @@ func (s CIPStatus) String() string {
case CIPStatus_FragmentationOfMessage:
return "FragmentationOfMessage"
case CIPStatus_NotEnoughData:
return "NotEnoughData"
return "Not enough data - The service did not supply enough data to perform the specified operation"
case CIPStatus_AttributeNotSupported:
return "AttributeNotSupported"
return "Attribute not supported - The attribute specified in the request is not supported"
case CIPStatus_TooMuchData:
return "TooMuchData"
return "Too much data - The service supplied more data than was expected"
case CIPStatus_ObjectDoesNotExist:
return "ObjectDoesNotExist"
return "Object does not exist - The object specified does not exist in the device."
case CIPStatus_ServiceFragmentation:
return "ServiceFragmentation"
case CIPStatus_NoStoredAttributeData:
Expand All @@ -451,7 +451,7 @@ func (s CIPStatus) String() string {
case CIPStatus_VendorSpecificError:
return "VendorSpecificError"
case CIPStatus_InvalidParameter:
return "InvalidParameter"
return "Invalid parameter - A parameter associated with the request was invalid. This code is used when a parameter does not meet the requirements of this specification and/or the requirements defined in an Application Object Specification"
case CIPStatus_WriteOnceValueOrMedium:
return "WriteOnceValueOrMedium"
case CIPStatus_InvalidReplyReceived:
Expand All @@ -463,7 +463,7 @@ func (s CIPStatus) String() string {
case CIPStatus_KeyFailure:
return "KeyFailure"
case CIPStatus_PathSizeInvalid:
return "PathSizeInvalid"
return "Path size invalid - The size of the path which was sent with the Service Request is either not large enough to allow the Request to be routed to an object or too much routing data was included"
case CIPStatus_UnexpectedAttribInList:
return "UnexpectedAttribInList"
case CIPStatus_InvalidMemberID:
Expand Down
2 changes: 1 addition & 1 deletion connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func (client *Client) parseResponse(header *eipHeader, data *bytes.Buffer) ([]CI
return nil, fmt.Errorf("error deserializing forward open response header extended status. %w", err)
}
}
if respHeader.Status != 0 {
if respHeader.Status != CIPStatus_OK {
errMsg := "bad status on response"
client.Logger.Error(errMsg,
slog.Any("status", respHeader.Status),
Expand Down
2 changes: 1 addition & 1 deletion listalltags.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (client *Client) ListAllTags(start_instance uint32) error {

}

if data_hdr.Status == 6 { //} && start_instance < 200 {
if data_hdr.Status == uint16(CIPStatus_PartialTransfer) { //} && start_instance < 200 {
err = client.ListAllTags(start_instance)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion listsubtags.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (client *Client) ListSubTags(Program *KnownProgram, start_instance uint32)

}

if data_hdr.Status == 6 {
if data_hdr.Status == uint16(CIPStatus_PartialTransfer) {
_, err = client.ListSubTags(Program, start_instance)
if err != nil {
return new_kts, fmt.Errorf("problem listing subtags. %w", err)
Expand Down
2 changes: 1 addition & 1 deletion read.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ func (client *Client) readList(tags []tagDesc) ([]any, error) {
return nil, fmt.Errorf("wasn't a response service. Got %v", rHdr.Service)
}
rHdr.Service = rHdr.Service.UnResponse()
if rHdr.Status != 0 {
if rHdr.Status != uint16(CIPStatus_OK) {
return nil, fmt.Errorf("problem reading %v. Status %v", tags[i], rHdr.Status)
}
if tags[i].Elements == 1 {
Expand Down
4 changes: 2 additions & 2 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (client *Client) write_udt(tag string, value any) error {
if err != nil {
return fmt.Errorf("problem deserializing write response header, %w", err)
}
if hdr2.Status != 0 {
if hdr2.Status != CIPStatus_OK {
extended := uint16(0)
if hdr2.StatusExtended == 1 {
err = items[1].DeSerialize(&extended)
Expand Down Expand Up @@ -181,7 +181,7 @@ func (client *Client) write_single(tag string, value any) error {
if err != nil {
return fmt.Errorf("problem deserializing write response header, %w", err)
}
if hdr2.Status != 0 {
if hdr2.Status != CIPStatus_OK {
extended := uint16(0)
if hdr2.StatusExtended == 1 {
err = items[1].DeSerialize(&extended)
Expand Down