X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/8fce4520de1f257819b16f9253fa28dcdae743f4..8efc0cf32160c68772a2ce1887e6a397852d3d96:/lunaix-os/usr/testp/main.c diff --git a/lunaix-os/usr/testp/main.c b/lunaix-os/usr/testp/main.c new file mode 100644 index 0000000..8011c30 --- /dev/null +++ b/lunaix-os/usr/testp/main.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include + +void +test_serial() +{ + int fd = open("/dev/ttyS0", FO_WRONLY); + if (fd < 0) { + printf("ttyS0 not accessable (%d)\n", errno); + return; + } + + char buf[32]; + int sz = 0; + + printf("ttyS0 input: "); + + if ((sz = read(fd, buf, 31)) < 0) { + printf("write to ttyS0 failed (%d)\n", errno); + } + + buf[sz] = 0; + + printf("%s", buf); + + close(fd); +} + +int +main(int argc, char* argv[]) +{ + if (argc <= 1) { + return 1; + } + + char* target = argv[1]; + + if (!strcmp(target, "serial")) { + test_serial(); + } else { + printf("unknown test: %s\n", target); + return 1; + } + + return 0; +} \ No newline at end of file