From 63e3a2f815a8d4c6e4013be9a98b58cf23f1b4d1 Mon Sep 17 00:00:00 2001 From: builderjer Date: Sat, 11 Jan 2025 09:17:27 -0700 Subject: [PATCH 1/3] fix no /dev/serial0 --- ovos_i2c_detection/__init__.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ovos_i2c_detection/__init__.py b/ovos_i2c_detection/__init__.py index 7fca441..d4d057e 100644 --- a/ovos_i2c_detection/__init__.py +++ b/ovos_i2c_detection/__init__.py @@ -1,6 +1,7 @@ import subprocess import serial from time import sleep +from pathlib import Path def is_texas_tas5806(): cmd = 'i2cdetect -y -a 1 0x2f 0x2f | egrep "(2f|UU)" | awk \'{print $2}\'' @@ -57,18 +58,24 @@ def is_adafruit_amp(): def is_mark_1(): if is_wm8960(): + SER_PORTS = ["serial0", "ttyS0", "ttyAMA0"] try: - ser = serial.Serial("/dev/serial0", 9600, timeout=3) - ser.write(b'system.version') - while True: - is_mk1 = ser.readline().decode().rstrip() - if is_mk1 and "Command" in is_mk1: + 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.close() - # This is a Mark 1 - return True - break - ser.close() - return False + ser.close() + return False except: return False From c29bec03eeb3bedceb84b555cb45f11a6ee92dd5 Mon Sep 17 00:00:00 2001 From: builderjer Date: Sat, 11 Jan 2025 09:28:53 -0700 Subject: [PATCH 2/3] updated README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 00a2c9a..4fb1bb6 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,5 @@ Currently you can get detection results for the following devices * `is_respeaker_6mic` * Adafruit audio amp (https://www.adafruit.com/product/1752) * `is_adafruit_amp` ++ Mycroft Mark 1 device + + `is_mark_1` From 20cc348b83f0a286d0f16694587a884ac8827fe8 Mon Sep 17 00:00:00 2001 From: builderjer Date: Sat, 11 Jan 2025 11:15:46 -0700 Subject: [PATCH 3/3] maybe a fix? --- ovos_i2c_detection/__init__.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ovos_i2c_detection/__init__.py b/ovos_i2c_detection/__init__.py index d4d057e..ebbeed6 100644 --- a/ovos_i2c_detection/__init__.py +++ b/ovos_i2c_detection/__init__.py @@ -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}\'' @@ -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