@dobot-plus/template 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/Main.schema.json +4 -0
- package/lua/utils/modbus.lua +12 -2
- package/package.json +1 -1
package/.vscode/Main.schema.json
CHANGED
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"type": "boolean",
|
|
22
22
|
"description": "Indicates if permissions are required for the application."
|
|
23
23
|
},
|
|
24
|
+
"hotkey": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"description": "Indicates if the application supports hotkeys."
|
|
27
|
+
},
|
|
24
28
|
"applicationDisplayed": {
|
|
25
29
|
"type": "object",
|
|
26
30
|
"properties": {
|
package/lua/utils/modbus.lua
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('$PLUGIN_NAME$.variables')
|
|
2
2
|
require("$PLUGIN_NAME$.util")
|
|
3
|
-
local lockerName = "
|
|
3
|
+
local lockerName = "dobot_485_lock"
|
|
4
4
|
|
|
5
5
|
--- SetTool485(baudrate, parity, stop, identify)
|
|
6
6
|
--- err, id = ModbusCreate(ip, port, slaveId, isRTU): use endTool for 485 communication
|
|
@@ -11,7 +11,7 @@ function createModbusMasterClient(slaveID)
|
|
|
11
11
|
local err, id = ModbusCreate("127.0.0.1", 60000, tonumber(slaveID), true)
|
|
12
12
|
--- local err, id = ModbusRTUCreate(slave_id, baud, parity, data_bit, stop_bit)
|
|
13
13
|
if err ~= 0 then
|
|
14
|
-
print("
|
|
14
|
+
print("ModbusCreate error:"..err)
|
|
15
15
|
return nil
|
|
16
16
|
end
|
|
17
17
|
return id
|
|
@@ -25,6 +25,11 @@ function getRegsData(reg, slaveID)
|
|
|
25
25
|
end
|
|
26
26
|
local result = Lock(lockerName, 10000, 10000)
|
|
27
27
|
Wait(10)
|
|
28
|
+
if result == false then
|
|
29
|
+
print("getRegsData lock failed")
|
|
30
|
+
ModbusClose(clientID)
|
|
31
|
+
return {}
|
|
32
|
+
end
|
|
28
33
|
local data = GetHoldRegs(clientID, reg.addrDec, reg.length)
|
|
29
34
|
Wait(10)
|
|
30
35
|
UnLock(lockerName)
|
|
@@ -42,6 +47,11 @@ function setRegsData(reg, values, slaveID)
|
|
|
42
47
|
end
|
|
43
48
|
local result = Lock(lockerName, 10000, 10000)
|
|
44
49
|
Wait(10)
|
|
50
|
+
if result == false then
|
|
51
|
+
print("setRegsData lock failed")
|
|
52
|
+
ModbusClose(clientID)
|
|
53
|
+
return -1
|
|
54
|
+
end
|
|
45
55
|
local err = SetHoldRegs(clientID, reg.addrDec, reg.length, values, 'U16')
|
|
46
56
|
Wait(10)
|
|
47
57
|
UnLock(lockerName)
|