title: Can't connect to slave with Python's modbus_tk
body: <p>I'm currently trying to develop an application that uses the Modbus-RTU protocol, and I have to use <em>modbus_tk</em> in Python 2.7.</p>
  
  <p>I'm supposed to use bits of code from another application which is able to communicate with the micro-controller via modbus. It works on that app when I run the following code, but I get an error when I run the same lines in my app.</p>
  
  <pre><code>import modbus_tk
  import modbus_tk.defines as cst
  import modbus_tk.modbus_rtu as modbus_rtu
  import serial
  
  MB_Add_Status = 8 + 5001
  
  def MB_GetStatus(MB_Master_handle):
      try:
          status = MB_Master_handle.execute(1, cst.READ_HOLDING_REGISTERS, MB_Add_Status, 1)
          return status
      except modbus_tk.modbus.ModbusError, e:
          logger.error("%s- Code=%d" % (e, e.get_exception_code()))
  
  MB_port  = 3
  masterMB = modbus_rtu.RtuMaster(serial.Serial(port='COM'+str(MB_port), baudrate=19200, bytesize=8, parity='N', stopbits=2, xonxoff=0))
  status = MB_GetStatus(masterMB)
  </code></pre>
  
  <p>First I needed to delete the arguments <code>baudrate</code>, <code>bytesize</code>, etc. in the constructor call because it rose an error like :</p>
  
  <pre><code>TypeError: __init__() got an unexpected keyword argument 'stopbits'
  </code></pre>
  
  <p>But then when we get to the call to <code>execute</code>, there is an error again, which I couldn't solve yet :</p>
  
  <pre><code>modbus_tk.modbus.ModbusInvalidResponseError: Response length is invalid 0
  </code></pre>
  
  <p>The only documentation I found is: <a href="https://github.com/Nobatek/modbus-tk/tree/master/docs" rel="nofollow">https://github.com/Nobatek/modbus-tk/tree/master/docs</a>, but I couldn't quite understand much of it. If someone could first explain me what this error really means, and where I should look, this would be highly appreciated. Thank you very much !</p>