Last active
January 15, 2016 00:39
-
-
Save rogovski/c6f5d71399963f9f01a3 to your computer and use it in GitHub Desktop.
pi serial
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
| # stop | |
| sudo systemctl stop serial-getty@ttyAMA0.service | |
| # disable | |
| sudo systemctl disable serial-getty@ttyAMA0.service | |
| # set baud | |
| stty -F /dev/ttyAMA0 9600 |
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 time | |
| import serial | |
| ser = serial.Serial( | |
| port='/dev/ttyUSB0', | |
| baudrate = 9600, | |
| parity=serial.PARITY_NONE, | |
| stopbits=serial.STOPBITS_ONE, | |
| bytesize=serial.EIGHTBITS, | |
| timeout=1 | |
| ) | |
| counter=0 | |
| while 1: | |
| x=ser.readline() | |
| print x |
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 time | |
| import serial | |
| ser = serial.Serial( | |
| port='/dev/ttyAMA0', | |
| baudrate = 9600, | |
| parity=serial.PARITY_NONE, | |
| stopbits=serial.STOPBITS_ONE, | |
| bytesize=serial.EIGHTBITS, | |
| timeout=1 | |
| ) | |
| counter=0 | |
| while 1: | |
| ser.write('Write counter: %d \n'%(counter)) | |
| time.sleep(1) | |
| counter += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment