I've just got access to a 51515 Hub and I tried to connect to it as a serial port (with baudrate 115200), however it's spamming the console with motor/sensor data:
{"m":0,"p":[[62, [11]], [0, []], [0, []], [0, []], [0, []], [0, []], [-30, -9, 1008], [0, 0, 0], [0, 0, 1], "", 12105]}
{"m":0,"p":[[62, [11]], [0, []], [0, []], [0, []], [0, []], [0, []], [-30, -8, 1007], [0, 0, 0], [0, 0, 1], "", 12105]}
{"m":0,"p":[[62, [11]], [0, []], [0, []], [0, []], [0, []], [0, []], [-30, -8, 1006], [0, 0, 0], [0, 0, 1], "", 12105]}
{"m":0,"p":[[62, [11]], [0, []], [0, []], [0, []], [0, []], [0, []], [-30, -8, 1006], [0, 0, 0], [0, 0, 1], "", 12105]}
{"m":0,"p":[[62, [11]], [0, []], [0, []], [0, []], [0, []], [0, []], [-29, -7, 1007], [0, 0, 0], [0, 0, 1], "", 12105]}
{"m":0,"p":[[62, [11]], [0, []], [0, []], [0, []], [0, []], [0, []], [-30, -8, 1007], [0, 0, 0], [0, 0, 1], "", 12105]}
I found a few related posts:
- Spike Prime remote command using screen
- I've figured out how to access the Spike/Mindstorms 51515 hub serial ports (bluetooth and usb) from python
I haven't found any info related to the sensor data which is preventing me from inputting new commands via USB VCP. (My hunch is because I've connected via bluetooth and used the app the getting started exercises).
In this case, what's the easiest way to connect to the hub via USB VCP and use the Python REPL ?
Update
I've noticed that I can send Ctrl+C
(KeyboardInterrupt) via VCP and with a bit of luck on timing the spam stops and I can type commands prototype directly on the REPL.
I've also tried rshell. Initially, because of my unorthodox Python setup I couldn't run rshell. Even though it didn't get added to PATH
I could still run the command manually:
c:\users\george.profenza\.pyenv\pyenv-win\versions\3.6.4-amd64\Scripts\rshell.exe -p COM3
Using buffer-size of 512
Connecting to COM3 (buffer-size 512)...
Trying to connect to REPL connected
Testing if ubinascii.unhexlify exists ... Y
/ /commands/ /event_loop/ /mindstorms/ /programrunner/ /protocol/ /sounds/ /spike/ /ui/ /hub_runtime.mpy/ /version.py/ /.runtime_hash/ /etc/ /extra_files/ /.extra_files_hash/ /runtime.log/
Setting time ... Feb 05, 2022 01:01:53
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 2000
Welcome to rshell. Use the exit command to exit rshell.
I could list hub content, but I couldn't figure out how to start a REPL session to type Python commands for the hub to execute directly.
https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/pkg_hub.html