update for rpi
This commit is contained in:
parent
4aa63fd4ec
commit
b5ee85acea
1 changed files with 12 additions and 2 deletions
|
|
@ -3,10 +3,20 @@
|
|||
|
||||
import time
|
||||
import board
|
||||
import busio
|
||||
|
||||
# baud rate for your device
|
||||
baud = 38400
|
||||
# Initialize UART for the CH9328
|
||||
# check for Raspberry Pi
|
||||
# pylint: disable=simplifiable-condition
|
||||
if "CE0" and "CE1" in dir(board):
|
||||
import serial
|
||||
|
||||
uart = serial.Serial("/dev/ttyS0", baudrate=baud, timeout=3000)
|
||||
# otherwise use busio
|
||||
else:
|
||||
import busio
|
||||
|
||||
uart = busio.UART(board.TX, board.RX, baudrate=baud)
|
||||
|
||||
print("Enter commands to send to the RS-232 device. Press Ctrl+C to exit.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue