diff options
Diffstat (limited to 'shared')
| -rw-r--r-- | shared/consts.h | 15 | ||||
| -rw-r--r-- | shared/errors.h | 2 | ||||
| -rw-r--r-- | shared/protocol.c | 19 | 
3 files changed, 9 insertions, 27 deletions
| diff --git a/shared/consts.h b/shared/consts.h index 50b16b9..cdd96b3 100644 --- a/shared/consts.h +++ b/shared/consts.h @@ -12,21 +12,24 @@  #warning "host operating system unknown"  #endif -/** max logic module execution time in milliseconds */ -#define W2_MAX_MODULE_CYCLE_MS (20)  /** serial baud rate (bit/s) */  #define W2_SERIAL_BAUD (9600) +/** size of input (receive) buffer (in bytes) */ +#define W2_SERIAL_READ_BUFFER_SIZE (255) +  /** size of the error handling buffer (in errors, not bytes) */  #define W2_ERROR_BUFFER_SIZE (16)  /** size of the serial communication buffer (in messages, not bytes) */  #define W2_SERCOMM_BUFFER_SIZE (16) -/** size of input (receive) buffer (in bytes) */ -#define W2_SERIAL_READ_BUFFER_SIZE (255) -/** exponential moving average new measurement weight (double 0-1) */ -#define W2_EMA_WEIGHT (0.10)  /** size of mode history buffer */  #define W2_MODE_HISTORY_BUFFER_SIZE (4) +/** max logic module execution time in milliseconds */ +#define W2_MAX_MODULE_CYCLE_MS (20) + +/** exponential moving average new measurement weight (double 0-1) */ +#define W2_EMA_WEIGHT (0.10) +  /** front-facing distance sensor pinout */  #define W2_FRONT_SENSOR_PIN 5  /** battery voltage sensor pinout */ diff --git a/shared/errors.h b/shared/errors.h index 4c9f7c8..344a506 100644 --- a/shared/errors.h +++ b/shared/errors.h @@ -45,8 +45,6 @@ typedef enum {  	W2_E_WARN_SERCOMM_BUFFER_FULL = 0x06 | W2_E_TYPE_WARN,  	/** semver minor version doesn't match */  	W2_E_WARN_VERSION_INCOMPATIBLE = 0x07 | W2_E_TYPE_WARN, -	/** serial byte took to long to receive */ -	W2_E_WARN_SERIAL_TIMEOUT = 0x08 | W2_E_TYPE_WARN,  	/** unknown message encountered (noisy channel?) */  	W2_E_WARN_SERIAL_NOISY = 0x09 | W2_E_TYPE_WARN,  	/** mode history index out of bounds */ diff --git a/shared/protocol.c b/shared/protocol.c index fcc9fa4..9be1d31 100644 --- a/shared/protocol.c +++ b/shared/protocol.c @@ -74,22 +74,3 @@ size_t w2_cmd_expt_tx_sizeof(w2_s_bin *data) {  size_t w2_cmd_mcfg_rx_sizeof(w2_s_bin *data) {  	return W2_DYN_MEMBER_SIZEOF(w2_s_cmd_mcfg_rx, 3, w2_s_cmd_mcfg_feature);  } - -void w2_cmd_handler(uint8_t data[W2_SERIAL_READ_BUFFER_SIZE], uint8_t data_length) { -	w2_s_bin *copy				= w2_bin_s_alloc(data_length, data); -	void (*handler)(w2_s_bin *) = g_w2_cmd_handlers[data[0]]; - -	if (handler == NULL) { -#ifdef W2_SIM -		// TODO throw warning -		simwarn("unknown serial message with code 0x%02x\n", data[0]); -#endif -	} else { -#ifdef W2_SIM -		w2_sim_print_serial(copy); -#endif -		handler(copy); -	} - -	free(copy); -} |