Skip to content

Commit

Permalink
新增modbus模拟能力
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed May 28, 2024
1 parent 6e2b032 commit 9b3b410
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/plugins/modbus/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
)

func (c *connector) mockRead(slaveId uint8, registerType string, address, quantity uint16) (values []uint16, err error) {
mockData, e := helper.CallLuaMethod(c.plugin.ls, "mockRead", lua.LNumber(slaveId), lua.LString(registerType), lua.LNumber(address), lua.LNumber(quantity))
e = json.Unmarshal([]byte(mockData), &values)
return values, e
mockData, err := helper.CallLuaMethod(c.plugin.ls, "mockRead", lua.LNumber(slaveId), lua.LString(registerType), lua.LNumber(address), lua.LNumber(quantity))
if err != nil {
return
}
err = json.Unmarshal([]byte(mockData), &values)
return
}

func (c *connector) mockWrite(slaveID uint8, registerType primaryTable, address uint16, values []uint16) error {
Expand Down

0 comments on commit 9b3b410

Please sign in to comment.