Stack overflow when trying to call observer 'wake'

I just started with Hello RVR - LED Control · Sphero Public SDK

(I added print statements to the script, otherwise as on the web page)

Brand new RVR, used 1. Python SDK Setup (Quick Start) · Sphero Public SDK

and I ended up with a stack overflow:

create observer
Checking RVR firmware versions…
call wake
Fatal Python error: Cannot recover from stack overflow.
Current thread 0x759cb440 (most recent call first):
File “/usr/lib/python3.7/posixpath.py”, line 42 in _get_sep
File “/usr/lib/python3.7/posixpath.py”, line 147 in basename
File “/usr/lib/python3.7/logging/init.py”, line 327 in init
File “/usr/lib/python3.7/logging/init.py”, line 1488 in makeRecord
File “/usr/lib/python3.7/logging/init.py”, line 1518 in _log
File “/usr/lib/python3.7/logging/init.py”, line 1395 in warning
File “/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/common/protocol/api_sphero_message.py”, line 421 in from_buffer
File “/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/observer/client/dal/observer_parser.py”, line 34 in __read
File “/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/observer/client/dal/observer_parser.py”, line 51 in __read
File “/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/observer/client/dal/observer_parser.py”, line 51 in __read
File “/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/observer/client/dal/observer_parser.py”, line 51 in __read
… (repeats)

I noted two things:

  1. api_sphero_message.py line 421 is trying to call logger.warning(‘Bad Checksum…’…)

  2. observer_parser.py (in _read) has a recursive call to _read which in this case looks to be the cause of the stack overflow. But perhaps this level of recursive calls is unusual and occurs only because of the checksum issue.

So perhaps I need to pay attention to the “Bad Checksum” warning.

Note: the Raspberry Pi also has a “Build HAT” attached. Per Raspberry Pi Documentation - Build HAT, the Build HAT uses GPIO pins 0/1, 4, 14, 15, 16, 17. But the RVR as I understand it uses pins 8, 10 and 12. So I don’t see any GPIO conflict in the documented pin usage.

Does someone have suggestions how I may resolve the issue?

Thanks in advance

1 Like

Rechecking the pins (https://pinout.xyz/), maybe there is a conflict.

RPi Build HAT uses GPIO 14&15, which are pins 8 and 10, also used by the RVR.

Has anyone else found a way to use Build HAT with RVR (to allow Lego sensors/motors to be attached to the RPi), or is it just incompatible?

1 Like

Maybe I can get the RPi to control the base unit via Bluetooth instead of using the GPIO connectors.

Has anyone tried this with Python (since the buildhat API is Python-based it would be helpful)?

1 Like

Hi @smartrvr,

The easiest way to connect your Pi to RVR without using the built-in UART pins on the Pi would be a USB-UART adapter. You’ll need to change the TTY that the SDK uses. I’m not at my computer right now, but if you take a look at the serial observer dal code you’ll see where the default TTY is specified.

I didn’t know about the Build Hat - I’ll need to pick up one of those.

Thanks very much Jim for the info.

For now I am trying out (instead of the Build HAT and Lego motor/sensor) using an HC-SR04 ultrasonic sensor and Tower Pro SG90 servo (to allow the ultrasonic sensor to sweep around).

I found that the Build HAT only gives sensor callbacks every 100 ms (e.g. for motor encoder position and ultrasonic distance reading), whereas using the HC-SR04 and servo I can get more measurements per second, therefore less chance of a collision.