This module provides commands interface to the subsystems of the Ctrl Panel.
Definition in file syscmds.c.
#include <string.h>
#include "gpio.h"
#include "FreeRTOS.h"
#include "task.h"
#include "shell.h"
#include "ethernet.h"
#include "BasicWEB.h"
#include "BasicSMTP.h"
#include "cptime.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_task.h"
#include "com1shell.h"
#include "sensor.h"
#include "supervisor.h"
#include "syscmds.h"
Go to the source code of this file.
Functions | |
eExecStatus | e_supervisor_switch_to_maintenance_mode (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The switch-to-maintenance-mode command: initiate the process to switch to maintenance mode. Format: maintain. | |
eExecStatus | e_syscmds_cmd_get_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The get sys config command: get the config fields value of a subsystem Takes one parameter, that is the subsystem's name. Format: get_sys_config sys=sysname. | |
eExecStatus | e_syscmds_cmd_set_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The set sys config command: set the value of a config field of a subsystem. Takes three parameters. The first parameter is the system's name, the second parameter is the config field name, the third parameter is its value. Format: set_sys_config sys=sysname field=value. | |
eExecStatus | e_syscmds_help (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The sys help command: display the system & subsystems available shell commands. Format: help. | |
eExecStatus | e_syscmds_reboot (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The sys reboot command: Sw reset of the Ctrl Panel. Format: reboot. | |
eExecStatus | e_syscmds_trace (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The dbgtrace command: displays info on the trace port(USART1). Format: dbgtrace. | |
eExecStatus | e_syscmds_version (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The sys version command: Display the Ctrl Panel sw version. Format: version. | |
void | v_syscmds_display_traces (void) |
Display debug info on the trace port(USART1). | |
Variables | |
const char *const | pcCtrlPanelVersion |
const signed portCHAR *const | SYSCMDS_MSG_HELP |
xSemaphoreHandle | xCFGMutex |
eExecStatus e_supervisor_switch_to_maintenance_mode | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The switch-to-maintenance-mode command: initiate the process to
switch to maintenance mode. Format: maintain.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Ignored. | |
av | Ignored. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 949 of file supervisor.c.
00953 { 00954 if( NULL != ppcStringReply ) 00955 *ppcStringReply = NULL; 00956 00957 #ifdef USB_ENABLE 00958 #if USB_DEVICE_FEATURE == ENABLED 00959 if( ( FALSE == bIsInMaintenance ) 00960 && ( 0 == u8IsMaintenanceRequired ) ) 00961 { // We're not in maintenance mode. 00962 // Initiate the process of switching to maintenance mode. 00963 if( 0 == u8IsMaintenanceRequired ) u8IsMaintenanceRequired++; 00964 00965 // Take all maintenance mutex except the USB mutex. 00966 if( TRUE == x_supervisor_SemaphoreTake( xLOGMutex, 0 ) ) u8IsMaintenanceRequired++; 00967 #if NW_INTEGRATED_IN_CONTROL_PANEL 00968 if( TRUE == x_supervisor_SemaphoreTake( xWEBMutex, 0 ) ) u8IsMaintenanceRequired++; 00969 #endif 00970 if( TRUE == x_supervisor_SemaphoreTake( xSHELLFSMutex, 0 ) ) u8IsMaintenanceRequired++; 00971 if( TRUE == x_supervisor_SemaphoreTake( xCFGMutex, 0 ) ) u8IsMaintenanceRequired++; 00972 00973 // If all mutexes have been acquired, switch to maintenance mode. 00974 if( ( SUPERVISOR_MAINTENANCE_NBMUTEX_TOTAKE +1 ) == u8IsMaintenanceRequired ) 00975 { 00976 fat_cache_flush(); // flush the FAT cache. 00977 nav_reset(); // Reset all file system navigators. We will mount 00978 // the com1shell default drive when we'll leave the 00979 // maintenance mode. 00980 // Switch to maintenance mode. 00981 xSemaphoreGive( xUSBMutex ); 00982 00983 // If the USB clock is frozen, unfreeze it so that we can write in the 00984 // USB registers. 00985 if(TRUE == Is_usb_clock_frozen()) 00986 { 00987 Usb_unfreeze_clock(); 00988 } 00989 // If it is not akready detached, physically detach the USB device. 00990 if(FALSE == Is_usb_detached()) 00991 { 00992 Usb_detach(); 00993 } 00994 vTaskDelay(500); // Wait 500ms 00995 Usb_attach(); // Reconnect the device. 00996 00997 bIsInMaintenance = TRUE; 00998 u8IsMaintenanceRequired = 0; 00999 TRACE_COM2( "Entering maintenance mode"); 01000 #ifdef MMILCD_ENABLE 01001 vMMI_SetUserMenuMode( eUserMenuWaitHost, pdTRUE ); 01002 #endif 01003 } 01004 // ELSE: we'll switch to maintenance mode in x_supervisor_SemaphoreGive() 01005 // (when the mutex(es) that we couldn't get will be released). 01006 } 01007 else 01008 { 01009 NAKED_TRACE_COM2( "Won't go to maintenance mode:"CRLF"bIsInMaintenance=%d u8CurrentUsbRole=%d u8IsMaintenanceRequired=%d", bIsInMaintenance, u8CurrentUsbRole, u8IsMaintenanceRequired ); 01010 } 01011 #endif 01012 #endif 01013 01014 return( SHELL_EXECSTATUS_OK ); 01015 }
eExecStatus e_syscmds_cmd_get_config | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The get sys config command: get the config fields value of a subsystem Takes one parameter, that is the subsystem's name. Format: get_sys_config sys=sysname.
The get sys config command: get the config fields value of a subsystem Takes one parameter, that is the subsystem's name. Format: get_sys_config sysname.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 1. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 141 of file syscmds.c.
References e_cptime_cmd_get_config(), e_ethernet_cmd_get_config(), e_smtpclient_cmd_get_config(), e_webserver_cmd_get_config(), and SHELL_EXECSTATUS_KO.
00144 { 00145 if ( !strcmp( (char *)av[1], "net" ) ) 00146 { 00147 return (e_ethernet_cmd_get_config( xModId, FsNavId, ac, av, ppcStringReply)); 00148 } 00149 else if ( !strcmp( (char *)av[1], "http" ) ) 00150 { 00151 return (e_webserver_cmd_get_config( xModId, FsNavId, ac, av, ppcStringReply)); 00152 } 00153 else if ( !strcmp( (char *)av[1], "time" ) ) 00154 { 00155 return (e_cptime_cmd_get_config( xModId, FsNavId, ac, av, ppcStringReply)); 00156 } 00157 else if ( !strcmp( (char *)av[1], "smtp" ) ) 00158 { 00159 return (e_smtpclient_cmd_get_config( xModId, FsNavId, ac, av, ppcStringReply)); 00160 } 00161 else return( SHELL_EXECSTATUS_KO ); 00162 }
eExecStatus e_syscmds_cmd_set_config | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The set sys config command: set the value of a config field of a subsystem. Takes three parameters. The first parameter is the system's name, the second parameter is the config field name, the third parameter is its value. Format: set_sys_config sys=sysname field=value.
The set sys config command: set the value of a config field of a subsystem. Takes three parameters. The first parameter is the system's name, the second parameter is the config field name, the third parameter is its value. Format: set_sys_config sysname field=value.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 3. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 185 of file syscmds.c.
References e_cptime_cmd_set_config(), e_ethernet_cmd_set_config(), e_smtpclient_cmd_set_config(), e_webserver_cmd_set_config(), SHELL_ERRMSG_MAINTENANCEMODE, SHELL_EXECSTATUS_KO, x_supervisor_SemaphoreGive(), x_supervisor_SemaphoreTake(), and xCFGMutex.
00188 { 00189 eExecStatus xRet = SHELL_EXECSTATUS_KO; 00190 00191 00192 // Take the CFG mutex. 00193 if( pdFALSE == x_supervisor_SemaphoreTake( xCFGMutex, 0 ) ) 00194 { 00195 if( NULL != ppcStringReply ) 00196 { 00197 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MAINTENANCEMODE; 00198 } 00199 return( SHELL_EXECSTATUS_KO ); 00200 } 00201 else if ( !strcmp( (char *)av[1], "net" ) ) 00202 { 00203 xRet = e_ethernet_cmd_set_config( xModId, FsNavId, ac-2, &(av[2]), ppcStringReply ); 00204 } 00205 else if ( !strcmp( (char *)av[1], "http" ) ) 00206 { 00207 xRet = e_webserver_cmd_set_config( xModId, FsNavId, ac-2, &(av[2]), ppcStringReply ); 00208 } 00209 else if ( !strcmp( (char *)av[1], "time" ) ) 00210 { 00211 xRet = e_cptime_cmd_set_config( xModId, FsNavId, ac-2, &(av[2]), ppcStringReply ); 00212 } 00213 else if ( !strcmp( (char *)av[1], "smtp" ) ) 00214 { 00215 xRet = e_smtpclient_cmd_set_config( xModId, FsNavId, ac-2, &(av[2]), ppcStringReply); 00216 } 00217 00218 x_supervisor_SemaphoreGive( xCFGMutex ); // Release the CFG mutex. 00219 return( xRet ); 00220 }
eExecStatus e_syscmds_help | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The sys help command: display the system & subsystems available shell commands. Format: help.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Ignored. | |
av | Ignored. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 239 of file syscmds.c.
References SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK_NO_FREE, and SYSCMDS_MSG_HELP.
Referenced by e_Shell_help().
00242 { 00243 // 1) If the way to reply is unavailable, it's no use to continue. 00244 if( ppcStringReply == NULL ) 00245 return( SHELL_EXECSTATUS_KO ); 00246 00247 // 2) Perform the command. 00248 *ppcStringReply = (signed portCHAR *)SYSCMDS_MSG_HELP; 00249 00250 return( SHELL_EXECSTATUS_OK_NO_FREE ); 00251 }
eExecStatus e_syscmds_reboot | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The sys reboot command: Sw reset of the Ctrl Panel. Format: reboot.
The sys reboot command. Format: reboot.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Ignored. | |
av | Ignored. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 271 of file syscmds.c.
References b_supervisor_IsInMaintenanceMode(), e_supervisor_switch_to_maintenance_mode(), SHELL_EXECSTATUS_OK, v_com1shell_stopResources(), v_ethernet_stopResources(), v_sensor_stop(), and v_tracedump_stopResources().
00274 { 00275 int LimitWaitMaintenanceCount = 1024; 00276 00277 00278 // Switch to maintenance mode: safety in case a task is currently accessing the 00279 // file system in write mode. 00280 e_supervisor_switch_to_maintenance_mode( xModId, FsNavId, 0, NULL, NULL ); 00281 00282 // Wait until the Ctrl Panel is in maintenance mode before performing the sw 00283 // reset. 00284 // PROS: safer because the switch to maintenance mode is not necessarily immediate. 00285 // CONS: if we want to perform a sw reset, this may be because the Control Panel 00286 // is in an instable state (and/or one or several tasks have crashed); in this 00287 // case, the wait below may end-up being an infinite loop. 00288 // Limit the waiting time to avoid falling into an infinite loop. 00289 while( ( FALSE == b_supervisor_IsInMaintenanceMode() ) && LimitWaitMaintenanceCount-- ); 00290 00291 //** 00292 //** Sw reset. 00293 //** 00294 // NOTE: we have to stop all possible ITs else there is a risk to get ITs 00295 // just after the sw reset while the modules init has not yet been performed 00296 // (especially while the ITs registering have not all been performed). 00297 Disable_global_interrupt(); 00298 // Disable USB IT. 00299 Usb_disable(); 00300 // Disable COM1 IT. 00301 v_com1shell_stopResources(); 00302 // Disable COM2 IT. 00303 v_tracedump_stopResources(); 00304 // Disable SENSORS IT. 00305 v_sensor_stop(); 00306 // Disable MACB IT. 00307 v_ethernet_stopResources(); 00308 Enable_global_interrupt(); 00309 Usb_disable_otg_pad(); 00310 // Reset_CPU(); 00311 00312 return( SHELL_EXECSTATUS_OK ); 00313 }
eExecStatus e_syscmds_trace | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The dbgtrace command: displays info on the trace port(USART1). Format: dbgtrace.
The dbgtrace command: displays info on the trace port(USART1). Format: dbgtrace.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Ignored. | |
av | Ignored. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 365 of file syscmds.c.
References SHELL_EXECSTATUS_OK, and v_syscmds_display_traces().
00368 { 00369 if( NULL != ppcStringReply ) 00370 *ppcStringReply = NULL; 00371 v_syscmds_display_traces(); // Display the debug traces on the trace port. 00372 return( SHELL_EXECSTATUS_OK ); 00373 }
eExecStatus e_syscmds_version | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The sys version command: Display the Ctrl Panel sw version. Format: version.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Ignored. | |
av | Ignored. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 333 of file syscmds.c.
References pcCtrlPanelVersion, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK_NO_FREE.
00336 { 00337 // 1) If the way to reply is unavailable, it's no use to continue. 00338 if( ppcStringReply == NULL ) 00339 return( SHELL_EXECSTATUS_KO ); 00340 00341 // 2) Perform the command. 00342 *ppcStringReply = (signed portCHAR *)pcCtrlPanelVersion; 00343 00344 return( SHELL_EXECSTATUS_OK_NO_FREE ); 00345 }
void v_syscmds_display_traces | ( | void | ) |
Display debug info on the trace port(USART1).
Definition at line 380 of file syscmds.c.
References NAKED_TRACE_COM2.
Referenced by e_syscmds_trace(), and portTASK_FUNCTION().
00381 { 00382 #if configCTRLPANEL_TRACE == 1 00383 #if configSTACK_CONSUMPTION_CHECK 00384 // Print the OS currently active tasks and info. 00385 /* WARNING FROM FREERTOS: This is a VERY costly function that should be used 00386 for debug only. It leaves interrupts disabled for a LONG time. */ 00387 vTaskList( acTaskListInfo ); 00388 NAKED_TRACE_COM2( "%s", acTaskListInfo ); 00389 #endif 00390 // Print dev info trace of several ctrl Panel modules. 00391 v_cptime_trace(); // cptime.c module 00392 v_datalog_trace(); // datalog.c module 00393 #ifdef NW_INTEGRATED_IN_CONTROL_PANEL 00394 v_basicweb_trace(); // BasicWEB.c module 00395 #endif 00396 v_supervisor_trace(); // supervisor.c module 00397 #endif 00398 }
const char* const pcCtrlPanelVersion |
The Ctrl Panel sw version.
Definition at line 100 of file main.c.
Referenced by e_syscmds_version().
const signed portCHAR* const SYSCMDS_MSG_HELP |
Initial value:
(signed portCHAR *)"\ "CRLF"get_sys_config sys={net,http,time} : display the config of a system module"CRLF"\ set_sys_config sys=net {macaddr,ipaddr,submask,gwaddr}=value : set one of the config fields of the network module"CRLF"\ set_sys_config sys=http port=value : set the HTTP port of the Web server module"CRLF"\ set_sys_config sys=time curtime=\"mm/dd/yy hh:mm:ss\" : set the current time of the Control Panel"CRLF"\ set_sys_config sys=smtp {port,mailto,mailfrom,server}=value : set one of the config fields of the SMTP client"CRLF"\ maintain : switch to maintenance mode"CRLF"\ cp_logs_to_ukey : cp the /LOG dir to a USB Mass Storage device"CRLF "reboot : sw reset"CRLF"\ lsusb : display info on the USB conn(DEVELOPMENT ONLY)"CRLF "\ version: display the Ctrl Panel sw version."CRLF
Definition at line 86 of file syscmds.c.
Referenced by e_syscmds_help().
xSemaphoreHandle xCFGMutex |
The CFG system mutex.
Definition at line 203 of file supervisor.c.