title: Sending data to serial with pyserial - Work on Razor 9DOF IMU
body: <p>I'm currently workng on a <strong>IMU Razor 9DOF</strong><br>
  I can read data from it by reading <em>/dev/ttyUSB0</em>. (default mode is YPR = angles of the IMU)<br>
  I can also change the data i'm receiving by sending <strong>#ot</strong> or <strong>#osrt</strong> to the IMU via the Arduino's Serial Monitor.  </p>
  
  <p>So I'm trying to write a code in Python3 to do both reading and changing mode via the same interface (and also using python3 to process the data).<br>
  Here are my issues:<br>
  <strong>1.</strong> I am using pyserial to read data from the port. Here is my code:
  </p>
  
  <pre><code>    from serial import *
      usb = Serial('/dev/ttyUSB0', 57600)
      while True:
         usb.readline()
  
      print()
  </code></pre>
  
  <p>When I try to run this code via python console it runs perfectly, but when I try doing it from the script (python3 mycode.py) it doesn't work.<br>
  I don't understand why.  </p>
  
  <p><strong>2.</strong> I try to change the mode by sending the command '#osrt' by using 
  </p>
  
  <pre><code>    usb.write(byte("#osrt", "utf8"))
  </code></pre>
  
  <p>but it only returns the length of data written without changing the mode.</p>
  
  <p>Thank You For Your Help ! </p>