I'm trying to read serial data printed by the Arduino with this C program -
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char *args []) {
char test;
FILE *serialPort;
system( "MODE COM4: BAUD=9600 PARITY=n DATA=8 STOP=1" );
serialPort = fopen("COM4:", "r" );
if (serialPort == NULL) {
printf ("Error: unable to open serial port COM4\n");
exit (1);
}
while (1) {
test = fgetc (serialPort);
if (test == EOF) {
printf ("End of file\n");
break;
}
printf ("%c", test);
}
fclose(serialPort) ;
return 0;
}
The problem is that it just stops when it gets to the fgetc line. It doesn't quit or anything, it just sits there with a blinking cursor. Is that because of an error with the code on my Arduino (it's just looping over 'Serial.print ("x");' over and over again), or is this method of reading data just not going to work?
Thanks very much!