|
@@ -14,6 +14,10 @@
|
|
|
#define ISO_nl 0x0a
|
|
|
#define ISO_cr 0x0d
|
|
|
|
|
|
+#define REPEAT_SENSOR_INFO_TIME configTICK_RATE_HZ*5*1
|
|
|
+
|
|
|
+#define array_len(x) (sizeof(x)/sizeof(x[0]))
|
|
|
+
|
|
|
/**
|
|
|
* @brief Общая структура настроек
|
|
|
*/
|
|
@@ -34,19 +38,17 @@ cli_state_t cli_states[MAX_SESSIONS];
|
|
|
void SensorInfoTimerCallback(TimerHandle_t pxTimer) {
|
|
|
portBASE_TYPE xReturned = pdTRUE;
|
|
|
uint8_t num_timer;
|
|
|
- for(uint8_t i = 0; i < MAX_SESSIONS; i ++){
|
|
|
+ for (uint8_t i = 0; i < array_len(cli_states); i ++) {
|
|
|
if(pxTimer == cli_states[i].RepeatSensorInfoTimer){
|
|
|
num_timer = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- do
|
|
|
- {
|
|
|
+ do {
|
|
|
/* Ensure there is not a string lingering in
|
|
|
the output buffer. */
|
|
|
cOutputBuffer[ 0 ] = 0x00;
|
|
|
- // TODO
|
|
|
- //xReturned = FreeRTOS_CLIProcessCommand( "sensor info", cOutputBuffer, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
|
|
+ xReturned = FreeRTOS_CLIProcessCommand(&cli_states[num_timer], "sensor info", cOutputBuffer, configCOMMAND_INT_MAX_OUTPUT_SIZE);
|
|
|
cli_states[num_timer].send(cli_states[num_timer].num_connect, cOutputBuffer, strlen( ( const char * ) cOutputBuffer ));
|
|
|
|
|
|
} while( xReturned != pdFALSE );
|
|
@@ -328,7 +330,20 @@ void cli_getchar(cli_state_t *s, char incoming_char)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#define array_len(x) (sizeof(x)/sizeof(x[0]))
|
|
|
+void cli_init(void)
|
|
|
+{
|
|
|
+ for (uint8_t i = 0; i < array_len(cli_states); i++) {
|
|
|
+ memset(cli_states[i].buf, 0, cmdMAX_INPUT_SIZE);
|
|
|
+ memset(cli_states[i].prev_cmd, 0, cmdMAX_INPUT_SIZE);
|
|
|
+ memset(cli_states[i].optdata, 0, cmdMAX_INPUT_SIZE);
|
|
|
+ cli_states[i].optlen = 0;
|
|
|
+ cli_states[i].num_connect = 0;
|
|
|
+ cli_states[i].user_id = USER;
|
|
|
+ cli_states[i].flag_telnet_ip_option = false;
|
|
|
+ cli_states[i].RepeatSensorInfoTimer = xTimerCreate("SensorInfoTmr", REPEAT_SENSOR_INFO_TIME, pdFALSE, ( void * ) i, SensorInfoTimerCallback);
|
|
|
+ }
|
|
|
+ vRegisterCLICommands();
|
|
|
+}
|
|
|
|
|
|
cli_state_t *alloc_state(void)
|
|
|
{
|