VEX V5 Brain Crash (while using VEX Serial)

Update: I think we were getting ValueError because we were relying too much on Serial Port to give the right commands and not countering for garbage.

image

I have started to add more checks, like making sure that the input strings are at least same size or longer than the strings we are comparing with. Also if the command arguments recieved with the commands are right type (e.g. angle.isdigit() etc.). Here are examples of the checks I added:

image

Thank you for the help.

I’m interested in what you were using as your command sequences. Are they things like CMS_START = “START”?

I’m also interested in the data you are sending. Is it binary data? Like 15 would be 1111 or would it be “15”. I’m looking at the Status Message STX,EXT!xC0,x80 STX would be x02 and ETX would be x03.

This chart https://en.wikipedia.org/wiki/Control_character has the mappings to other control characters. When I’ve done data between systems, using binary has tripped me up more times than I’d like to admit on a public robotics forum.

Are you running with the RobotMesh debugger disabled ? It sounds a bit like your messages may be being interpreted by some code in the Python VM.

@RobotMesh

7 Likes

Yes the debugger is disabled. My partner BotWorld, is more experienced with VEX than I am. I help her with mostly Linux usage and Python coding…

How do we enable the debugger?

I don’t use RobotMesh often, but I think you just select different download methods from the dropdown. The debugger uses the same USB serial link you have going to the RasPi.

image

9 Likes

Did some troubleshooting with Andy8Kahn and BotWorld offline. In case anyone has a similar problem: Exception: 0xEE Value error is thrown when the int() builtin is given a value it can’t parse.

For a contrived example, int('13') will return 13 just fine, but int('thirteen') will blow up. It also cannot handle hex notation when given as a string: int(0x13) correctly returns 19, (probably because the tokenizer is canonicalizing it) but int('0x13') dies with Value error. This is identical behavior to CPython.

5 Likes

Nice catch, and thanks for the update on what the fix. I often wish that people would report back on the fix so the rest of us can learn.

1 Like

for anyone using VEXcode python (which is based on micropython so nothing I did that micropython wouldn’t do), it at least handles the int('0x13') case

MicroPython v1.12-164-g7708f98 on 2020-08-17; Vex V5 with Zynq (v0.2)
Type "help()" for more information.
>>> 
>>> int(0x13)
19
>>> int('0x13')
19
>>> int('thirteen')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid syntax for integer
>>> 
4 Likes

Thank you. I see the options now.

We are sending string commands, converted to /from ByteArray and passing it to Serial Port Buffer using vex.brain.serial class (https://www.robotmesh.com/studio/content/docs/vexv5-python/html/classvex_1_1_serial.html).

e.g. “START” = [0x53, 0x53, 0x41, 0x52, 0x53]

On Pi I use vex_user_port.write( cmd_str.encode() ) to send messages to VEX ( code uses Pyton3 PySerial)
The other character on error after STX ETX is NULL
image
image

3 Likes