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:
    VEX V5 Python API: vex.Serial Class Reference
    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)?

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…

1 Like

Does anyone know the PROS api to read serial data? or can this only be done using python.

1 Like

Hmm I saw that too but the API is only for smart ports and not thru usb. :C

1 Like

Awe man, sorry. Typing in “USB” into the PROS api only one result comes up, which doesn’t seem remotely close to the question:
https://pros.cs.purdue.edu/v5/tutorials/general/debugging.html?highlight=usb

1 Like