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.
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).