12345678910111213141516171819202122232425262728293031 |
- #include <fcntl.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- int main() {
-
- int fd = open("/dev/char/uart:1088", O_WRONLY | O_NONBLOCK);
- char buf[1] = {0};
- int n;
- memset(buf, 0, 1);
- while (1) {
- n = read(fd, buf, 1);
- close(fd);
- fd = open("/dev/char/uart:1088", O_WRONLY | O_NONBLOCK);
- if (n != 0) {
- printf("Received: %s\n", buf);
- if (buf[0] == 'g') {
- break;
- }
- }
- }
- printf("fd: %d", fd);
-
- char *str = "------fuck-----";
- int len = write(fd, str, strlen(str));
- printf("len: %d", len);
-
- close(fd);
- return 0;
- }
|