|
@@ -88,6 +88,10 @@ const char *akb_args_list[] = {
|
|
"lifetime",
|
|
"lifetime",
|
|
"dataset",
|
|
"dataset",
|
|
"upspower",
|
|
"upspower",
|
|
|
|
+#else if HARDWARE_BT6711
|
|
|
|
+ "capacity",
|
|
|
|
+ "voltakb",
|
|
|
|
+ "upspower",
|
|
#endif
|
|
#endif
|
|
};
|
|
};
|
|
|
|
|
|
@@ -335,6 +339,10 @@ static const CLI_Command_Definition_t prvAKBCommandDefinition = {
|
|
"\takb lifetime <value>: ввод срока службы АКБ (лет)\r\n"
|
|
"\takb lifetime <value>: ввод срока службы АКБ (лет)\r\n"
|
|
"\takb dataset <YYYY-MM-DD>: ввод даты установки АКБ\r\n"
|
|
"\takb dataset <YYYY-MM-DD>: ввод даты установки АКБ\r\n"
|
|
"\takb upspower <value>: ввод полной мощности ИБП (ВА)\r\n"
|
|
"\takb upspower <value>: ввод полной мощности ИБП (ВА)\r\n"
|
|
|
|
+#else if HARDWARE_BT6711
|
|
|
|
+ "\takb capacity <value>: ввод ёмкости АКБ (Ач)\r\n"
|
|
|
|
+ "\takb voltakb <value>: ввод номинального напряжения АКБ (В)\r\n"
|
|
|
|
+ "\takb upspower <value>: ввод полной мощности ИБП (ВА)\r\n"
|
|
#endif
|
|
#endif
|
|
,
|
|
,
|
|
prvTaskAKBCommand, /* The function to run. */
|
|
prvTaskAKBCommand, /* The function to run. */
|
|
@@ -504,7 +512,38 @@ static const CLI_Command_Definition_t prvFTPCommandDefinition = {
|
|
"\tftp pass <password>: задать пароль для аутентификации на FTP-сервере\r\n"
|
|
"\tftp pass <password>: задать пароль для аутентификации на FTP-сервере\r\n"
|
|
"\tftp run: запустить процесс обновления через FTP\r\n",
|
|
"\tftp run: запустить процесс обновления через FTP\r\n",
|
|
prvTaskFTPCommand, /* The function to run. */
|
|
prvTaskFTPCommand, /* The function to run. */
|
|
- -1, // varying number of parameters
|
|
|
|
|
|
+ -1 /* The user can enter any number of commands. */
|
|
|
|
+};
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#ifdef SYSLOG_ENABLE
|
|
|
|
+
|
|
|
|
+const char *syslog_args_list[] = {
|
|
|
|
+ "info",
|
|
|
|
+ "ENA",
|
|
|
|
+ "DIS",
|
|
|
|
+ "server_ip",
|
|
|
|
+ "server_port",
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+typedef enum{
|
|
|
|
+ ARG_SYSLOG_INFO = 0,
|
|
|
|
+ ARG_SYSLOG_ENABLE,
|
|
|
|
+ ARG_SYSLOG_DISABLE,
|
|
|
|
+ ARG_SYSLOG_IP,
|
|
|
|
+ ARG_SYSLOG_PORT,
|
|
|
|
+ ARG_SYSLOG_ALL
|
|
|
|
+}syslog_args_t;
|
|
|
|
+
|
|
|
|
+static portBASE_TYPE prvTaskSysLogCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
|
|
|
+static const CLI_Command_Definition_t prvSysLogCommandDefinition = {
|
|
|
|
+ (const int8_t *const)"syslog", /* The command string to type. */
|
|
|
|
+ (const int8_t *const)"\tsyslog info: вывод информации о настройках Syslog\r\n"
|
|
|
|
+ "\tsyslog ENA|DIS: вкл./выкл. Syslog\r\n"
|
|
|
|
+ "\tsyslog server_ip <ip address>: установка ip-адреса Syslog-сервера\r\n"
|
|
|
|
+ "\tsyslog server_port <port>: установка порта Syslog-сервера\r\n",
|
|
|
|
+ prvTaskSysLogCommand, /* The function to run. */
|
|
|
|
+ -1 /* The user can enter any number of commands. */
|
|
};
|
|
};
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -545,6 +584,9 @@ void vRegisterCLICommands( void )
|
|
FreeRTOS_CLIRegisterCommand( &prvUPSCommandDefinition );
|
|
FreeRTOS_CLIRegisterCommand( &prvUPSCommandDefinition );
|
|
#ifdef FTP_ENABLE
|
|
#ifdef FTP_ENABLE
|
|
FreeRTOS_CLIRegisterCommand( &prvFTPCommandDefinition );
|
|
FreeRTOS_CLIRegisterCommand( &prvFTPCommandDefinition );
|
|
|
|
+#endif
|
|
|
|
+#ifdef SYSLOG_ENABLE
|
|
|
|
+ FreeRTOS_CLIRegisterCommand( &prvSysLogCommandDefinition );
|
|
#endif
|
|
#endif
|
|
FreeRTOS_CLIRegisterCommand( &prvQuitCommandDefinition );
|
|
FreeRTOS_CLIRegisterCommand( &prvQuitCommandDefinition );
|
|
}
|
|
}
|
|
@@ -1474,7 +1516,7 @@ static portBASE_TYPE prvTaskAKBCommand(cli_state_t *cli_state, int8_t *pcWriteBu
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
-#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS
|
|
|
|
|
|
+#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS || HARDWARE_BT6711
|
|
case ARG_AKB_CAPACITY:
|
|
case ARG_AKB_CAPACITY:
|
|
if (value >= CAPACITY_MIN_RANGE && value <= CAPACITY_MAX_RANGE && (value - (int32_t)value) == 0) {
|
|
if (value >= CAPACITY_MIN_RANGE && value <= CAPACITY_MAX_RANGE && (value - (int32_t)value) == 0) {
|
|
SetCapacityNominalAKBStr(str);
|
|
SetCapacityNominalAKBStr(str);
|
|
@@ -1491,6 +1533,7 @@ static portBASE_TYPE prvTaskAKBCommand(cli_state_t *cli_state, int8_t *pcWriteBu
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+#ifndef HARDWARE_BT6711
|
|
case ARG_AKB_LIFETIME:
|
|
case ARG_AKB_LIFETIME:
|
|
if (value >= LIFETIME_MIN_RANGE && value <= LIFETIME_MAX_RANGE && (value - (int32_t)value) == 0) {
|
|
if (value >= LIFETIME_MIN_RANGE && value <= LIFETIME_MAX_RANGE && (value - (int32_t)value) == 0) {
|
|
SetLifeTimeAKBStr(str);
|
|
SetLifeTimeAKBStr(str);
|
|
@@ -1545,6 +1588,7 @@ static portBASE_TYPE prvTaskAKBCommand(cli_state_t *cli_state, int8_t *pcWriteBu
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+#endif
|
|
case ARG_AKB_UPS_POWER:
|
|
case ARG_AKB_UPS_POWER:
|
|
if (value >= UPS_POWER_MIN_RANGE && value <= UPS_POWER_MAX_RANGE && ((int32_t)value % 50) == 0 && (value - (int32_t)value) == 0) {
|
|
if (value >= UPS_POWER_MIN_RANGE && value <= UPS_POWER_MAX_RANGE && ((int32_t)value % 50) == 0 && (value - (int32_t)value) == 0) {
|
|
SetUPSPowerStr(str);
|
|
SetUPSPowerStr(str);
|
|
@@ -2861,6 +2905,153 @@ static portBASE_TYPE prvTaskUPSCommand(cli_state_t *cli_state, int8_t *pcWriteBu
|
|
return xReturn;
|
|
return xReturn;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef SYSLOG_ENABLE
|
|
|
|
+static portBASE_TYPE prvTaskSysLogCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
|
|
|
+{
|
|
|
|
+ int8_t *pcParameterString;
|
|
|
|
+ signed portBASE_TYPE xParameterStringLength, xReturn;
|
|
|
|
+ portBASE_TYPE xParameterNumber = 1;
|
|
|
|
+ char str[110];
|
|
|
|
+ char str_temp[110];
|
|
|
|
+ uint8_t len;
|
|
|
|
+ uint8_t i;
|
|
|
|
+ bool enable_old_syslog;
|
|
|
|
+
|
|
|
|
+ const int8_t *const pcInfoTableHeader = ( int8_t * )
|
|
|
|
+ "\r\n***********SysLog настройки Контроллера***********\r\n";
|
|
|
|
+
|
|
|
|
+ ( void ) pcCommandString;
|
|
|
|
+ ( void ) xWriteBufferLen;
|
|
|
|
+ configASSERT( pcWriteBuffer );
|
|
|
|
+
|
|
|
|
+ memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);
|
|
|
|
+ /* Obtain the parameter string. */
|
|
|
|
+ pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter
|
|
|
|
+ (
|
|
|
|
+ pcCommandString, /* The command string itself. */
|
|
|
|
+ xParameterNumber, /* Return the next parameter. */
|
|
|
|
+ &xParameterStringLength /* Store the parameter string length. */
|
|
|
|
+ );
|
|
|
|
+ if (pcParameterString == NULL) {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ return pdFALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < ARG_SYSLOG_ALL; i ++) {
|
|
|
|
+ if ( strncmp( ( const char * ) pcParameterString, syslog_args_list[i], strlen(syslog_args_list[i]) ) == 0
|
|
|
|
+ && xParameterStringLength == strlen(syslog_args_list[i])) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (cli_state->user_id != ADMIN && i != ARG_SYSLOG_INFO) {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );
|
|
|
|
+ return pdFALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ xParameterNumber ++;
|
|
|
|
+ /* Obtain the parameter string. */
|
|
|
|
+ pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter
|
|
|
|
+ (
|
|
|
|
+ pcCommandString, /* The command string itself. */
|
|
|
|
+ xParameterNumber, /* Return the next parameter. */
|
|
|
|
+ &xParameterStringLength /* Store the parameter string length. */
|
|
|
|
+ );
|
|
|
|
+ if (pcParameterString == NULL) {
|
|
|
|
+ switch (i) {
|
|
|
|
+ case ARG_SYSLOG_INFO:
|
|
|
|
+ /* Return the next command help string, before moving the pointer on to
|
|
|
|
+ the next command in the list. */
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInfoTableHeader, strlen( ( char * ) pcInfoTableHeader ) );
|
|
|
|
+
|
|
|
|
+ GetSyslogEnableStrRU(str, &len);
|
|
|
|
+ strcat(( char * ) pcWriteBuffer, "Передача по SysLog:\t\t");
|
|
|
|
+ strncat(( char * ) pcWriteBuffer, str, len);
|
|
|
|
+
|
|
|
|
+ strcat(( char * ) pcWriteBuffer, "\r\nIP адрес сервера:\t\t");
|
|
|
|
+ GetSyslogServer(str, &len);
|
|
|
|
+ strncat(( char * ) pcWriteBuffer, str, len);
|
|
|
|
+
|
|
|
|
+ strcat(( char * ) pcWriteBuffer, "\r\nПорт сервера:\t\t\t");
|
|
|
|
+ GetSyslogPort(str, &len);
|
|
|
|
+ strncat(( char * ) pcWriteBuffer, str, len);
|
|
|
|
+
|
|
|
|
+ strcat(( char * ) pcWriteBuffer, "\r\n");
|
|
|
|
+ break;
|
|
|
|
+ case ARG_SYSLOG_ENABLE:
|
|
|
|
+ enable_old_syslog = sSettings.sSyslog.enabled;
|
|
|
|
+ SetSyslogEnable("on");
|
|
|
|
+ if (sSettings.sSyslog.enabled != enable_old_syslog) {
|
|
|
|
+ cli_save_config(cli_state);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case ARG_SYSLOG_DISABLE:
|
|
|
|
+ enable_old_syslog = sSettings.sSyslog.enabled;
|
|
|
|
+ SetSyslogEnable("off");
|
|
|
|
+ if (sSettings.sSyslog.enabled != enable_old_syslog) {
|
|
|
|
+ cli_save_config(cli_state);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ memset(str_temp, 0, sizeof(str_temp));
|
|
|
|
+ if (xParameterStringLength > (int32_t)sizeof(str_temp)) {
|
|
|
|
+ xParameterStringLength = sizeof(str_temp) - 1;
|
|
|
|
+ }
|
|
|
|
+ strncat(str_temp, ( const char * ) pcParameterString, xParameterStringLength);
|
|
|
|
+ switch (i) {
|
|
|
|
+ case ARG_SYSLOG_IP:
|
|
|
|
+ if (xParameterStringLength <= 15) {
|
|
|
|
+ if (ipaddr_addr(str_temp) != IPADDR_NONE) {
|
|
|
|
+ GetSyslogServer(str, &len);
|
|
|
|
+ if (strncmp(str_temp, str, strlen(str_temp)) != 0) {
|
|
|
|
+ SetSyslogServer(str_temp);
|
|
|
|
+ cli_save_config(cli_state);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case ARG_SYSLOG_PORT:
|
|
|
|
+ if (xParameterStringLength <= 5) {
|
|
|
|
+ for (uint8_t j = 0; j < xParameterStringLength; j++) {
|
|
|
|
+ if (!isdigit_int(str_temp[j])) {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ return pdFALSE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int temp = atoi(str_temp);
|
|
|
|
+ if (temp > 0 && temp < 65535) {
|
|
|
|
+ GetSyslogPort(str, &len);
|
|
|
|
+ if (strncmp(str_temp, str, strlen(str_temp)) != 0) {
|
|
|
|
+ SetSyslogPort(str_temp);
|
|
|
|
+ cli_save_config(cli_state);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ xReturn = pdFALSE;
|
|
|
|
+
|
|
|
|
+ return xReturn;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
#ifdef FTP_ENABLE
|
|
#ifdef FTP_ENABLE
|
|
#pragma GCC diagnostic error "-Wall"
|
|
#pragma GCC diagnostic error "-Wall"
|
|
#pragma GCC diagnostic error "-Wextra"
|
|
#pragma GCC diagnostic error "-Wextra"
|