From 15392ca85848dda7bd4bb9042722b15e4d8407d6 Mon Sep 17 00:00:00 2001 From: unknown <ТД@DESKTOP-7LS51MR.svs-tech.pro> Date: Fri, 23 Aug 2024 14:09:05 +0300 Subject: [PATCH] save command to socket --- client_socket.py | 58 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/client_socket.py b/client_socket.py index 5fbae37..25b5785 100644 --- a/client_socket.py +++ b/client_socket.py @@ -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"], +}) \ No newline at end of file