title: Reading data over RS-485 with pySerial
body: <p>I'm working on a project where I need a microcontroller to transmit data to a computer over RS-485. I have a USB to RS422/485 adapter, with the adapter's DATA+ and DATA- pins connected to my board's RS-485A and RS-485B pins. The microcontroller is sending 8-bit packets with start and stop bits at a baudrate of 9600. As a test case, I have the packets in groups of 4, containing the data 0x00, 0x01, 0x02, 0x03. Yet when I try to read the serial data with something like</p>
  <pre><code>import serial
  ser = serial.Serial('/dev/ttyUSB0')
  ser.rs485_mode
  ser.timeout = 0.01
  ser.open()
  ser.read(4)
  ser.close()
  </code></pre>
  <p>there's no consistency in what I read. Results range from b'\x00\x01\x02\x03' to b'\x02\x03\x00\x00' or even b'\x01\x02\x06\x00' . My best guess is it's a flow control issue, with the program not knowing to wait for or not knowing how to interpret start and stop bits. What can I do to troubleshoot this?</p>