Skip to content

Instantly share code, notes, and snippets.

@matt448 matt448/serialtest.py
Last active Aug 29, 2015

Embed
What would you like to do?
Python script to test the CAN data sent by the Trinket CAN to UART converter
#!/usr/bin/python
##########################################
# https://matthewcmcmillan.blogspot.com
# Twitter: @matthewmcmillan
#
# For the most up to date version of this file see:
# https://github.com/matt448/Digital_Dash_v2/blob/master/serialtest.py
#
import serial
import os.path
from time import sleep
import Adafruit_BBIO.UART as UART
#Start serial connection with Arduino UART
#Create device if it doesn't exist.
if os.path.exists('/dev/ttyO1'):
ser = serial.Serial('/dev/ttyO1', 115200, timeout=2)
else:
UART.setup("UART1") #This creates the serial device
ser = serial.Serial('/dev/ttyO1', 115200, timeout=2)
while True:
line = ser.readline()
print(line)
sleep(0.025)
ser.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.