Created
October 6, 2016 07:55
-
-
Save taotao/84b25e75b3c9f4a0983ec318576efbf4 to your computer and use it in GitHub Desktop.
Use pyserial to send serial data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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