diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/commands.c | 19 | ||||
| -rw-r--r-- | client/commands.h | 7 | ||||
| -rw-r--r-- | client/errcatch.c | 1 | ||||
| -rw-r--r-- | client/main.c | 4 | ||||
| -rw-r--r-- | client/main.h | 1 | ||||
| -rw-r--r-- | client/serial.c | 29 | ||||
| -rw-r--r-- | client/setup.c | 8 | ||||
| -rw-r--r-- | client/setup.h | 2 | ||||
| -rw-r--r-- | client/time.h | 4 | ||||
| -rw-r--r-- | client/time_linux.c | 4 | ||||
| -rw-r--r-- | client/ui.c | 9 | ||||
| -rw-r--r-- | client/ui.h | 5 | 
12 files changed, 33 insertions, 60 deletions
| diff --git a/client/commands.c b/client/commands.c index 67025f4..1ab79fb 100644 --- a/client/commands.c +++ b/client/commands.c @@ -1,10 +1,10 @@  #include <stdlib.h> -#include "commands.h" -#include "time.h" -#include "main.h"  #include "../shared/bin.h"  #include "../shared/protocol.h" +#include "commands.h" +#include "main.h" +#include "time.h"  void w2_send_bin(w2_s_bin *data) {  	w2_serial_write("\xff", 1); @@ -14,27 +14,26 @@ void w2_send_bin(w2_s_bin *data) {  	}  } -w2_s_bin* w2_send_info() { +w2_s_bin *w2_send_info() {  	size_t msg_size		  = sizeof(w2_s_cmd_info_rx);  	w2_s_cmd_info_rx *msg = malloc(msg_size);  	msg->opcode			  = W2_CMD_INFO | W2_CMDDIR_RX; -	w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg); +	w2_s_bin *msg_bin	  = w2_bin_s_alloc(msg_size, (uint8_t *)msg);  	w2_send_bin(msg_bin);  	free(msg);  	free(msg_bin);  } -w2_s_bin* w2_send_ping() { -	g_w2_state.ping_id = (uint8_t) rand(); +w2_s_bin *w2_send_ping() { +	g_w2_state.ping_id	  = (uint8_t)rand();  	size_t msg_size		  = sizeof(w2_s_cmd_ping_rx);  	w2_s_cmd_ping_rx *msg = malloc(msg_size);  	msg->opcode			  = W2_CMD_PING | W2_CMDDIR_RX; -	msg->id = g_w2_state.ping_id; -	w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg); +	msg->id				  = g_w2_state.ping_id; +	w2_s_bin *msg_bin	  = w2_bin_s_alloc(msg_size, (uint8_t *)msg);  	w2_send_bin(msg_bin);  	free(msg);  	free(msg_bin);  	w2_timer_start(W2_TIMER_PING);  } - diff --git a/client/commands.h b/client/commands.h index aa4b964..949360e 100644 --- a/client/commands.h +++ b/client/commands.h @@ -1,8 +1,7 @@  #pragma once -#include "serial.h"  #include "../shared/bin.h" +#include "serial.h" -w2_s_bin* w2_send_info(); -w2_s_bin* w2_send_ping(); - +w2_s_bin *w2_send_info(); +w2_s_bin *w2_send_ping(); diff --git a/client/errcatch.c b/client/errcatch.c index e8d696a..5e39b00 100644 --- a/client/errcatch.c +++ b/client/errcatch.c @@ -16,4 +16,3 @@ void w2_errcatch_handle_error(w2_s_error *error) {  	return;  } - diff --git a/client/main.c b/client/main.c index 530af2a..8fe6d8e 100644 --- a/client/main.c +++ b/client/main.c @@ -1,7 +1,7 @@ -#include "setup.h" -#include "../shared/errcatch.h"  #include "main.h" +#include "../shared/errcatch.h"  #include "serial.h" +#include "setup.h"  #include "ui.h"  w2_s_client_state g_w2_state; diff --git a/client/main.h b/client/main.h index f81e8ce..462da73 100644 --- a/client/main.h +++ b/client/main.h @@ -10,4 +10,3 @@ typedef struct {  } w2_s_client_state;  extern w2_s_client_state g_w2_state; - diff --git a/client/serial.c b/client/serial.c index ec523cc..0d0bca7 100644 --- a/client/serial.c +++ b/client/serial.c @@ -1,8 +1,8 @@  #include "serial.h" -#include "time.h" -#include "main.h"  #include "../shared/protocol.h"  #include "../shared/serial_parse.h" +#include "main.h" +#include "time.h"  void w2_serial_main() {  	int temp; @@ -14,24 +14,12 @@ void w2_cmd_ping_tx(w2_s_bin *data) {  	g_w2_state.ping = w2_timer_end(W2_TIMER_PING);  	printf("ping measured, %ims\n", g_w2_state.ping);  } -void w2_cmd_expt_tx(w2_s_bin *data) { -	printf("w2_cmd_expt_tx()\n"); -} -void w2_cmd_mode_tx(w2_s_bin *data) { -	printf("w2_cmd_mode_tx()\n"); -} -void w2_cmd_cord_tx(w2_s_bin *data) { -	printf("w2_cmd_cord_tx()\n"); -} -void w2_cmd_bomd_tx(w2_s_bin *data) { -	printf("w2_cmd_bomd_tx()\n"); -} -void w2_cmd_sens_tx(w2_s_bin *data) { -	printf("w2_cmd_sens_tx()\n"); -} -void w2_cmd_info_tx(w2_s_bin *data) { -	printf("w2_cmd_info_tx()\n"); -} +void w2_cmd_expt_tx(w2_s_bin *data) { printf("w2_cmd_expt_tx()\n"); } +void w2_cmd_mode_tx(w2_s_bin *data) { printf("w2_cmd_mode_tx()\n"); } +void w2_cmd_cord_tx(w2_s_bin *data) { printf("w2_cmd_cord_tx()\n"); } +void w2_cmd_bomd_tx(w2_s_bin *data) { printf("w2_cmd_bomd_tx()\n"); } +void w2_cmd_sens_tx(w2_s_bin *data) { printf("w2_cmd_sens_tx()\n"); } +void w2_cmd_info_tx(w2_s_bin *data) { printf("w2_cmd_info_tx()\n"); }  void w2_cmd_ping_rx(w2_s_bin *data) { return; }  void w2_cmd_mode_rx(w2_s_bin *data) { return; } @@ -46,4 +34,3 @@ void w2_cmd_info_rx(w2_s_bin *data) { return; }  void w2_cmd_disp_rx(w2_s_bin *data) { return; }  void w2_cmd_play_rx(w2_s_bin *data) { return; }  void w2_cmd_cled_rx(w2_s_bin *data) { return; } - diff --git a/client/setup.c b/client/setup.c index 35b761c..2e8cce7 100644 --- a/client/setup.c +++ b/client/setup.c @@ -1,18 +1,18 @@  #include <stdio.h>  #include <stdlib.h> -#include "serial.h" -#include "setup.h" -#include "commands.h"  #include "../shared/bin.h"  #include "../shared/protocol.h" +#include "commands.h" +#include "serial.h" +#include "setup.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) { +void w2_client_setup(int argc, char **argv) {  	if (argc < 2) {  		printf("usage: %s <serial port>\n", argv[0]);  		exit(1); diff --git a/client/setup.h b/client/setup.h index 4b4a040..bcad11e 100644 --- a/client/setup.h +++ b/client/setup.h @@ -1,3 +1,3 @@  #pragma once -void w2_client_setup(int argc, char** argv); +void w2_client_setup(int argc, char **argv); diff --git a/client/time.h b/client/time.h index 75b1f70..253451d 100644 --- a/client/time.h +++ b/client/time.h @@ -3,9 +3,7 @@  /** amount of parallel timers */  #define W2_CLIENT_TIMER_COUNT (4)  extern unsigned long g_w2_client_timers[W2_CLIENT_TIMER_COUNT]; -typedef enum { -	W2_TIMER_PING = 0 -} w2_e_client_timers; +typedef enum { W2_TIMER_PING = 0 } w2_e_client_timers;  void w2_timer_start(w2_e_client_timers label);  unsigned long w2_timer_end(w2_e_client_timers label); diff --git a/client/time_linux.c b/client/time_linux.c index 5b72838..f6d50d8 100644 --- a/client/time_linux.c +++ b/client/time_linux.c @@ -10,9 +10,7 @@ unsigned long w2_get_time() {  	return ((now.tv_sec * 1000) + (now.tv_nsec / 1000000));  } -void w2_timer_start(w2_e_client_timers label) { -	g_w2_client_timers[label] = w2_get_time(); -} +void w2_timer_start(w2_e_client_timers label) { g_w2_client_timers[label] = w2_get_time(); }  unsigned long w2_timer_end(w2_e_client_timers label) {  	return w2_get_time() - g_w2_client_timers[label]; diff --git a/client/ui.c b/client/ui.c index 4a8e64d..239065c 100644 --- a/client/ui.c +++ b/client/ui.c @@ -9,11 +9,6 @@ void w2_ui_update() {  	// measure terminal width and height  } -void w2_ui_paint() { +void w2_ui_paint() { w2_ui_paint_statusbar(); } -	w2_ui_paint_statusbar(); -} - -void w2_ui_paint_statusbar() { - -} +void w2_ui_paint_statusbar() {} diff --git a/client/ui.h b/client/ui.h index 433d610..afb0817 100644 --- a/client/ui.h +++ b/client/ui.h @@ -48,11 +48,10 @@ void w2_ui_set_fg(w2_e_colors color);  void w2_ui_set_bg(w2_e_colors color);  /** align `text` `align` with `text` buffer length `length` */ -void w2_ui_align(char* text, w2_e_alignment align, unsigned int length); +void w2_ui_align(char *text, w2_e_alignment align, unsigned int length);  /**   * trim spaces from `top` and overlay on top of `bottom`   * both strings should be at least `length` long   */ -void w2_ui_overlay(char* bottom, char* top, unsigned int length); - +void w2_ui_overlay(char *bottom, char *top, unsigned int length); |