title: python and serial. how to send a message and receive an answer
body: <p>I have to send <code>ZANE:1:00004:XX_X.X_XXXX_000XX:\r\n</code>via serial communication with python. </p>
  
  <p>here is my code:</p>
  
  <pre><code>import serial
  ser = serial.Serial('/dev/cu.usbserial-A901HOQC')
  ser.baudrate = 57600
  
  msg = 'ZANE:1:00004:XX_X.X_XXXX_000XX:\r\n'
  </code></pre>
  
  <p>If I write: </p>
  
  <pre><code>&gt;&gt;&gt; ser.write(msg)
  </code></pre>
  
  <p>the answer will be <code>33</code>, which is the length in byte of the message I'm sending.</p>
  
  <p>How can I receive the answer? The connected device will answer just after he gets the message, but if I type </p>
  
  <pre><code>&gt;&gt;&gt; ser.write(msg); ser.readline()
  </code></pre>
  
  <p>the result will be that <code>readline</code> never gets any message at all...</p>
  
  <p>any ideas? </p>