I'm trying to read BNO08x data via UART on a Single Board Computer running Ubuntu 22.04. The problem is that the driver fails during initialization and I think I tracked the error down to a faulty init routine in __init__.py:
def initialize(self) -> None:
"""Initialize the sensor"""
for _ in range(3):
self.hard_reset()
self.soft_reset()
try:
if self._check_id():
break
except BaseException as e: # pylint:disable=bare-except
print(e)
time.sleep(0.5)
else:
raise RuntimeError("Could not read ID")
My test program is bno08x_simpletest_uart.py with some setup changes (baudrate 3000000, adjusted serial port and debug=True):
# SPDX-FileCopyrightText: 2020 Bryan Siepert, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import adafruit_bno08x
from adafruit_bno08x.uart import BNO08X_UART
import board # pylint:disable=wrong-import-order
import busio # pylint:disable=wrong-import-order
#uart = busio.UART(board.TX, board.RX, baudrate=3000000, receiver_buffer_size=2048)
# uncomment and comment out the above for use with Raspberry Pi
import serial
uart = serial.Serial("/dev/ttyS4", 3000000)
# for a USB Serial cable:
# import serial
# uart = serial.Serial("/dev/ttyUSB0", baudrate=115200)
bno = BNO08X_UART(uart, reset=None, debug=True)
bno.enable_feature(adafruit_bno08x.BNO_REPORT_ACCELEROMETER)
bno.enable_feature(adafruit_bno08x.BNO_REPORT_GYROSCOPE)
bno.enable_feature(adafruit_bno08x.BNO_REPORT_MAGNETOMETER)
bno.enable_feature(adafruit_bno08x.BNO_REPORT_ROTATION_VECTOR)
...
Now when I run the program it stops with an error Could not read ID (full debug output below). Note that I have printed out the actual exception coming from self.check_id() as it would not have been visible in the original program (in the above printed initialize method). So I found this exception to be Didn't find packet end thrown in uart.py in the _read_packet method: https://github.com/adafruit/Adafruit_CircuitPython_BNO08x/blob/cfefd9430ffd67d5b912eb1ea7bfa08a859371a8/adafruit_bno08x/uart.py#L138
What I believe happens is that the soft_reset method in uart.py is sending out a couple of packets which somehow cause the check_id method to fail. Further, when the check_id method sends out the command to read the product id, the response is read by the soft_reset in the next turn of the for loop. So the response will never be available in the check_id method. Thus, this whole init method fails. The simplest way to solve this is to comment out this line: https://github.com/adafruit/Adafruit_CircuitPython_BNO08x/blob/cfefd9430ffd67d5b912eb1ea7bfa08a859371a8/adafruit_bno08x/__init__.py#L523
The question is: What is this soft_reset good for? Is it safe to disable?
Thank you for any advice.
Hi all
I'm trying to read BNO08x data via UART on a Single Board Computer running Ubuntu 22.04. The problem is that the driver fails during initialization and I think I tracked the error down to a faulty init routine in
__init__.py
:My test program is
bno08x_simpletest_uart.py
with some setup changes (baudrate 3000000, adjusted serial port and debug=True):Now when I run the program it stops with an error
Could not read ID
(full debug output below). Note that I have printed out the actual exception coming fromself.check_id()
as it would not have been visible in the original program (in the above printedinitialize
method). So I found this exception to beDidn't find packet end
thrown inuart.py
in the_read_packet
method: https://github.com/adafruit/Adafruit_CircuitPython_BNO08x/blob/cfefd9430ffd67d5b912eb1ea7bfa08a859371a8/adafruit_bno08x/uart.py#L138 What I believe happens is that thesoft_reset
method inuart.py
is sending out a couple of packets which somehow cause thecheck_id
method to fail. Further, when thecheck_id
method sends out the command to read the product id, the response is read by thesoft_reset
in the next turn of the for loop. So the response will never be available in thecheck_id
method. Thus, this whole init method fails. The simplest way to solve this is to comment out this line: https://github.com/adafruit/Adafruit_CircuitPython_BNO08x/blob/cfefd9430ffd67d5b912eb1ea7bfa08a859371a8/adafruit_bno08x/__init__.py#L523The question is: What is this
soft_reset
good for? Is it safe to disable? Thank you for any advice.