Skip to content

Commit

Permalink
maybe a fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
builderjer committed Jan 11, 2025
1 parent c29bec0 commit 20cc348
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions ovos_i2c_detection/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import subprocess
import serial
from time import sleep
from pathlib import Path
from ovos_utils.log import LOG

def is_texas_tas5806():
cmd = 'i2cdetect -y -a 1 0x2f 0x2f | egrep "(2f|UU)" | awk \'{print $2}\''
Expand Down Expand Up @@ -58,24 +58,24 @@ def is_adafruit_amp():

def is_mark_1():
if is_wm8960():
SER_PORTS = ["serial0", "ttyS0", "ttyAMA0"]
try:
for port in SER_PORTS:
s_port = Path(f"/dev/{port}")
if s_port.exists():
s_port = str(s_port)
ser = serial.Serial(s_port, 9600, timeout=5)
ser.write(b'system.version')
while True:
is_mk1 = ser.readline().decode().rstrip()
if is_mk1 and "Command" in is_mk1:
ser.close()
# This is a Mark 1
return True
break
ser = serial.Serial("/dev/ttyAMA0", 9600, timeout=5)
ser.write(b'system.version')
while ser.is_open:
is_mk1 = ser.readline().decode().rstrip()
if is_mk1 and "Command" in is_mk1:
# Check for a version
mk1_ver = ser.readline().decode().rstrip()
# New versions of the firmware will return a version that needs read to continue
if mk1_ver:
LOG.debug(f"Firmware version {mk1_ver}")
ser.close()
# This is a Mark 1
return True
ser.close()
return False
except:
ser.close()
return False
except Exception as e:
LOG.error(e)
return False

0 comments on commit 20cc348

Please sign in to comment.