selyunin / bno055_usb_stick_py

BNO055 USB Stick Linux Python 3 Driver
MIT License
12 stars 2 forks source link

Receiving packet failed! #1

Closed svanya closed 5 years ago

svanya commented 5 years ago

root@elon:~# python3.6 test_bno055.py Traceback (most recent call last): File "test_bno055.py", line 4, in bno_usb_stick.activate_streaming() File "/home/stefan/.local/lib/python3.6/site-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 355, in activatestreaming ok, = self.send_recv(bytearray(command), params) File "/home/stefan/.local/lib/python3.6/site-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 119, in send_recv raise BnoException("Receiving packet failed!") bno055_usb_stick_py.bno055_usb_stick.BnoException: Receiving packet failed!

selyunin commented 5 years ago

Hi Stefan,

How can one reproduce this problem?

Also, (1) Did you try to unplug and then re-plug the BNO USB Stick? (2) Did single register read work?

svanya commented 5 years ago

Hi Konstantin, (1) I tried replug many times. (2) Single register read works. Output is: "bno chip id addr: 0, value: 160"

I have RED BNO USB STICK with USB 3.0

Output from lsusb: Bus 002 Device 004: ID 152a:80c1 Thesycon Systemsoftware & Consulting GmbH

Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 2 Communications bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x152a Thesycon Systemsoftware & Consulting GmbH idProduct 0x80c1 bcdDevice 1.00 iManufacturer 1 Bosch Sensortec iProduct 2 Bosch Sensortec BNO stick iSerial 3 001 bNumConfigurations 1

selyunin commented 5 years ago

Unfortunately I cannot reproduce this problem until now. I have "red" BNO USB Stick. (1) Which PCB color BNO USB Stick you have (green / red)? (2) Can you post output from udevadm info -q all /dev/ttyACM0 where /dev/ttyACM0 is your device corresponding to BNO USB Stick? (3) What client script are you using for streaming data? I.e. what does your script test_bno055.py contain? (4) What is your OS, Python versions? (5) Does burst read works for you? I.e. does code like below executes correctly:

from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
burst_read_result = bno_usb_stick.burst_read(0x00, 30)
print(burst_read_result)
selyunin commented 5 years ago

OK, I was able to reproduce and fix the issue -- the updated version is 0.9.3

To get the fix at your side:

1) Update to the latest package version (0.9.3):

pip install -U bno055_usb_stick_py

2) Check the version is 0.9.3:

pip freeze | grep -Ei bno055-usb-stick-py

3) Try streaming mode. I included examples into the README.md

svanya commented 5 years ago

It's working now! Both streaming mode (generator and single packets).

But sometimes ended with another error (both mode):

GENERATOR: root@elon:# python3.6 test_bno055.py bno data: BNO055(a_raw=(-182, -3, 961), g_raw=(-4, 11, -3), m_raw=(-68, -78, -489), euler_raw=(4555, -182, 4), quaternion_raw=(12911, -1027, 1260, 9955), lin_a_raw=(11, 2, 1), gravity_raw=(-193, -5, 961), a=(-1.82, -0.03, 9.61), g=(-0.25, 0.6875, -0.1875), m=(-4.25, -4.875, -30.5625), euler=(284.6875, -11.375, 0.25), quaternion=(0.78802490234375, -0.06268310546875, 0.076904296875, 0.60760498046875), lin_a=(0.11, 0.02, 0.01), gravity=(-1.93, -0.05, 9.61), temp=39, calib_stat=48, st_result=15, int_sta=0, sys_clk_status=0, sys_status=0, quaternion_resolution=6.103515625e-05, acceleration_resolution=0.01, magnetometer_resolution=0.0625, gyroscope_resolution=0.0625, linear_acceleration_resolution=0.01, gravity_resolution=0.01, euler_resolution=0.0625) Traceback (most recent call last): File "test_bno055.py", line 5, in for packet in bno_usb_stick.recv_streaming_generator(num_packets=10): File "/usr/local/lib/python3.6/dist-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 282, in recv_streaming_generator yield self.recv_streaming_packet() File "/usr/local/lib/python3.6/dist-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 270, in recv_streaming_packet self.check_streaming_packet() File "/usr/local/lib/python3.6/dist-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 253, in check_streaming_packet raise BnoException(f"Streaming packet length does not match, expected: 0x38, got {len(self.buffer)}") bno055_usb_stick_py.bno055_usb_stick.BnoException: Streaming packet length does not match, expected: 0x38, got 112 root@elon:#

SINGLE PACKETS: ... BNO055(a_raw=(-195, 0, 953), g_raw=(2, -22, 1), m_raw=(-67, -65, -510), euler_raw=(4564, -169, 1), quaternion_raw=(12965, -925, 1196, 9902), lin_a_raw=(-12, 2, -3), gravity_raw=(-180, -1, 964), a=(-1.95, 0.0, 9.53), g=(0.125, -1.375, 0.0625), m=(-4.1875, -4.0625, -31.875), euler=(285.25, -10.5625, 0.0625), quaternion=(0.79132080078125, -0.05645751953125, 0.072998046875, 0.6043701171875), lin_a=(-0.12, 0.02, -0.03), gravity=(-1.8, -0.01, 9.64), temp=39, calib_stat=48, st_result=15, int_sta=0, sys_clk_status=0, sys_status=0, quaternion_resolution=6.103515625e-05, acceleration_resolution=0.01, magnetometer_resolution=0.0625, gyroscope_resolution=0.0625, linear_acceleration_resolution=0.01, gravity_resolution=0.01, euler_resolution=0.0625) Traceback (most recent call last): File "test_bno055_4.py", line 5, in packet = bno_usb_stick.recv_streaming_packet() File "/usr/local/lib/python3.6/dist-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 270, in recv_streaming_packet self.check_streaming_packet() File "/usr/local/lib/python3.6/dist-packages/bno055_usb_stick_py/bno055_usb_stick.py", line 253, in check_streaming_packet raise BnoException(f"Streaming packet length does not match, expected: 0x38, got {len(self.buffer)}") bno055_usb_stick_py.bno055_usb_stick.BnoException: Streaming packet length does not match, expected: 0x38, got 112 root@elon:#

selyunin commented 5 years ago

Hi, Hopefully fixed the error with streaming packets. Please update to the latest version 0.9.5 and see whether you still get the problem.

svanya commented 5 years ago

Great! It works without any errors. Thank you :-)

selyunin commented 5 years ago

Great, closing the issue then!