Skip to content

Instantly share code, notes, and snippets.

@rogovski
Last active January 15, 2016 00:39
Show Gist options
  • Select an option

  • Save rogovski/c6f5d71399963f9f01a3 to your computer and use it in GitHub Desktop.

Select an option

Save rogovski/c6f5d71399963f9f01a3 to your computer and use it in GitHub Desktop.
pi serial
# stop
sudo systemctl stop serial-getty@ttyAMA0.service
# disable
sudo systemctl disable serial-getty@ttyAMA0.service
# set baud
stty -F /dev/ttyAMA0 9600
#!/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
#!/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