33 if (cnt < CMD_BUFFER_LEN && c >= 32 && c <= 126)
39 if ((c ==
'\n' || c ==
'\r') && cnt > 0)
61 token = strtok(cmd,
" ");
64 if (strcasecmp(token,
"HELLO") == 0)
66 printf(
"Communication OK\n");
69 else if (strcasecmp(token,
"HOME") == 0)
74 else if (strcasecmp(token,
"STATUS") == 0)
76 printf(
"reg:%08lx\n", *p_reg);
79 else if (strcasecmp(token,
"RESET") == 0)
84 else if (strcasecmp(token,
"TURN") == 0)
89 else if (strcasecmp(token,
"PULSE") == 0)
94 else if (strcasecmp(token,
"READ") == 0)
99 else if (strcasecmp(token,
"AUTOREAD") == 0)
104 else if (strcasecmp(token,
"SET") == 0)
109 else if (strcasecmp(token,
"CMD") == 0)
115 printf(
"Invalid cmd\n");
136 token = strtok(NULL,
" ");
137 if (strcasecmp(token,
"RIGHT") == 0)
141 else if (strcasecmp(token,
"LEFT") == 0)
147 printf(
"Invalid dir\n");
169 token = strtok(NULL,
" ");
171 if (strcasecmp(token,
"GYR") == 0)
176 else if (strcasecmp(token,
"ACC") == 0)
181 else if (strcasecmp(token,
"POS") == 0)
186 else if (strcasecmp(token,
"ALL") == 0)
223 token = strtok(NULL,
" ");
227 if (strcasecmp(token,
"RIGHT") == 0)
232 else if (strcasecmp(token,
"LEFT") == 0)
239 printf(
"Invalid dir\n");
243 token = strtok(NULL,
" ");
245 pulse_len = atoi(token);
251 time_array[dir_pointer] = (uint8_t)(pulse_len/
PULSE_REPRE);
254 else if (token == NULL)
261 printf(
"Invalid time\n");
266 _set_time(*p_reg, time_array[0], time_array[1]);
284 token = strtok(NULL,
" ");
286 if (strcasecmp(token,
"ON") == 0)
291 else if (strcasecmp(token,
"OFF") == 0)
297 printf(
"Invalid cmd\n");
315 token = strtok(NULL,
" ");
317 if (strcasecmp(token,
"READ") == 0)
321 else if (strcasecmp(token,
"AUTO") == 0)
325 else if (strcasecmp(token,
"TIME") == 0)
329 else if (strcasecmp(token,
"ANGLE") == 0)
333 else if (strcasecmp(token,
"HOME") == 0)
339 printf(
"Invalid cmd\n");
373 token = strtok(NULL,
" ");
377 if (strcasecmp(token,
"ACC") == 0)
381 else if (strcasecmp(token,
"GYR") == 0)
385 else if (strcasecmp(token,
"POS") == 0)
391 printf(
"Invalid cmd\n");
395 token = strtok(NULL,
" ");
398 if (strcasecmp(token,
"ON") == 0)
402 else if (strcasecmp(token,
"OFF") == 0)
408 printf(
"Invalid cmd\n");
422 token = strtok(NULL,
" ");
423 uint8_t time = atoi(token);
425 if ((time != 0) && (time <=
MAX_TIME))
440 token = strtok(NULL,
" ");
444 token = strtok(NULL,
" ");
445 uint16_t time = atoi(token);
449 if (strcasecmp(dir,
"RIGHT") == 0)
453 else if (strcasecmp(dir,
"LEFT") == 0)
457 else if (strcasecmp(dir,
"ALL") == 0)
464 printf(
"Invalid dir\n");
479 token = strtok(NULL,
" ");
480 uint8_t angle = atoi(token);
497 token = strtok(NULL,
" ");
498 int16_t home = atoi(token);
506 printf(
"Invalid position\n");
549 token = strtok(NULL,
" ");
567 printf(
"Invalid cmd\n");
static void process_cmd_set_home(char *token)
static void process_cmd(char *cmd, uint32_t *p_reg)
static void process_cmd_autoread(char *token, uint32_t *p_reg)
static void process_cmd_ncmd(char *token, uint32_t *p_reg)
static void process_cmd_home(uint32_t *p_reg)
static void process_cmd_turn(char *token, uint32_t *p_reg)
static void process_cmd_set_auto(char *token)
static void process_cmd_set_angle(char *token)
static void process_cmd_set_read(char *token, uint32_t *p_reg)
static void process_cmd_set_time(char *token)
static void process_cmd_set(char *token, uint32_t *p_reg)
static void process_cmd_pulse(char *token, uint32_t *p_reg)
static void process_cmd_read(char *token)
static void process_cmd_reset(uint32_t *p_reg)
settings_t set_data
Main system settings.
sensor_data_t measured_data
Current sensor measured data.
void uart_byte_available(uint8_t c, uint32_t *p_reg)
Recognizes commands in the received characters and sets the cmd register accordingly.
: Header for main.c file. This file contains the common defines of the application.
#define _float2int(data_fl)
#define VALVE_R_GPIO_Port
#define _tog_BV(reg, bit)
#define _clr_BV(reg, bit)
#define _set_time(reg, time_l, time_r)
#define VALVE_L_GPIO_Port
#define _set_BV(reg, bit)
float pos[3]
Orientation X, Y, Z [deg]; related to initial position.
float gyr[3]
Gyroscope X, Y, Z [dps].
float acc[3]
Accelerometer X, Y, Z [g].
uint8_t time_r
Time [10*ms], right valve is open.
uint8_t angle
Angle [deg], cube rotate after turn cmd.
int16_t home
Angle [deg], default orientation.
uint8_t time_l
Time [10*ms], left valve is open.
uint8_t time_a
Period [100*ms], sensor report will be sended.