Last active
July 16, 2020 19:45
-
-
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
This file contains 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/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