00001
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #include <string.h>
00059 #include "gpio.h"
00060
00061 #include "FreeRTOS.h"
00062 #include "task.h"
00063 #include "shell.h"
00064
00065 #include "ethernet.h"
00066 #include "BasicWEB.h"
00067 #include "BasicSMTP.h"
00068 #include "cptime.h"
00069
00070 #ifdef USB_ENABLE
00071 #include "conf_usb.h"
00072 #include "usb_drv.h"
00073 #include "usb_task.h"
00074 #endif
00075
00076 #include "com1shell.h"
00077 #include "sensor.h"
00078 #include "supervisor.h"
00079 #include "syscmds.h"
00080
00081
00082
00083
00084
00085
00086 const signed portCHAR *const SYSCMDS_MSG_HELP = (signed portCHAR *)"\
00087 "CRLF"get_sys_config sys={net,http,time} : display the config of a system module"CRLF"\
00088 set_sys_config sys=net {macaddr,ipaddr,submask,gwaddr}=value : set one of the config fields of the network module"CRLF"\
00089 set_sys_config sys=http port=value : set the HTTP port of the Web server module"CRLF"\
00090 set_sys_config sys=time curtime=\"mm/dd/yy hh:mm:ss\" : set the current time of the Control Panel"CRLF"\
00091 set_sys_config sys=smtp {port,mailto,mailfrom,server}=value : set one of the config fields of the SMTP client"CRLF"\
00092 maintain : switch to maintenance mode"CRLF"\
00093 cp_logs_to_ukey : cp the /LOG dir to a USB Mass Storage device"CRLF
00094 "reboot : sw reset"CRLF"\
00095 lsusb : display info on the USB conn(DEVELOPMENT ONLY)"CRLF
00096 #if configCTRLPANEL_TRACE == 1
00097 "\
00098 ipstat : display info about the TCP/IP stack on the COM2 port(DEVELOPMENT ONLY)"CRLF"\
00099 dbgtrace : display debug info on the USART1 trace port(DEVELOPMENT ONLY)"CRLF
00100 #endif
00101 "\
00102 version: display the Ctrl Panel sw version."CRLF;
00103
00105 extern xSemaphoreHandle xCFGMutex;
00106
00108 extern const char *const pcCtrlPanelVersion;
00109
00110 eExecStatus e_supervisor_switch_to_maintenance_mode( eModId xModId,
00111 signed short FsNavId,
00112 int ac, signed portCHAR *av[],
00113 signed portCHAR **ppcStringReply );
00114
00115 #if configCTRLPANEL_TRACE == 1
00116 #if configSTACK_CONSUMPTION_CHECK
00117 signed portCHAR acTaskListInfo[1024];
00118 #endif
00119 #endif
00120
00121
00122
00141 eExecStatus e_syscmds_cmd_get_config( eModId xModId, signed short FsNavId,
00142 int ac, signed portCHAR *av[],
00143 signed portCHAR **ppcStringReply )
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 }
00163
00164
00185 eExecStatus e_syscmds_cmd_set_config( eModId xModId, signed short FsNavId,
00186 int ac, signed portCHAR *av[],
00187 signed portCHAR **ppcStringReply )
00188 {
00189 eExecStatus xRet = SHELL_EXECSTATUS_KO;
00190
00191
00192
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 );
00219 return( xRet );
00220 }
00221
00239 eExecStatus e_syscmds_help( eModId xModId, signed short FsNavId,
00240 int ac, signed portCHAR *av[],
00241 signed portCHAR **ppcStringReply )
00242 {
00243
00244 if( ppcStringReply == NULL )
00245 return( SHELL_EXECSTATUS_KO );
00246
00247
00248 *ppcStringReply = (signed portCHAR *)SYSCMDS_MSG_HELP;
00249
00250 return( SHELL_EXECSTATUS_OK_NO_FREE );
00251 }
00252
00253
00271 eExecStatus e_syscmds_reboot( eModId xModId, signed short FsNavId,
00272 int ac, signed portCHAR *av[],
00273 signed portCHAR **ppcStringReply )
00274 {
00275 int LimitWaitMaintenanceCount = 1024;
00276
00277
00278
00279
00280 e_supervisor_switch_to_maintenance_mode( xModId, FsNavId, 0, NULL, NULL );
00281
00282
00283
00284
00285
00286
00287
00288
00289 while( ( FALSE == b_supervisor_IsInMaintenanceMode() ) && LimitWaitMaintenanceCount-- );
00290
00291
00292
00293
00294
00295
00296
00297 Disable_global_interrupt();
00298
00299 Usb_disable();
00300
00301 v_com1shell_stopResources();
00302
00303 v_tracedump_stopResources();
00304
00305 v_sensor_stop();
00306
00307 v_ethernet_stopResources();
00308 Enable_global_interrupt();
00309 Usb_disable_otg_pad();
00310
00311
00312 return( SHELL_EXECSTATUS_OK );
00313 }
00314
00315
00333 eExecStatus e_syscmds_version( eModId xModId, signed short FsNavId,
00334 int ac, signed portCHAR *av[],
00335 signed portCHAR **ppcStringReply )
00336 {
00337
00338 if( ppcStringReply == NULL )
00339 return( SHELL_EXECSTATUS_KO );
00340
00341
00342 *ppcStringReply = (signed portCHAR *)pcCtrlPanelVersion;
00343
00344 return( SHELL_EXECSTATUS_OK_NO_FREE );
00345 }
00346
00347
00365 eExecStatus e_syscmds_trace( eModId xModId, signed short FsNavId,
00366 int ac, signed portCHAR *av[],
00367 signed portCHAR **ppcStringReply )
00368 {
00369 if( NULL != ppcStringReply )
00370 *ppcStringReply = NULL;
00371 v_syscmds_display_traces();
00372 return( SHELL_EXECSTATUS_OK );
00373 }
00374
00375
00380 void v_syscmds_display_traces( void )
00381 {
00382 #if configCTRLPANEL_TRACE == 1
00383 #if configSTACK_CONSUMPTION_CHECK
00384
00385
00386
00387 vTaskList( acTaskListInfo );
00388 NAKED_TRACE_COM2( "%s", acTaskListInfo );
00389 #endif
00390
00391 v_cptime_trace();
00392 v_datalog_trace();
00393 #ifdef NW_INTEGRATED_IN_CONTROL_PANEL
00394 v_basicweb_trace();
00395 #endif
00396 v_supervisor_trace();
00397 #endif
00398 }