|
|
- #!/usr/bin/python2.7
- import serial
- import os
- import string
-
-
- #button0 = "User Pressed button: 0"
-
-
-
- ser = serial.Serial(
- port='/dev/ttyUSB0',\
- baudrate=9600,\
- parity=serial.PARITY_NONE,\
- stopbits=serial.STOPBITS_ONE,\
- bytesize=serial.EIGHTBITS,\
- #timeout=None) #doesn't work
- timeout=0)
-
- line = []
-
- print("connected to: " + ser.portstr)
-
- while True:
- # line = ser.readline(); #this adds extra new lines in random spots, wut
- # line = ser.read().splitlines() #this makes everything like \g in mysql
- # line = ser.read().rstrip('\n') #does similar to above, without brackets
- line = ser.readline().rstrip('\n') # this fails to remove line breaks. fuck pyserial
- if line:
- # print(line.splitlines()) # also doesn't work
- print(line)
-
- #ser.close()
|