Skip to content

Instantly share code, notes, and snippets.

@taotao
Created October 6, 2016 07:55
Show Gist options
  • Save taotao/84b25e75b3c9f4a0983ec318576efbf4 to your computer and use it in GitHub Desktop.
Save taotao/84b25e75b3c9f4a0983ec318576efbf4 to your computer and use it in GitHub Desktop.
Use pyserial to send serial data
#!/usr/bin/env python
import serial
import binascii
ser=serial.Serial('/dev/ttyM0', baudrate=38400, timeout=1)
ser.write(binascii.unhexlify('010200010001e80a'))
r = ser.read(16)
if r is not None:
print repr(binascii.hexlify(r))
ser.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment