VEX U

you can also use standard C stdio API, this examples shows how to do that


#include <stdio.h>
#include "robot-config.h"
          
using namespace vex;

int main() {
    // IO using stdio
    //**********************
    FILE *fp1, *fp2;
    fp1 = fopen( "/dev/port20", "wb" );
    fp2 = fopen( "/dev/port18", "rb" );
    while(1) {
      if( fp1 != NULL ) {
        fprintf(fp1, "Hello\r\n");
        fflush(fp1);
      }
      if( fp2 != NULL ) {
        char buf[128];
        int nRead = fread( buf, 1, 128, fp2 );
        if( nRead > 0 ) {
          for(int i=0;i<nRead;i++) {
            printf("%02X ", buf*);
          }
          printf("\n");
        }
      }
    this_thread::sleep_for(10);
    }
}

In this case the characters I’m reading are sent using printf to the second serial port (that’s USB serial, the V5 USB shows as two serial ports on your computer, the first is dedicated to admin and program download, the second is for user code to use) that the V5 has, you would need a suitable terminal program to see the output (for example, on OSX I use screen )*