/ bin / app / echo.py
echo.py
 1  #!/usr/bin/env python
 2  
 3  import zmq
 4  from pydrk import serial
 5  
 6  context = zmq.Context()
 7  socket = context.socket(zmq.REQ)
 8  #self.socket.setsockopt(zmq.IPV6, True)
 9  socket.connect(f"tcp://127.0.0.1:9484")
10  
11  req_cmd = bytearray()
12  serial.write_u8(req_cmd, 0)
13  payload = bytearray()
14  socket.send_multipart([req_cmd, payload])
15  
16  errc, reply = socket.recv_multipart()
17  errc = int.from_bytes(errc, "little")
18  cursor = serial.Cursor(reply)
19  response = serial.decode_str(cursor)
20  print(errc, response)
21