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