1 | #include "stdio.h" |
2 |
|
3 | int main() { |
4 | printf("AutoPlow starting...\n\n"); |
5 |
|
6 | printf("Attempting to begin serial data read on ARD1 (Motor Controller) at /dev/ttyACM0\n"); |
7 | FILE * ttyACM0; |
8 | ttyACM0 = fopen("/dev/ttyACM0", "r"); |
9 | if (ttyACM0) { |
10 | printf("Successfully opened serial stream\n\n"); |
11 | printf("Dumping contents:\n"); |
12 | char buffer[4096]; |
13 | while (fgets(buffer, sizeof(buffer), ttyACM0) != NULL) { |
14 | printf("Input: "); |
15 | printf(buffer); |
16 | } |
17 | printf("Closing file stream\n"); |
18 | fclose(ttyACM0); |
19 | } else { |
20 | printf("Unsuccessful in opening serial stream. Make sure the Arduino is plugged in to the RPI.\n"); |
21 | return 1; |
22 | } |
23 | return 0; |
24 | } |
25 |
|