Reading VEX V5 Serial Port using Python

I have connected a Raspberry Pi to the mini USB Port.
On Pi, if I list /dev, I see /dev/AMC0 and /dev/AMC1.

I have few questions:

  1. Rrom Pi, which of these ports should I send dsata to so I can read on VEX V5 Brain?

  2. What Baudrate, Stop Bits, Parity Options should I use?

  3. On the brain, how do I read this data using Python?

    I have looked at the following link for the API:
    https://www.robotmesh.com/studio/content/docs/vexv5-python/html/classvex_1_1_serial.html
    def init (self, parent)
    def write (self, data, null_terminate_string=True)
    def read (self, buffer)
    def has_data (self)

    I get an error trying to instantiate vex.Serial()
    What value of parent field should I use?

1 Like

are you using VEXcode Python or RobotMesh Python ?

for Q1, you would use /dev/AMC1
baudrate generally doesn’t matter that much as it’s USB, but use 115200, 8,N,1 if in doubt.

1 Like

Thank you for the reply.
I am new to VEX or Pi.
I do have some experience with Serial Communication using PySerial on Linux.
Keeping that in mind. what is Qi?
Also, if I set baudrate to something in pi, and send out data on /dev/AMC1, how does VEX synchronize without knowing the baudrate?
Lastly and most importantly, what is the parent field in: vex.Serial(parent) [ def init (self, parent) ]

Q1 ? I meant question 1, the answer is that you need to use /dev/AMC1 as that would be the serial port that user code can read.

are you using VEXcode Python or RobotMesh Python ?

I’m familiar with VEXcode Python but not RobotMesh, I can’t help you with that.

1 Like

Mostly Robot Mesh. But its the same.

Current Issue I am getting is when creating the object.
It might be because of missing input.
What is the parent input for vex.Serial(parent)?

Vex-Serial

Hm, very much not the same. There are some similarities but RobotMesh is based on Python 2.x and VEXcode Python on 3.x (full disclosure, I wrote the VEXcode Python VM).

I would say, based on the RobotMesh documentation, you should be using vex.Serial.write etc. directly and not try and create an instance of the class. but as I said, you need someone with more RobotMesh experience to respond.

9 Likes

The person I was working with told me that the problem can be fixed by passing an instance of the vex.Brain() as parent:

Based on that, I think the Alternative Way below, would work too…

Vex-Serial-1

1 Like