Line | |
---|
1 |
|
---|
2 | #ifndef WIN32
|
---|
3 | #include <unistd.h>
|
---|
4 | #else
|
---|
5 | #include <windows.h>
|
---|
6 | #include <direct.h>
|
---|
7 | #endif
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <stdlib.h>
|
---|
10 |
|
---|
11 | int main(int argc, char* argv[]) {
|
---|
12 |
|
---|
13 | FILE* fp = fopen("/dev/ttyS0", "r");
|
---|
14 |
|
---|
15 | if (!fp) {
|
---|
16 | printf("Cannot open file.\n");
|
---|
17 | exit(9);
|
---|
18 | }
|
---|
19 |
|
---|
20 | char msg[100];
|
---|
21 |
|
---|
22 | while (true) {
|
---|
23 | int nb = fread(msg, sizeof(msg), 1, fp);
|
---|
24 | printf("read %d\n", nb);
|
---|
25 | sleep(1);
|
---|
26 | }
|
---|
27 |
|
---|
28 | return 0;
|
---|
29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.