aboutsummaryrefslogtreecommitdiff
path: root/client/setup.c
blob: 5eb6c13a6da1a2394f6680e64998f12481c747d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <stdlib.h>

#include "../shared/bin.h"
#include "../shared/protocol.h"
#include "commands.h"
#include "serial.h"
#include "setup.h"
#include "term.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("usage: %s <serial port>\n", argv[0]);
		exit(1);
	}

	if (w2_serial_open(argv[1]) == 0) {
		printf("serial port open fout\n");
		exit(1);
	}

	w2_term_raw_mode();

	w2_cmd_setup_handlers();

	w2_send_info();
	w2_send_ping();

	// check endianness
	g_w2_endianness = *_ptest;
}