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