Now I copied over some C code for writing data to the Arduino, that worked on my notebook, but it doesn't work on the Pi anymore:
Code: Select all
FILE *fp;
fp = fopen("/dev/ttyACM0", "wb");
..error handling..
fprintf(fp, "%c", 'B'); /* write the character 'B' to the serial port)
fflush(fp); /* optional, if more write operations follow, in an actual program */
fclose(fp);
On the Pi, fflush(fp) just freezes the program and never returns.
I removed the fflush(fp) to check if the write buffers are at least flushed normally when the program eventually terminates, but lo and behold, in that case the program will freeze at fclose(fp) instead!
Any ideas? :/
(Reading Bytes sent by the Arduino from the serial port via fopen("/dev/ttyACM0", "rw") and then fgetc() works fine by the way.
I have also tried wiringPi library, but it has exactly the same results, just freezing.)