Skip to content

Commit

Permalink
Merge pull request #7 from yonwoo9/fix
Browse files Browse the repository at this point in the history
fix something
  • Loading branch information
wendy512 authored Jul 7, 2024
2 parents cf0bab6 + fc41020 commit c0d1d51
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
17 changes: 10 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ func (c *Client) GetLogicalDeviceList() DataModel {

C.LinkedList_destroy(dataSets)

clnRef := Go2CStr(lnRef)
defer C.free(unsafe.Pointer(clnRef))
clnRef1 := Go2CStr(lnRef)
defer C.free(unsafe.Pointer(clnRef1))

reports := C.IedConnection_getLogicalNodeDirectory(c.conn, &clientError, clnRef, C.ACSI_CLASS_URCB)
reports := C.IedConnection_getLogicalNodeDirectory(c.conn, &clientError, clnRef1, C.ACSI_CLASS_URCB)
report := reports.next
for report != nil {
var r URReport
Expand All @@ -256,10 +256,10 @@ func (c *Client) GetLogicalDeviceList() DataModel {
}
C.LinkedList_destroy(reports)

clnRef := Go2CStr(lnRef)
defer C.free(unsafe.Pointer(clnRef))
clnRef2 := Go2CStr(lnRef)
defer C.free(unsafe.Pointer(clnRef2))

reports = C.IedConnection_getLogicalNodeDirectory(c.conn, &clientError, clnRef, C.ACSI_CLASS_BRCB)
reports = C.IedConnection_getLogicalNodeDirectory(c.conn, &clientError, clnRef2, C.ACSI_CLASS_BRCB)
report = reports.next
for report != nil {
var r BRReport
Expand Down Expand Up @@ -380,8 +380,9 @@ func (c *Client) GetVariableSpecType(objectReference string, fc FC) (MmsType, er
default:
return Uint32, nil
}
default:
return mmsType, fmt.Errorf("unsupported type %d", mmsType)
}
return mmsType, nil
}

func (c *Client) toGoValue(mmsValue *C.MmsValue, mmsType MmsType) interface{} {
Expand Down Expand Up @@ -413,6 +414,8 @@ func (c *Client) toGoValue(mmsValue *C.MmsValue, mmsType MmsType) interface{} {
value = uint64(C.MmsValue_getBinaryTimeAsUtcMs(mmsValue))
case UTCTime:
value = uint32(C.MmsValue_toUnixTimestamp(mmsValue))
default:
panic(fmt.Sprintf("unsupported type %d", mmsType))
}
return value
}
Expand Down
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
CreateControlObjectClientFail = errors.New("control object not found in server")
ControlObjectFail = errors.New("control object fail")
ControlSelectFail = errors.New("select control fail")
UnSupportOperation = errors.New("un support operation")
UnSupportedOperation = errors.New("unsupported operation")
)

func GetIedClientError(err C.IedClientError) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.19

require (
github.com/spf13/cast v1.6.0
golang.org/x/text v0.14.0
golang.org/x/text v0.16.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
2 changes: 1 addition & 1 deletion mms.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func toMmsValue(mmsType MmsType, value interface{}) (*C.MmsValue, error) {
return nil, err
}
default:
return nil, UnSupportOperation
return nil, UnSupportedOperation
}
return mmsValue, nil
}
Expand Down

0 comments on commit c0d1d51

Please sign in to comment.