save command to socket

This commit is contained in:
unknown 2024-08-23 14:09:05 +03:00
parent 44d79b598d
commit 15392ca858
1 changed files with 47 additions and 11 deletions

View File

@ -10,6 +10,17 @@ port = 9760
s.connect((host, port))
# print(s)
def send_data(data):
s.send(str.encode(json.dumps(data)))
response_data = s.recv(1024)
response = json.loads(response_data)
if data["reqType"] == 'query':
pprint({"request":data["queryAddr"], "response":response["queryData"]})
elif data["reqType"] == 'command':
pprint({"request":data["cmdData"], "response":response["cmdReply"]})
else:
pprint(response)
# получить версию оборудования
request_data = {
@ -18,21 +29,46 @@ request_data = {
"queryAddr": ["version", "curMold"],
}
request_data = {
send_data({
"dsID": "www.hc-system.com.RemoteMonitor",
"reqType": "query",
"packID": "0",
"queryAddr": ["RemoteCmdLen"],
})
send_data({
"dsID": "www.hc-system.com.HCRemoteCommand",
"reqType": "AddRCC",
"emptyList": "1",
"packID": "0",
"instructions": [{"oneshot": "0", "action": "51", "isUse": "0", "speed": "1234"}],
}
"instructions": [{"oneshot": "1", "action": "4",
"m0":"79.287",
"m1":"1.639",
"m2":"-31.667",
"m3":"3.380",
"m4":"7.986",
"m5":"-25.592",
"m6":"0",
"m7":"0",
"ckStatus":"0xFF",
"speed":"11.0",
"delay":"1.0",
"coord":"0",
"tool":"0",
"smooth":"0",
}],
})
request_data = {
"dsID": "www.hc-system.com.HCRemoteCommand",
send_data({
"dsID": "www.hc-system.com.RemoteMonitor",
"reqType": "query",
"packID": "0",
"queryAddr": ["RemoteCmdLen"],
})
send_data({
"dsID": "www.hc-system.com.RemoteMonitor",
"reqType": "command",
"packID": "0",
"cmdReply": ["AddRCC", "r1"],
}
s.send(str.encode(json.dumps(request_data)))
response_data = s.recv(1024)
response = json.loads(response_data)
pprint(response)
"cmdData": ["actionSingleCycle"],
})