aboutsummaryrefslogtreecommitdiff
path: root/client/main.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-29 13:15:58 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-29 13:15:58 +0200
commit529f067e65b0146c5afa150103809ba5e09869b7 (patch)
tree80fa7a44ce8f5d43b2cc04dc1d0fd1fb79eb254e /client/main.c
parentdbd005573295293d35647dc0e9feb2beec48a31c (diff)
client/robot sim connected
Diffstat (limited to 'client/main.c')
-rw-r--r--client/main.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/client/main.c b/client/main.c
index 76e8197..d51f30b 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1 +1,29 @@
-int main() { return 0; }
+#include "serial.h"
+
+#include <stdio.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+ if (argc < 2) {
+ printf("usage: %s <serial port>\n", argv[0]);
+ return 1;
+ }
+
+ if (w2_serial_open(argv[1]) == 0) {
+ printf("serial port open fout");
+ return 1;
+ }
+
+ printf("writing...\n");
+ bool success = w2_serial_write("\xff\x14", 2);
+ printf("writing %s\n", success ? "succeeded" : "failed");
+
+ printf("reading...\n");
+ while (1) {
+ int res = w2_serial_read();
+ if (res == -1) continue;
+
+ printf("%02x ", (uint8_t)res);
+ fflush(stdout);
+ }
+}