Serial communication with using Robot Mesh

Hello there,
I am currently trying to use Robot Mesh Studio’s python API with the Vex V5, and more specifically, its vex.Serial function. But have not been successful. Everytime I try to run the Serial function, Robotmesh returns an error pointing to the first line that I try to use Serial.

I simply want the Vex bot to move its motor(s) based on what I send the bot through the usb connection (which I connected to a Jetson Nano that outputs ‘Yes’ or ‘No’ strings through serial communication).
And simpler than that, I am first trying to print on the Vex Brain screen what I am sending to the brain from the Jetson through the USB cable.

Here is the code I have so far, partly dug from other forums, but it does not work (any help in using vex.Serial is greatly appreciated:)

VEX V5 Python Project

import sys
import vex
import string
from vex import *

#region config
v5_brain = vex.Brain()
v5_ser = vex.Serial(v5_brain)
motor_1 = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False)
motor_3 = vex.Motor(vex.Ports.PORT3, vex.GearSetting.RATIO18_1, False)
motor_8 = vex.Motor(vex.Ports.PORT8, vex.GearSetting.RATIO18_1, False)
motor_10 = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, False)
#endregion config

if v5_ser.has_data():
data = bytearray(128)

What error does it print?


When I use 'Run Fast:…" and build and upload the program without the debugger, the brain seems to run it without the error… but it still isn’t receiving or printing out anything on the screen.

No need to instantiate a new Serial object, just use v5_brain.serial directly.

Example project that writes foo to the USB port once a second:

Separately, when you select “run fast” it does not start the debugger. This means it will not display whatever errors the brain is trying to print. The error is still there, you just can’t see it.

Ah I see. I played around with it more, but I still haven’t gotten the brain to input any data from the serial port… I also get a display of in a red rectabgle on the Brain: ‘Memory Permission error ! 06049A88’ when I run the program while it is plugged into my computer. This too, after running while plugged into the computer:

If I unplugg it and run it, it only runs for about 1 sec and stops.

I tried the code you provided, and I believe it runs perfectly, except I couldn’t get the ‘foo’ to print onto a computer screen (does the Baud rate have an effect on this… I receiving on both 9600 and 115200, but was only receiving ‘b’’ no matter what I replace ‘foo’ with.

Greatly appreciate your help and effort btw:o

If you have any exception errors, the program is broken, and will not run. You must fix those first.

Due to the wide variety of serial terminals, we do not provide technical support for reading or writing serial data from the V5 brain. Also note that communicating with a V5 brain during a competition match is not legal under VRC rules.

Important note that if you click Run instead of Run Fast, Robot Mesh Studio will open the debugger, and hold the serial port open. You will not be able to read or write to that port with a separate program. If there is conflict between multiple programs trying to talk on the same COM port, you will need to close and restart them.

If you choose Run Fast, you will not see exceptions or program errors, so you will be programming in the blind, without feedback. This makes using the serial ports difficult. There isn’t really any way around this.