summaryrefslogtreecommitdiff
path: root/client/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'client/setup.c')
-rw-r--r--client/setup.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/client/setup.c b/client/setup.c
new file mode 100644
index 0000000..fd37c13
--- /dev/null
+++ b/client/setup.c
@@ -0,0 +1,44 @@
+#include <ncurses.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "../shared/bin.h"
+#include "../shared/protocol.h"
+#include "commands.h"
+#include "serial.h"
+#include "setup.h"
+#include "strings.h"
+#include "ui.h"
+
+// pointers for endianness check
+static const uint16_t _test = 1;
+static const uint8_t *_ptest = (uint8_t *)&_test;
+uint8_t g_w2_endianness;
+
+void w2_client_setup(int argc, char **argv) {
+ if (argc < 2) {
+ printf(W2_UI_CLI_USAGE, argv[0]);
+ exit(1);
+ }
+
+ if (w2_serial_open(argv[1]) == 0) {
+ printf(W2_UI_CLI_SERPORT_ERROR);
+ exit(1);
+ }
+
+ if ((g_w2_ui_win = initscr()) == NULL) {
+ printf(W2_UI_CLI_INITSCR_FAIL);
+ exit(1);
+ }
+ noecho();
+ curs_set(false);
+ nodelay(g_w2_ui_win, true);
+
+ w2_strings_init();
+ w2_cmd_setup_handlers();
+
+ w2_send_info();
+
+ // check endianness
+ g_w2_endianness = *_ptest;
+}