Module_ConfigTools.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * Module_ConfigTools.c
  3. *
  4. * Created on: 2020年6月22日
  5. * Author: foluswen
  6. */
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #include <sys/time.h>
  10. #include <sys/timeb.h>
  11. #include <sys/types.h>
  12. #include <sys/ioctl.h>
  13. #include <sys/socket.h>
  14. #include <sys/ipc.h>
  15. #include <sys/shm.h>
  16. #include <sys/mman.h>
  17. #include <linux/wireless.h>
  18. #include <arpa/inet.h>
  19. #include <netinet/in.h>
  20. #include <dirent.h>
  21. #include <unistd.h>
  22. #include <stdarg.h>
  23. #include <stdio.h> /*標準輸入輸出定義*/
  24. #include <stdlib.h> /*標準函數庫定義*/
  25. #include <unistd.h> /*Unix 標準函數定義*/
  26. #include <fcntl.h> /*檔控制定義*/
  27. #include <termios.h> /*PPSIX 終端控制定義*/
  28. #include <errno.h> /*錯誤號定義*/
  29. #include <errno.h>
  30. #include <string.h>
  31. #include <time.h>
  32. #include <ctype.h>
  33. #include <ifaddrs.h>
  34. #include <stdbool.h>
  35. #include <stddef.h>
  36. #include <stdint.h>
  37. #include "define.h"
  38. //=================================
  39. // System basic sample constant
  40. //=================================
  41. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  42. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  43. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  44. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  45. #define PASS 1
  46. #define FAIL -1
  47. #define YES 1
  48. #define NO 0
  49. #define ON 1
  50. #define OFF 0
  51. #define MtdBlockSize 0x300000
  52. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  53. struct StatusCodeData *ShmStatusCodeData;
  54. int StoreLogMsg(const char *fmt, ...)
  55. {
  56. char Buf[4096+256];
  57. char buffer[4096];
  58. time_t CurrentTime;
  59. struct tm *tm;
  60. struct timeval tv;
  61. va_list args;
  62. va_start(args, fmt);
  63. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  64. va_end(args);
  65. memset(Buf,0,sizeof(Buf));
  66. CurrentTime = time(NULL);
  67. tm=localtime(&CurrentTime);
  68. gettimeofday(&tv, NULL); // get microseconds, 10^-6
  69. sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]ConfigToolsLog",
  70. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
  71. buffer,
  72. tm->tm_year+1900,tm->tm_mon+1);
  73. #ifdef SystemLogMessage
  74. system(Buf);
  75. #endif
  76. #ifdef ConsloePrintLog
  77. printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
  78. #endif
  79. return rc;
  80. }
  81. int runShellCmd(const char*cmd)
  82. {
  83. int result = FAIL;
  84. char buf[256];
  85. FILE *fp;
  86. fp = popen(cmd, "r");
  87. if(fp != NULL)
  88. {
  89. while(fgets(buf, sizeof(buf), fp) != NULL)
  90. {
  91. DEBUG_INFO("%s\n", buf);
  92. }
  93. result = PASS;
  94. }
  95. pclose(fp);
  96. return result;
  97. }
  98. int StoreUsrConfigData(struct SysConfigData *UsrData)
  99. {
  100. int result = PASS;
  101. int fd,wrd;
  102. unsigned int i,Chk;
  103. unsigned char *ptr, *BufTmp;
  104. Chk=0;
  105. ptr=(unsigned char *)UsrData;
  106. if((BufTmp=malloc(MtdBlockSize))!=NULL)
  107. {
  108. memset(BufTmp,0,MtdBlockSize);
  109. memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
  110. for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
  111. Chk+=*(BufTmp+i);
  112. memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
  113. // Output configuration to file.
  114. fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
  115. if (fd < 0)
  116. {
  117. DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
  118. free(BufTmp);
  119. return 0;
  120. }
  121. wrd=write(fd, BufTmp, MtdBlockSize);
  122. close(fd);
  123. if(wrd<MtdBlockSize)
  124. {
  125. DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
  126. free(BufTmp);
  127. return 0;
  128. }
  129. DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
  130. DEBUG_INFO("Erase /dev/mtd10.\n");
  131. runShellCmd("flash_erase /dev/mtd10 0 12");
  132. DEBUG_INFO("Write /dev/mtd10.\n");
  133. runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
  134. DEBUG_INFO("Erase /dev/mtd11.\n");
  135. runShellCmd("flash_erase /dev/mtd11 0 12");
  136. DEBUG_INFO("Write /dev/mtd11.\n");
  137. runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
  138. system("rm -f /mnt/EvseConfig.bin");
  139. DEBUG_INFO("EvseConfig write to flash OK\n");
  140. }
  141. else
  142. {
  143. DEBUG_ERROR("alloc BlockSize NG\r\n");
  144. result = FAIL;
  145. }
  146. if(BufTmp!=NULL)
  147. free(BufTmp);
  148. return result;
  149. }
  150. int InitShareMemory()
  151. {
  152. int result = PASS;
  153. int MeterSMId;
  154. //Initial ShmSysConfigAndInfo
  155. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  156. {
  157. #ifdef SystemLogMessage
  158. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  159. #endif
  160. result = FAIL;
  161. }
  162. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  163. {
  164. #ifdef SystemLogMessage
  165. DEBUG_ERROR("[shmat ShmSysConfigAndInfo NG\n");
  166. #endif
  167. result = FAIL;
  168. }
  169. //Initial ShmStatusCodeData
  170. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  171. {
  172. #ifdef SystemLogMessage
  173. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  174. #endif
  175. result = FAIL;
  176. }
  177. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  178. {
  179. #ifdef SystemLogMessage
  180. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  181. #endif
  182. result = FAIL;
  183. }
  184. return result;
  185. }
  186. int main(void)
  187. {
  188. char cmd[128];
  189. if(InitShareMemory() == FAIL)
  190. {
  191. #ifdef SystemLogMessage
  192. DEBUG_ERROR("InitShareMemory NG\n");
  193. #endif
  194. if(ShmStatusCodeData!=NULL)
  195. {
  196. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  197. }
  198. sleep(5);
  199. return 0;
  200. }
  201. else
  202. {
  203. DEBUG_INFO("InitShareMemory OK.\r\n");
  204. }
  205. for(;;)
  206. {
  207. system("clear");
  208. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  209. printf("\n ===== main menu ===================================");
  210. printf("\n system: system configuration menu.");
  211. printf("\n ocpp: ocpp configuration menu.");
  212. printf("\n network: netwok configuration menu.");
  213. printf("\n upgrade: trigger firmware upgrade.");
  214. printf("\n save: Save config.");
  215. printf("\n exit: Exit config tools.");
  216. printf("\n =================================================");
  217. printf("\n Please input item name to config: ");
  218. scanf("%s", &cmd[0]);
  219. if(strcmp(cmd, "system") == 0)
  220. {
  221. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  222. printf("\n ***** system configuration menu ******************");
  223. printf("\n modelname: EVSE model name.");
  224. printf("\n serialnumber: EVSE serial number.");
  225. printf("\n *************************************************");
  226. printf("\n Please input operation item: ");
  227. scanf("%s", &cmd[0]);
  228. if(strcmp(cmd, "modelname") == 0)
  229. {
  230. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  231. printf("\n *************************************************");
  232. printf("\n Current model name: %s", ShmSysConfigAndInfo->SysConfig.ModelName);
  233. printf("\n 0: Keep current config.");
  234. printf("\n 1: Input new model name.");
  235. printf("\n *************************************************");
  236. printf("\n Please input operation item: ");
  237. scanf("%s", &cmd[0]);
  238. if(atoi(cmd) == 1)
  239. {
  240. printf("\n Please input model name: ");
  241. scanf("%s", &cmd[0]);
  242. memset(&ShmSysConfigAndInfo->SysConfig.ModelName[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
  243. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.ModelName[0], (char*)&cmd[0]);
  244. }
  245. }
  246. else if(strcmp(cmd, "serialnumber") == 0)
  247. {
  248. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  249. printf("\n *************************************************");
  250. printf("\n Current serial number: %s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  251. printf("\n 0: Keep current config.");
  252. printf("\n 1: Input new serial number.");
  253. printf("\n *************************************************");
  254. printf("\n Please input operation item: ");
  255. scanf("%s", &cmd[0]);
  256. if(atoi(cmd) == 1)
  257. {
  258. printf("\n Please input serial number: ");
  259. scanf("%s", &cmd[0]);
  260. memset(&ShmSysConfigAndInfo->SysConfig.SerialNumber[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
  261. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.SerialNumber[0], (char*)&cmd[0]);
  262. }
  263. }
  264. }
  265. else if(strcmp(cmd, "ocpp") == 0)
  266. {
  267. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  268. printf("\n *************************************************");
  269. printf("\n ocppurl: OCPP backend server url.");
  270. printf("\n cboxid: Charger box id.");
  271. printf("\n *************************************************");
  272. printf("\n Please input operation item: ");
  273. scanf("%s", &cmd[0]);
  274. if(strcmp(cmd, "ocppurl") == 0)
  275. {
  276. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  277. printf("\n *************************************************");
  278. printf("\n Current OCPP url: %s", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  279. printf("\n 0: Keep current config.");
  280. printf("\n 1: Input new ocpp url.");
  281. printf("\n *************************************************");
  282. printf("\n Please input operation item: ");
  283. scanf("%s", &cmd[0]);
  284. if(atoi(cmd) == 1)
  285. {
  286. printf("\n Please input ocpp url: ");
  287. scanf("%s", &cmd[0]);
  288. memset(&ShmSysConfigAndInfo->SysConfig.OcppServerURL[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  289. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.OcppServerURL[0], (char*)&cmd[0]);
  290. }
  291. }
  292. else if(strcmp(cmd, "cboxid") == 0)
  293. {
  294. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  295. printf("\n *************************************************");
  296. printf("\n Current OCPP charger box id: %s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  297. printf("\n 0: Keep current config.");
  298. printf("\n 1: Input new charger box id.");
  299. printf("\n *************************************************");
  300. printf("\n Please input operation item: ");
  301. scanf("%s", &cmd[0]);
  302. if(atoi(cmd) == 1)
  303. {
  304. printf("\n Please input OCPP charger box id: ");
  305. scanf("%s", &cmd[0]);
  306. memset(&ShmSysConfigAndInfo->SysConfig.ChargeBoxId[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ChargeBoxId));
  307. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId[0], (char*)&cmd[0]);
  308. }
  309. }
  310. }
  311. else if(strcmp(cmd, "network") == 0)
  312. {
  313. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  314. printf("\n *************************************************");
  315. printf("\n ethdhcp: Ethernet DHCP client.");
  316. printf("\n wifimode: WiFi mode.");
  317. printf("\n wifidhcp: WiFi DHCP client.");
  318. printf("\n wificssid: WiFi client SSID.");
  319. printf("\n wificpasswd: WiFi client password.");
  320. printf("\n telemode: Telecomm mode.");
  321. printf("\n teleapn: Telecomm APN.");
  322. printf("\n teleid: Telecomm login id.");
  323. printf("\n telepwd: Telecomm login password.");
  324. printf("\n *************************************************");
  325. printf("\n Please input operation item: ");
  326. scanf("%s", &cmd[0]);
  327. if(strcmp(cmd, "ethdhcp") == 0)
  328. {
  329. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  330. printf("\n *************************************************");
  331. printf("\n 0: Disable.");
  332. printf("\n 1: Enable.");
  333. printf("\n *************************************************");
  334. printf("\n Current ethernet dhcp mode: %d", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient^1);
  335. printf("\n Please input dhcp mode: ");
  336. scanf("%s", &cmd[0]);
  337. ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd)^1:0);
  338. }
  339. else if(strcmp(cmd, "wifimode") == 0)
  340. {
  341. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  342. printf("\n *************************************************");
  343. printf("\n 0: Disable.");
  344. printf("\n 1: Station.");
  345. printf("\n 2: Access point.");
  346. printf("\n *************************************************");
  347. printf("\n Current WiFi mode: %d", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
  348. printf("\n Please input WiFi mode: ");
  349. scanf("%s", &cmd[0]);
  350. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode = ((0<=atoi(cmd))&&(atoi(cmd)<=2)?atoi(cmd):0);
  351. }
  352. else if(strcmp(cmd, "wifidhcp") == 0)
  353. {
  354. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  355. printf("\n *************************************************");
  356. printf("\n 0: Disable.");
  357. printf("\n 1: Enable.");
  358. printf("\n *************************************************");
  359. printf("\n Current WiFi dhcp client mode: %d", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient^1);
  360. printf("\n Please input WiFi mode: ");
  361. scanf("%s", &cmd[0]);
  362. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd)^1:0);
  363. }
  364. else if(strcmp(cmd, "wificssid") == 0)
  365. {
  366. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  367. printf("\n *************************************************");
  368. printf("\n Current WiFi client SSID: %s", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid);
  369. printf("\n 0: Keep current config.");
  370. printf("\n 1: Input new WiFi client SSID.");
  371. printf("\n *************************************************");
  372. printf("\n Please input operation item: ");
  373. scanf("%s", &cmd[0]);
  374. if(atoi(cmd) == 1)
  375. {
  376. printf("\n Please input WiFi client SSID: ");
  377. scanf("%s", &cmd[0]);
  378. memset(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid));
  379. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid[0], (char*)&cmd[0]);
  380. }
  381. }
  382. else if(strcmp(cmd, "wificpasswd") == 0)
  383. {
  384. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  385. printf("\n *************************************************");
  386. printf("\n Current WiFi client password: %s", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword);
  387. printf("\n 0: Keep current config.");
  388. printf("\n 1: Input new WiFi client password.");
  389. printf("\n *************************************************");
  390. printf("\n Please input operation item: ");
  391. scanf("%s", &cmd[0]);
  392. if(atoi(cmd) == 1)
  393. {
  394. printf("\n Please input WiFi client password: ");
  395. scanf("%s", &cmd[0]);
  396. memset(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword));
  397. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword[0], (char*)&cmd[0]);
  398. }
  399. }
  400. else if(strcmp(cmd, "telemode") == 0)
  401. {
  402. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  403. printf("\n *************************************************");
  404. printf("\n 0: Disable.");
  405. printf("\n 1: Enable.");
  406. printf("\n *************************************************");
  407. printf("\n Current telecomm mode: %d", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode^1);
  408. printf("\n Please input telecomm mode: ");
  409. scanf("%s", &cmd[0]);
  410. ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd)^1:0);
  411. }
  412. else if(strcmp(cmd, "teleapn") == 0)
  413. {
  414. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  415. printf("\n *************************************************");
  416. printf("\n Current telecomm APN: %s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn);
  417. printf("\n 0: Keep current config.");
  418. printf("\n 1: Input new telecomm APN.");
  419. printf("\n *************************************************");
  420. printf("\n Please input operation item: ");
  421. scanf("%s", &cmd[0]);
  422. if(atoi(cmd) == 1)
  423. {
  424. printf("\n Please input telecomm APN: ");
  425. scanf("%s", &cmd[0]);
  426. memset(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn));
  427. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn[0], (char*)&cmd[0]);
  428. }
  429. }
  430. else if(strcmp(cmd, "teleid") == 0)
  431. {
  432. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  433. printf("\n *************************************************");
  434. printf("\n Current telecomm login id: %s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId);
  435. printf("\n 0: Keep current config.");
  436. printf("\n 1: Input new telecomm login id.");
  437. printf("\n *************************************************");
  438. printf("\n Please input operation item: ");
  439. scanf("%s", &cmd[0]);
  440. if(atoi(cmd) == 1)
  441. {
  442. printf("\n Please input telecomm login id: ");
  443. scanf("%s", &cmd[0]);
  444. memset(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId));
  445. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId[0], (char*)&cmd[0]);
  446. }
  447. }
  448. else if(strcmp(cmd, "telepwd") == 0)
  449. {
  450. memset(cmd, 0x00, ARRAY_SIZE(cmd));
  451. printf("\n *************************************************");
  452. printf("\n Current telecomm login password: %s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd);
  453. printf("\n 0: Keep current config.");
  454. printf("\n 1: Input new telecomm login password.");
  455. printf("\n *************************************************");
  456. printf("\n Please input operation item: ");
  457. scanf("%s", &cmd[0]);
  458. if(atoi(cmd) == 1)
  459. {
  460. printf("\n Please input telecomm login password: ");
  461. scanf("%s", &cmd[0]);
  462. memset(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd));
  463. strcpy((char*)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd[0], (char*)&cmd[0]);
  464. }
  465. }
  466. }
  467. else if(strcmp(cmd, "upgrade") == 0)
  468. {
  469. printf("\n Firmware upgrade trigger.");
  470. ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = ON;
  471. sleep(2);
  472. }
  473. else if(strcmp(cmd, "save") == 0)
  474. {
  475. if(StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig) != PASS)
  476. {
  477. printf("\n Write configuration fail.\r\n");
  478. }
  479. else
  480. printf("\n Write configuration OK.\r\n");
  481. sleep(2);
  482. }
  483. else if(strcmp(cmd, "exit") == 0)
  484. {
  485. printf("\n exit program.\n\n");
  486. return FAIL;
  487. }
  488. }
  489. return -1;
  490. }