Need help figuring out the serial connection for PROS

Howdy,
I have searched far and wide to try to find information about a serial connection. However, I’m struggling to find information about the following topic.

In VEXCode, I know I can read “/dev/serial1” using fopen, however I am unsure how to read the USB serial for PROS.

I read the following but there’s not really any additional detail for what serial connection to use for PROS.

https://pros.cs.purdue.edu/v5/tutorials/topical/filesystem.html?highlight=serial

Looking through our source code, it would appear that what you are looking for is this:
image

you should be able to fopen("sout","w") to write to the standard output, or you can fopen("sinp", "r") to read the standard input.

Hopefully this helps.

3 Likes

Thank you! <20chars>

What is the difference between doing something like this and just using count?

Do you mean cout from namespace std?

yes, sorry autocorrect

To be honest my answer is kind of a flip flop.

I use fopen over cin because I can use the gnu++ features to decide whether or not I want fopen blocking or non-blocking. Cin is blocking which honestly I find it to be pretty unreliable when receiving data. Therefore by using fopen, configured as non-blocking, it is very helpful to continuously read the serial stream and combine every 5-10 milliseconds as I have coded my own buffer system that can flush incomplete data and also combine fragmented data into something that is complete if the size of the system’s buffer is full.

And because I use fopen instead of cin, I use fopen over cout for readability and consistency. Additionally, the VEX AI source code uses fopen over cout to ‘prevent data from being outputted to the terminal’ albeit I’ve had mixed results with such a comment they have made as sometimes it still goes displays outgoing serial outputs to the terminal (so i’m a bit confused about that).