We're having a lot of difficulty using the serial port on the cRio to interface with devices.
- Console out switch is off.
- Tried with an RS232 compass sensor
- Tried with an Arduino spitting out a single byte in a loop
- Confirmed correct serial data on both devices with a logic analyzer and Portmon
When running some very simple code (I sure hope I'm just doing something wrong) - the cRio will read some data (
slowly) and then crash.
Code:
virtual void TeleopPeriodic() {
int n = com.GetBytesReceived();
if (n > 0) {
char *buffer;
printf("Reading\n");
com.Read(buffer, n);
printf("Done reading\n");
for (int i = 0; i < n; i++) {
printf("%d 0x%X\n", n, buffer[i]);
}
}
Screenshot attached.