Skip to content

Instantly share code, notes, and snippets.

@matt448
Last active July 16, 2020 19:45
Show Gist options
  • Save matt448/65ca3fee006e0ae6596f to your computer and use it in GitHub Desktop.
Save matt448/65ca3fee006e0ae6596f to your computer and use it in GitHub Desktop.
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