Skip to content

Commit

Permalink
Merge pull request #203 from lurch/pi5_fix
Browse files Browse the repository at this point in the history
Fix Build HAT library to work on Raspberry Pi 5
  • Loading branch information
grega authored Nov 23, 2023
2 parents eeffd9d + 4f0ac08 commit b29ee3f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions buildhat/serinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import tempfile
import threading
import time
import os
from enum import Enum
from threading import Condition, Timer

Expand Down Expand Up @@ -105,6 +106,11 @@ def __init__(self, firmware, signature, version, device="/dev/serial0", debug=Fa
self.rampftr.append([])
self.motorqueue.append(queue.Queue())

# On a Pi 5 /dev/serial0 will point to /dev/ttyAMA10 (which *only*
# exists on a Pi 5, and is the 3-pin debug UART connector)
# The UART on the Pi 5 GPIO header is /dev/ttyAMA0
if device == "/dev/serial0" and os.readlink(device) == "ttyAMA10":
device = "/dev/ttyAMA0"
self.ser = serial.Serial(device, 115200, timeout=5)
# Check if we're in the bootloader or the firmware
self.write(b"version\r")
Expand Down

0 comments on commit b29ee3f

Please sign in to comment.