title: python serial data read code with carriage return \r
body: <p>This is my working code to read the data from the Artix-7 serial port. But it comes form the carriage return. Like;</p>
  
  <pre><code>'FFFDB03\r'
  'FFFFB606'
  '\r00006C0'
  'D\rFFFFD8'
  '1B\rFFFFB'
  '037\r0000'
  '606F\rFFF'
  'FC0DF\rFF'
  'FF81BE\r0'
  '000037D\r'
  </code></pre>
  
  <p>how to solve this, can I set the CR and LF in the serial.Serial() settings. If anyone knows please reply</p>
  
  <pre><code>#!/usr/bin/python
  import serial, time
  
  ser = serial.Serial()
  ser.port = "/dev/ttyUSB0"
  ser.baudrate = 115200
  ser.bytesize = serial.EIGHTBITS 
  ser.parity = serial.PARITY_NONE 
  ser.stopbits = serial.STOPBITS_ONE              
  ser.xonxoff = False    
  ser.rtscts = False    
  ser.dsrdtr = False  
  
  try: 
      ser.open()
  except Exception, e:
      print "error open serial port: " + str(e)
      exit()
  
  if ser.isOpen():
      try:
          ser.flushInput()
          ser.flushOutput()
  
          while True:
              print repr(ser.read(8))
      except Exception, e1:
          print "error communicating...: " + str(e1)
  else:
      print "cannot open serial port "
  </code></pre>