Yeah it’s been a while since the last update, but I didn’t know if it was a newly purchased RVR.
Since we know your UART can talk to itself, there are basically two paths left:
Path 1: Investigate the Pi UART for possible baud rate issues
This blog has some details about variable baud rates with the default “mini UART” on the Pi, and different options for correcting it.
If you happen to have an oscilloscope or logic analyzer you could also measure the baud rate on the TX pin of the Pi. It should be 115200 to work with RVR.
Path 2: Test RVR with a 3.3V USB-serial adapter
If you have a 3.3V USB-serial adapter on hand (could be FTDI, CP210x, CH340, etc as long as it supports 115200 baud), you can use that to verify the RVR UART. This could be done from the Pi or any other computer. Here are a couple of example packets that you can send with your terminal of choice:
// Echo the payload {0x11 0x22 0x33 0x44} from the Nordic BLE processor
0x8D 0x3A 0x11 0x01 0x10 0x00 0xAA 0x11 0x22 0x33 0x44 0x55 0xFA 0xD8
// Echo the payload {0x11 0x22 0x33 0x44} from the ST processor
0x8D 0x3A 0x12 0x01 0x10 0x00 0xAA 0x11 0x22 0x33 0x44 0x55 0xF9 0xD8
Alternatively, you can select a different TTY device in any SDK script, by including the optional port_id
parameter in the constructor for the SerialAsyncDal
object.
class SerialAsyncDal(SpheroDalBase, SerialSpheroPort):
"""
"""
def __init__(self, loop=None, port_id='/dev/ttyS0', baud=115200):
SpheroDalBase.__init__(self)
SerialSpheroPort.__init__(
self,
loop,
1,
Parser,
Handler,
port_id,
baud
)
Alternate port selection would look something like this (this is based on `getting_started/asyncio/leds/set_all_leds.py. I have not tested it as I don’t have enough time to set up a Pi right now)
import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../')))
import asyncio
from sphero_sdk import SpheroRvrAsync
from sphero_sdk import Colors
from sphero_sdk import RvrLedGroups
from sphero_sdk import SerialAsyncDal
loop = asyncio.get_event_loop()
rvr = SpheroRvrAsync(
dal=SerialAsyncDal(
loop=loop,
port_id='/dev/ttyForMyFtdiBreakoutOrWhatever'
)
)
async def main():
""" This program demonstrates how to set the all the LEDs.
"""
await rvr.wake()
# Give RVR time to wake up
await asyncio.sleep(2)
await rvr.set_all_leds(
led_group=RvrLedGroups.all_lights.value,
led_brightness_values=[color for _ in range(10) for color in Colors.off.value]
)
# Delay to show LEDs change
await asyncio.sleep(1)
await rvr.set_all_leds(
led_group=RvrLedGroups.all_lights.value,
led_brightness_values=[color for x in range(10) for color in [0, 255, 0]]
)
# Delay to show LEDs change
await asyncio.sleep(1)
await rvr.close()
if __name__ == '__main__':
try:
loop.run_until_complete(
main()
)
except KeyboardInterrupt:
print('\nProgram terminated with keyboard interrupt.')
loop.run_until_complete(
rvr.close()
)
finally:
if loop.is_running():
loop.close()
Let me know how it goes
Jim