ljean/modbus-tk

simulator.py/RpcHandler() needs encode/decode to work these days

kiml opened this issue · 1 comments

kiml commented

I needed to make the following change (Python 3.9) to make this code work.

@@ -90,13 +90,13 @@ class RpcHandler(SocketServer.BaseRequestHandler):
"""This function is called automatically by the SocketServer"""
# self.request is the TCP socket connected to the client
# read the incoming command

  •    request = self.request.recv(1024).strip()
    
  •    request = self.request.recv(1024).decode().strip()
       # write to the queue waiting to be processed by the server
       INPUT_QUEUE.put(request)
       # wait for the server answer in the output queue
       response = OUTPUT_QUEUE.get(timeout=5.0)
       # send back the answer
    
  •    self.request.send(response)
    
  •    self.request.send(response.encode())
    
ljean commented

Hello, thanks for proposal. Can you please make a PR with this code. Is it still works in prior version of Python 3?