title: Pyserial writes data but does not read
body: <p>I'm relatively new to programming, so bear with me. I'm trying to communicate with the measurement device METEX M-4650CR <a href="https://sigrok.org/wiki/Voltcraft_M-4650CR" rel="nofollow">https://sigrok.org/wiki/Voltcraft_M-4650CR</a> and I'm using a windows 7 64bit OS. I simply want to read out the data the device measures to my python procedure and display it and calculate with it.</p>
  
  <p>I found in the manual <a href="http://elektron.pol.lublin.pl/elekp/labor_instr/METEX_M-4650CR_Manual.pdf" rel="nofollow">http://elektron.pol.lublin.pl/elekp/labor_instr/METEX_M-4650CR_Manual.pdf</a> (page 25ff), that it works with a <strong>baudrate of 1200</strong>, a <strong>bytesize of 7</strong> (with ASCII coding) and <strong>2 stopbits</strong>. </p>
  
  <p>Furthermore, it can be requested to send data to the computer by simply giving it the command "M". It then returns <strong>14 bytes</strong> to the computer. Without anything to measured connected to it, it should return something like 'DC 00.0000V  CR'. CR is the terminator here (I hope that is the right name).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import pyserial
  import time
  
  ser = serial.Serial(port='COM5', baudrate=1200, 
                      bytesize=7, stopbits=2, timeout=1, 
                      rtscts=False, dsrdtr=True)
  
  time.sleep(1)
  ser.write("M")
  time.sleep(1)
  bytestoread = ser.inWaiting()
  print bytestoread
  
  output = ''
  output += ser.read(1000)
  print 'output:' + str(output)
  
  time.sleep(1)
  ser.close()
  </code></pre>
  
  <p>My problem is, that I cannot read out the data properly with pyserial. I send the command "M" to the METEX and in the display it says 'send' for a short moment, so I guess my write command works fine. But after that (it should have send the data), all I get when from <code>ser.inWaitung</code> is '0L' or '1L' and the <code>ser.read</code> command gives nothing at all.</p>
  
  <p>I don't think it is a problem of the hardware, because with another programme, called 'serialwatcher', I'm able read out the data correctly. It gives exactly the characters described in the manual.</p>
  
  <p>I also tried the following while loop, having the problem, that most of the time <code>inWaiting == 0</code>, such that it never initialises the loop.</p>
  
  <pre><code>while ser.inWaiting() &gt; 0:
      output += ser.read(1)
  if output != '':
      output = outpus.rstrip()
      print output
  </code></pre>
  
  <p>So, how can I read out the data correctly, that were send to the serial port? Thanks in advance.</p>