ReadCmdline.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. /*
  2. * Main.c
  3. *
  4. * Created on: 2019年8月6日
  5. * Author: 7564
  6. */
  7. #include <sys/time.h>
  8. #include <sys/timeb.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.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/shm.h>
  17. #include <sys/mman.h>
  18. #include <linux/wireless.h>
  19. #include <arpa/inet.h>
  20. #include <netinet/in.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 <math.h>
  35. #include <stdbool.h>
  36. #include "../../define.h"
  37. typedef unsigned char byte;
  38. #define PASS 1
  39. #define FAIL -1
  40. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  41. #define NO_DEFINE 255
  42. #define DEFAULT_AC_INDEX 2
  43. #define TTY_PATH "/dev/tty"
  44. #define STTY_US "stty raw -echo -F "
  45. #define STTY_DEF "stty -raw echo -F "
  46. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  47. struct StatusCodeData *ShmStatusCodeData;
  48. struct PrimaryMcuData *ShmPrimaryMcuData;
  49. struct CHAdeMOData *ShmCHAdeMOData;
  50. struct CcsData *ShmCcsData;
  51. struct GBTData *ShmGBTData;
  52. struct FanModuleData *ShmFanModuleData;
  53. struct RelayModuleData *ShmRelayModuleData;
  54. struct LedModuleData *ShmLedModuleData;
  55. struct PsuData *ShmPsuData;
  56. struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  57. struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
  58. char *msg = "state : get gun state (index) \n"
  59. "card : scanning card (x) : \n"
  60. "gun : get gun plugit state (index) \n"
  61. "lock : get gun locked state (index) \n"
  62. "self : self test state (x) \n"
  63. "ver : ver of board (407 or index or rb or fan) \n"
  64. "ac : get ac relay state (x) \n";
  65. bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
  66. {
  67. for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
  68. {
  69. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
  70. {
  71. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
  72. return true;
  73. }
  74. }
  75. for (byte index = 0; index < CCS_QUANTITY; index++)
  76. {
  77. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
  78. {
  79. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
  80. return true;
  81. }
  82. }
  83. for (byte index = 0; index < GB_QUANTITY; index++)
  84. {
  85. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
  86. {
  87. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
  88. return true;
  89. }
  90. }
  91. return false;
  92. }
  93. bool FindAcChargingInfoData(byte target, struct ChargingInfoData **acChargingData)
  94. {
  95. if (target < AC_QUANTITY)
  96. {
  97. acChargingData[target] = &ShmSysConfigAndInfo->SysInfo.AcChargingData[target];
  98. return true;
  99. }
  100. return false;
  101. }
  102. int InitShareMemory()
  103. {
  104. int result = PASS;
  105. int MeterSMId;
  106. //initial ShmSysConfigAndInfo
  107. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  108. {
  109. result = FAIL;
  110. }
  111. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  112. {
  113. result = FAIL;
  114. }
  115. else
  116. {}
  117. //initial ShmStatusCodeData
  118. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  119. {
  120. result = FAIL;
  121. }
  122. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  123. {
  124. result = FAIL;
  125. }
  126. else
  127. {}
  128. if (CHAdeMO_QUANTITY > 0) {
  129. if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData), IPC_CREAT | 0777)) < 0)
  130. {
  131. result = FAIL;
  132. }
  133. else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
  134. result = FAIL;
  135. }
  136. else
  137. {
  138. //NULL
  139. }
  140. }
  141. if (CCS_QUANTITY > 0)
  142. {
  143. if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData), IPC_CREAT | 0777)) < 0)
  144. {
  145. result = FAIL;
  146. }
  147. else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  148. {
  149. result = FAIL;
  150. } else
  151. {
  152. //NULL
  153. }
  154. }
  155. if (GB_QUANTITY > 0)
  156. {
  157. if ((MeterSMId = shmget(ShmGBTCommKey, sizeof(struct GBTData), IPC_CREAT | 0777)) < 0)
  158. {
  159. return 0;
  160. }
  161. else if ((ShmGBTData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  162. {
  163. return 0;
  164. }
  165. memset(ShmGBTData, 0, sizeof(struct GBTData));
  166. }
  167. if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), IPC_CREAT | 0777)) < 0)
  168. {
  169. result = FAIL;
  170. }
  171. else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  172. {
  173. result = FAIL;
  174. }
  175. if ((MeterSMId = shmget(ShmFanBdKey, sizeof(struct FanModuleData), IPC_CREAT | 0777)) < 0)
  176. {
  177. result = FAIL;
  178. }
  179. else if ((ShmFanModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  180. {
  181. result = FAIL;
  182. }
  183. if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), IPC_CREAT | 0777)) < 0)
  184. {
  185. result = FAIL;
  186. }
  187. else if ((ShmRelayModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  188. {
  189. result = FAIL;
  190. }
  191. if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), 0777)) < 0)
  192. {
  193. result = FAIL;
  194. }
  195. else if ((ShmLedModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  196. {
  197. result = FAIL;
  198. }
  199. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), IPC_CREAT | 0777)) < 0)
  200. {
  201. result = FAIL;
  202. }
  203. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  204. {
  205. result = FAIL;
  206. }
  207. return result;
  208. }
  209. unsigned long GetTimeoutValue(struct timeval _sour_time)
  210. {
  211. struct timeval _end_time;
  212. gettimeofday(&_end_time, NULL);
  213. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  214. }
  215. void RunStatusProc(char *v1, char *v2)
  216. {
  217. if (strcmp(v1, "ac") == 0)
  218. {
  219. if (!FindAcChargingInfoData(0, &ac_chargingInfo[0]))
  220. {
  221. printf("FindChargingInfoData (AC) false \n");
  222. }
  223. printf("AC Status = %d \n", ac_chargingInfo[0]->ConnectorPlugIn);
  224. return;
  225. }
  226. int _index = atoi(v1);
  227. if (_index <= 1)
  228. {
  229. if (!FindChargingInfoData(_index, &_chargingData[0]))
  230. {
  231. printf ("FindChargingInfoData error\n");
  232. return;
  233. }
  234. if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
  235. {
  236. // get
  237. printf ("index = %x, status = %x (%d)\n", _index, _chargingData[_index]->SystemStatus, _chargingData[_index]->IsAvailable);
  238. printf ("SystemTimeoutFlag = %d, PageIndex = %d\n",
  239. ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag, ShmSysConfigAndInfo->SysInfo.PageIndex);
  240. }
  241. else
  242. {
  243. // set
  244. _chargingData[_index]->SystemStatus = atoi(v2);
  245. }
  246. }
  247. else
  248. {
  249. if (!FindAcChargingInfoData(0, &ac_chargingInfo[0]))
  250. {
  251. printf("FindChargingInfoData (AC) false \n");
  252. }
  253. if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
  254. {
  255. // get
  256. printf ("AC Type, status = %x (%d)\n", ac_chargingInfo[0]->SystemStatus, ac_chargingInfo[0]->IsAvailable);
  257. }
  258. else
  259. {
  260. // set
  261. ac_chargingInfo[0]->SystemStatus = atoi(v2);
  262. }
  263. }
  264. }
  265. void RunCardProc(char *v1, char *v2)
  266. {
  267. if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0)
  268. {
  269. if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit)
  270. {
  271. ShmSysConfigAndInfo->SysInfo.WaitForPlugit = 0x00;
  272. printf ("SysInfo.WaitForPlugit = %x \n", ShmSysConfigAndInfo->SysInfo.WaitForPlugit);
  273. }
  274. else
  275. {
  276. ShmSysConfigAndInfo->SysInfo.WaitForPlugit = 0x01;
  277. printf ("SysInfo.WaitForPlugit = %x \n", ShmSysConfigAndInfo->SysInfo.WaitForPlugit);
  278. }
  279. }
  280. else
  281. {
  282. strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
  283. memcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, v1, strlen(v1));
  284. ShmSysConfigAndInfo->SysConfig.UserId[strlen(v1)] = '\0';
  285. printf("StartUserId = %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
  286. }
  287. }
  288. void RunGunPlugitProc(char *v1, char *v2)
  289. {
  290. int _index = atoi(v1);
  291. if (!FindChargingInfoData(_index, &_chargingData[0]))
  292. {
  293. printf("FindChargingInfoData error\n");
  294. return;
  295. }
  296. if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
  297. {
  298. // get
  299. printf("index = %x, plug it = %x\n", _index, _chargingData[_index]->ConnectorPlugIn);
  300. }
  301. else
  302. {
  303. // set
  304. _chargingData[_index]->ConnectorPlugIn = atoi(v2);
  305. }
  306. }
  307. void GetGunLockStatusProc(char *v1, char *v2)
  308. {
  309. int _index = atoi(v1);
  310. if (!FindChargingInfoData(_index, &_chargingData[0]))
  311. {
  312. printf("FindChargingInfoData error\n");
  313. return;
  314. }
  315. if (strcmp(v2, "-1") != 0 && strcmp(v2, "") != 0)
  316. {
  317. _chargingData[_index]->GunLocked = atoi(v2);
  318. }
  319. printf("Gun Locked Status = %d \n", _chargingData[_index]->GunLocked);
  320. }
  321. void SetSystemIDProc()
  322. {
  323. char *systemId = "Alston_Test";
  324. memcpy(&ShmSysConfigAndInfo->SysConfig.SystemId, systemId, strlen(systemId));
  325. }
  326. void RunSelfProc()
  327. {
  328. printf("self test status = %x\n", ShmSysConfigAndInfo->SysInfo.SelfTestSeq);
  329. }
  330. void GetFwVerProc(char *v1)
  331. {
  332. if (strcmp(v1, "407") == 0)
  333. {
  334. printf("407 FW Version = %s \n", ShmPrimaryMcuData->version);
  335. }
  336. else if (strcmp(v1, "0") == 0 || strcmp(v1, "1") == 0)
  337. {
  338. int _index = atoi(v1);
  339. if (_index == 0)
  340. printf("Gun 0 FW Version = %s \n", ShmSysConfigAndInfo->SysInfo.Connector1FwRev);
  341. else if (_index == 1)
  342. printf("Gun 1 FW Version = %s \n", ShmSysConfigAndInfo->SysInfo.Connector2FwRev);
  343. }
  344. else if (strcmp(v1, "rb") == 0)
  345. {
  346. printf("RB Version = %s \n", ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev);
  347. }
  348. else if (strcmp(v1, "fan") == 0)
  349. {
  350. printf("FAN Version = %s \n", ShmSysConfigAndInfo->SysInfo.FanModuleFwRev);
  351. }
  352. else if (strcmp(v1, "dc") == 0)
  353. {
  354. printf("DC Main Version = %s \n", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  355. }
  356. else if (strcmp(v1, "led") == 0)
  357. {
  358. printf("LED Version = %s \n", ShmSysConfigAndInfo->SysInfo.LedModuleFwRev);
  359. }
  360. else if (strcmp(v1, "ac") == 0)
  361. {
  362. if (!FindAcChargingInfoData(0, &ac_chargingInfo[0]))
  363. {
  364. printf("FindChargingInfoData (AC) false \n");
  365. }
  366. printf("AC Version = %s \n", ac_chargingInfo[0]->version);
  367. }
  368. }
  369. void CreateOneError(char *v1)
  370. {
  371. int value = atoi(v1);
  372. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PrimaryStestFail = value;
  373. ShmSysConfigAndInfo->SysConfig.BillingData.isBilling = value;
  374. }
  375. void GetAuthorizeFlag(char *v1)
  376. {
  377. if (strcmp(v1, "-1") == 0|| strcmp(v1, "") == 0)
  378. printf("AuthorizeFlag = %d \n", ShmSysConfigAndInfo->SysInfo.AuthorizeFlag);
  379. else
  380. ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = atoi(v1);
  381. }
  382. void GetOrClearId(char *v1)
  383. {
  384. int _index = atoi(v1);
  385. if (!FindChargingInfoData(_index, &_chargingData[0]))
  386. {
  387. printf("FindChargingInfoData error\n");
  388. return;
  389. }
  390. printf("Card Number = %s \n", _chargingData[_index]->StartUserId);
  391. }
  392. void FwUpdateFlagProc()
  393. {
  394. ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = 0x01;
  395. }
  396. void CheckAcStatus(char *v1)
  397. {
  398. if (strcmp(v1, "-1") == 0|| strcmp(v1, "") == 0)
  399. {
  400. printf("AC Status = %d \n", ShmSysConfigAndInfo->SysInfo.AcContactorStatus);
  401. }
  402. }
  403. void SetCableChkStatus(char *v1, char *v2)
  404. {
  405. int _index = atoi(v1);
  406. if (!FindChargingInfoData(_index, &_chargingData[0]))
  407. {
  408. printf ("FindChargingInfoData error\n");
  409. return;
  410. }
  411. _chargingData[_index]->GroundFaultStatus = atoi(v2);
  412. }
  413. void SetPowerValue(char *v1, char *v2)
  414. {
  415. int _index = atoi(v1);
  416. float _Current = atof(v2);
  417. // 盲沖的時候才允許使用~
  418. if (_chargingData[_index]->Type != 9)
  419. return;
  420. if (!FindChargingInfoData(_index, &_chargingData[0]))
  421. {
  422. printf ("FindChargingInfoData error\n");
  423. return;
  424. }
  425. _chargingData[_index]->EvBatterytargetCurrent = _Current;
  426. }
  427. void GetSystemInfo()
  428. {
  429. printf ("ModelName = %s \n", ShmSysConfigAndInfo->SysConfig.ModelName);
  430. printf ("SerialNumber = %s \n", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  431. printf ("InternetConn = %d \n", ShmSysConfigAndInfo->SysInfo.InternetConn);
  432. printf ("MaxChargingPower = %d, MaxChargingCurrent = %d \n",
  433. ShmSysConfigAndInfo->SysConfig.MaxChargingPower,
  434. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  435. }
  436. void ChangeGunNum()
  437. {
  438. if (ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1 < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount)
  439. {
  440. ShmSysConfigAndInfo->SysInfo.CurGunSelected += 1;
  441. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
  442. }
  443. else if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount > 0 &&
  444. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE)
  445. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
  446. else
  447. {
  448. ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
  449. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
  450. }
  451. }
  452. void GetGunSelectedNum(char *v1)
  453. {
  454. if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0)
  455. {
  456. if (AC_QUANTITY > 0 &&
  457. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc != NO_DEFINE)
  458. {
  459. printf("connector select changed = AC \n");
  460. }
  461. else
  462. printf("connector selected = %d \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
  463. }
  464. else
  465. {
  466. int _index = atoi(v1);
  467. if (_index <= 1)
  468. {
  469. ShmSysConfigAndInfo->SysInfo.CurGunSelected = _index;
  470. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
  471. printf("connector select changed = %d \n", _index);
  472. }
  473. else if (AC_QUANTITY > 0)
  474. {
  475. ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
  476. printf("connector select changed = AC \n");
  477. }
  478. }
  479. }
  480. void SetFanSpeed(char *v1)
  481. {
  482. int speed = atoi(v1);
  483. ShmFanModuleData->TestFanSpeed = speed;
  484. }
  485. void GetFanSpeed()
  486. {
  487. printf("ShmFanModuleData->PresentFan1Speed = %d \n", ShmFanModuleData->PresentFan1Speed);
  488. printf("ShmFanModuleData->PresentFan2Speed = %d \n", ShmFanModuleData->PresentFan2Speed);
  489. printf("ShmFanModuleData->PresentFan3Speed = %d \n", ShmFanModuleData->PresentFan3Speed);
  490. printf("ShmFanModuleData->PresentFan4Speed = %d \n", ShmFanModuleData->PresentFan4Speed);
  491. }
  492. void SetDebugMode(char *v1)
  493. {
  494. int mode = atoi(v1);
  495. ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag = mode;
  496. }
  497. void SetGFDMode(char *v1)
  498. {
  499. int mode = atoi(v1);
  500. ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag = mode;
  501. }
  502. void GetPsuTemp()
  503. {
  504. for (byte index = 0; index < ShmPsuData->GroupCount; index++)
  505. {
  506. for (byte count = 0; count < ShmPsuData->PsuGroup[index].GroupPresentPsuQuantity; count++)
  507. {
  508. printf("PSU Temp = %d \n", ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp);
  509. }
  510. }
  511. }
  512. void GetAcInputVol()
  513. {
  514. printf("L1N_L12 = %f, L2N_L23 = %f, L3N_L31 = %f \n",
  515. ShmSysConfigAndInfo->SysInfo.InputVoltageR,
  516. ShmSysConfigAndInfo->SysInfo.InputVoltageS,
  517. ShmSysConfigAndInfo->SysInfo.InputVoltageT);
  518. }
  519. void GetPsuInformation(char *v1)
  520. {
  521. printf("**********************AC Contact needed*************************\n");
  522. if(strcmp(v1, "count") == 0)
  523. {
  524. for (int i = 0; i < 4; i++)
  525. {
  526. printf("Group Index = %d, Module Count = %d \n", i, ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity);
  527. }
  528. }
  529. else if(strcmp(v1, "ver") == 0)
  530. {
  531. for (int i = 0; i < ShmPsuData->SystemPresentPsuQuantity; i++)
  532. {
  533. printf("Psu Index = %d, PriVersion = %s, SecVersion = %s \n",
  534. i, ShmPsuData->PsuVersion[i].FwPrimaryVersion, ShmPsuData->PsuVersion[i].FwSecondVersion);
  535. }
  536. for (int i = 0; i < ShmPsuData->GroupCount; i++)
  537. {
  538. for (int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++)
  539. {
  540. printf("Group Index = %d, Psu Index = %d, Version = %s \n",
  541. i, j, ShmPsuData->PsuGroup[i].PsuModule[j].FwVersion);
  542. }
  543. }
  544. }
  545. else if(strcmp(v1, "cap") == 0)
  546. {
  547. for (int i = 0; i < ShmPsuData->GroupCount; i++)
  548. {
  549. printf("Group Index = %d, MaxCur = %d, Power = %d \n",
  550. i, ShmPsuData->PsuGroup[i].GroupAvailableCurrent, ShmPsuData->PsuGroup[i].GroupAvailablePower);
  551. }
  552. }
  553. else if (strcmp(v1, "output") == 0)
  554. {
  555. for (int i = 0; i < ShmPsuData->GroupCount; i++)
  556. {
  557. printf("Group Index = %d, OutputV = %d, OutputC = %d \n",
  558. i, ShmPsuData->PsuGroup[i].GroupPresentOutputVoltage, ShmPsuData->PsuGroup[i].GroupPresentOutputCurrent);
  559. }
  560. }
  561. printf("*************************************************\n");
  562. }
  563. void GetConnectorCapInfo(char *v1)
  564. {
  565. int _GunIndex = atoi(v1);
  566. if (!FindChargingInfoData(_GunIndex, &_chargingData[0]))
  567. {
  568. printf ("FindChargingInfoData error\n");
  569. return;
  570. }
  571. printf ("Charger Max Current = %d, Max Power = %d \n",
  572. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10,
  573. ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
  574. printf ("Index = %d, MaxPow = %f, MaxVol = %f, MaxCur = %f\n",
  575. _GunIndex,
  576. _chargingData[_GunIndex]->RealMaxPower,
  577. _chargingData[_GunIndex]->RealMaxVoltage,
  578. _chargingData[_GunIndex]->RealMaxCurrent);
  579. }
  580. static void get_char(char *word)
  581. {
  582. fd_set rfds;
  583. struct timeval tv;
  584. FD_ZERO(&rfds);
  585. FD_SET(0, &rfds);
  586. tv.tv_sec = 0;
  587. tv.tv_usec = 10; //wait input timout time
  588. //if input
  589. if (select(1, &rfds, NULL, NULL, &tv) > 0)
  590. {
  591. fgets(word, 128, stdin);
  592. }
  593. }
  594. void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
  595. {
  596. int _GunIndex = atoi(v1);
  597. float _Voltage = atof(v2);
  598. float _Current = atof(v3);
  599. unsigned char PreviousSystemStatus = 0xff;
  600. if (!FindChargingInfoData(_GunIndex, &_chargingData[0]))
  601. {
  602. printf ("FindChargingInfoData error\n");
  603. return;
  604. }
  605. printf ("ReqVoltage = %f, ReqCurrent = %f\n", _Voltage, _Current);
  606. if(_Voltage > 1000 || _Voltage < 50)
  607. {
  608. printf ("Input Voltage over range\n");
  609. return;
  610. }
  611. // if(_Current > 100 || _Current < 2){
  612. //
  613. // printf ("Input Current over range\n");
  614. // return;
  615. // }
  616. //測試期間先跳過自我測試 _STEST_COMPLETE = 0xfe
  617. //ShmSysConfigAndInfo->SysInfo.SelfTestSeq = 0xfe;
  618. //kill ev task
  619. system("killall Module_EvComm");
  620. //_Voltage = (_Voltage * 10);
  621. //_Current = (_Current * 10);
  622. //system(STTY_US TTY_PATH);
  623. while(true)
  624. {
  625. //fix gun 1
  626. ShmSysConfigAndInfo->SysInfo.CurGunSelected = _GunIndex;
  627. switch(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  628. {
  629. case S_IDLE:
  630. {
  631. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  632. {
  633. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  634. printf ("[UnconditionalCharge - S_IDLE]\n");
  635. }
  636. ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x01;
  637. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_PREPARNING;
  638. }
  639. break;
  640. case S_PREPARNING:
  641. {
  642. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  643. {
  644. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  645. printf ("[UnconditionalCharge - S_PREPARNIN]\n");
  646. //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
  647. printf ("wait find module\n");
  648. }
  649. //main 會在此階段判斷以下資料跳到下一個 state
  650. //用來得知 AC 是否有搭上 (搭上模組的資訊才會出來) 因為每次 AC_Contactor
  651. //ShmPsuData->SystemPresentPsuQuantity;
  652. //ShmPsuData->PsuGroup[gun_index].GroupPresentPsuQuantity;
  653. //ShmPsuData->PsuGroup[gun_index].GroupAvailablePower;
  654. //_chargingData[gun_index]->AvailableChargingPower;
  655. //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
  656. //sleep(10);
  657. //清除 main timeout 機制
  658. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
  659. //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
  660. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
  661. }
  662. break;
  663. case S_PREPARING_FOR_EV:
  664. {
  665. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  666. {
  667. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  668. printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
  669. printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage * 10,_Current * 10);
  670. }
  671. //清除 main timeout 機制
  672. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
  673. //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
  674. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
  675. //充電電壓電流
  676. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
  677. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 500;
  678. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 2;
  679. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
  680. //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
  681. //確定模組己升壓完成
  682. //if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage <= (3000+500) &&
  683. // _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage >= (3000-500) )
  684. {
  685. printf ("Precharge Done = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
  686. //EV done
  687. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_PREPARING_FOR_EVSE;
  688. }
  689. }
  690. break;
  691. case S_PREPARING_FOR_EVSE:
  692. {
  693. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  694. {
  695. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  696. printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
  697. }
  698. //printf ("tar vol = %d \n", _Voltage);
  699. //printf ("tar cur = %d \n", _Current);
  700. //清除 main timeout 機制
  701. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
  702. //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
  703. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
  704. //充電電壓電流
  705. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
  706. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 500;
  707. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 2;
  708. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
  709. //printf ("tar vol_ = %d \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage);
  710. // printf ("tar cur_ = %d \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent);
  711. //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
  712. //確定模組己升壓完成
  713. if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x01 ||
  714. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x03)
  715. {
  716. printf ("First Ground Fault State (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
  717. printf ("Wait K1K2 = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
  718. sleep(5);
  719. //EV done
  720. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_CHARGING;
  721. }
  722. else if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus > 0x02)
  723. {
  724. printf ("First Ground Fault check Fail (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
  725. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
  726. }
  727. }
  728. break;
  729. case S_CHARGING:
  730. {
  731. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  732. {
  733. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  734. //充電電壓電流
  735. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
  736. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _Voltage;
  737. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _Current;
  738. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
  739. printf ("[UnconditionalCharge - S_CHARGING]\n");
  740. }
  741. //ev task do this
  742. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingPower =
  743. ((float)((_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage) * (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingCurrent)) / 1000);
  744. if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x02)
  745. {
  746. printf ("Charging Ground Fault check Fail (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
  747. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
  748. }
  749. }
  750. break;
  751. case S_TERMINATING:
  752. {
  753. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  754. {
  755. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  756. system("/root/Module_EvComm &");
  757. printf ("[UnconditionalCharge - S_TERMINATING]\n");
  758. //無阻塞偵測 keybaord 結束
  759. system(STTY_DEF TTY_PATH);
  760. }
  761. sleep(3);
  762. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_COMPLETE;
  763. return;
  764. }
  765. break;
  766. case S_COMPLETE:
  767. {
  768. if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
  769. {
  770. PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
  771. printf ("[UnconditionalCharge - S_COMPLETE]\n");
  772. }
  773. sleep(3);
  774. return;
  775. }
  776. break;
  777. }
  778. char word[128];
  779. char newString[7][10];
  780. int i,j,ctr;
  781. memset(word, 0x00, sizeof(word));
  782. get_char(word);
  783. if (strlen(word) == 0)
  784. continue;
  785. j=0; ctr=0;
  786. strcpy(newString[1], "-1");
  787. strcpy(newString[2], "-1");
  788. for (i = 0; i <= (strlen(word)); i++)
  789. {
  790. if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
  791. {
  792. newString[ctr][j] = '\0';
  793. ctr++;
  794. j = 0;
  795. }
  796. else
  797. {
  798. newString[ctr][j] = word[i];
  799. j++;
  800. }
  801. }
  802. if(strcmp(newString[0], "chg") == 0)
  803. {
  804. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  805. continue;
  806. if (strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
  807. continue;
  808. float _vol = atof(newString[1]);
  809. float _cur = atof(newString[2]);
  810. if (_cur <= 0 || _cur <= 0)
  811. continue;
  812. printf("vol = %f, cur = %f \n", _vol, _cur);
  813. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _vol;
  814. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _cur;
  815. }
  816. else if (strcmp(newString[0], "c") == 0)
  817. {
  818. printf("stop \n\r");
  819. ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
  820. _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
  821. }
  822. usleep(100000);
  823. }
  824. }
  825. int main(void)
  826. {
  827. if(InitShareMemory() == FAIL)
  828. {
  829. printf ("InitShareMemory = FAIL \n");
  830. if(ShmStatusCodeData != NULL)
  831. {
  832. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  833. }
  834. sleep(5);
  835. return 0;
  836. }
  837. for(;;)
  838. {
  839. char word[128];
  840. char newString[7][10];
  841. int i,j,ctr;
  842. fgets(word, sizeof(word), stdin);
  843. j=0; ctr=0;
  844. strcpy(newString[1], "-1");
  845. strcpy(newString[2], "-1");
  846. for (i = 0; i <= (strlen(word)); i++)
  847. {
  848. if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
  849. {
  850. newString[ctr][j] = '\0';
  851. ctr++;
  852. j = 0;
  853. }
  854. else
  855. {
  856. newString[ctr][j] = word[i];
  857. j++;
  858. }
  859. }
  860. if(strcmp(newString[0], "state") == 0)
  861. {
  862. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  863. continue;
  864. // 槍狀態
  865. RunStatusProc(newString[1], newString[2]);
  866. }
  867. else if(strcmp(newString[0], "card") == 0)
  868. {
  869. // 刷卡狀態
  870. RunCardProc(newString[1], newString[2]);
  871. }
  872. else if(strcmp(newString[0], "gun") == 0)
  873. {
  874. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  875. continue;
  876. // 插槍狀態
  877. RunGunPlugitProc(newString[1], newString[2]);
  878. }
  879. else if(strcmp(newString[0], "lock") == 0)
  880. {
  881. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  882. continue;
  883. // 插槍狀態
  884. GetGunLockStatusProc(newString[1], newString[2]);
  885. }
  886. else if(strcmp(newString[0], "sysid") == 0)
  887. {
  888. // 測試 sys id
  889. SetSystemIDProc();
  890. }
  891. else if(strcmp(newString[0], "self") == 0)
  892. {
  893. // CSU 自我檢測狀態
  894. RunSelfProc(newString[1]);
  895. }
  896. else if(strcmp(newString[0], "ver") == 0)
  897. {
  898. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  899. continue;
  900. // 取 FW 版號
  901. GetFwVerProc(newString[1]);
  902. }
  903. else if (strcmp(newString[0], "update") == 0)
  904. {
  905. // 更新
  906. FwUpdateFlagProc(newString[1]);
  907. }
  908. else if (strcmp(newString[0], "ac") == 0)
  909. {
  910. // AC contactor 狀態
  911. CheckAcStatus(newString[1]);
  912. }
  913. else if (strcmp(newString[0], "cable") == 0)
  914. {
  915. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  916. continue;
  917. // cable check pass
  918. SetCableChkStatus(newString[1], newString[2]);
  919. }
  920. else if (strcmp(newString[0], "pow") == 0)
  921. {
  922. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  923. continue;
  924. // cable check pass
  925. SetPowerValue(newString[1], newString[2]);
  926. }
  927. else if (strcmp(newString[0], "model") == 0)
  928. {
  929. GetSystemInfo();
  930. }
  931. else if(strcmp(newString[0], "select") == 0)
  932. {
  933. // 取得 / 設定 當前選的槍號
  934. GetGunSelectedNum(newString[1]);
  935. }
  936. else if(strcmp(newString[0], "change") == 0)
  937. {
  938. // 模擬按鈕改變選槍
  939. ChangeGunNum();
  940. }
  941. else if(strcmp(newString[0], "fan") == 0)
  942. {
  943. // 設定風扇速度
  944. SetFanSpeed(newString[1]);
  945. }
  946. else if(strcmp(newString[0], "speed") == 0)
  947. {
  948. // 取得風扇速度
  949. GetFanSpeed();
  950. }
  951. else if(strcmp(newString[0], "debug") == 0)
  952. {
  953. // 設定 debug mode
  954. SetDebugMode(newString[1]);
  955. }
  956. else if (strcmp(newString[0], "gfd") == 0)
  957. {
  958. // 設定盲沖使用 GFD 功能
  959. SetGFDMode(newString[1]);
  960. }
  961. else if(strcmp(newString[0], "temp") == 0)
  962. {
  963. // 取得 PSU 溫度
  964. GetPsuTemp();
  965. }
  966. else if(strcmp(newString[0], "acin") == 0)
  967. {
  968. // 取得三向輸入電壓
  969. GetAcInputVol();
  970. }
  971. else if(strcmp(newString[0], "psu") == 0)
  972. {
  973. //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
  974. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  975. {
  976. printf ("PSU : Param fail..Please retry again......\n");
  977. continue;
  978. }
  979. // 取得 PSU 資訊
  980. GetPsuInformation(newString[1]);
  981. }
  982. else if (strcmp(newString[0], "cap") == 0)
  983. {
  984. GetConnectorCapInfo(newString[1]);
  985. }
  986. else if(strcmp(newString[0], "error") == 0)
  987. {
  988. CreateOneError(newString[1]);
  989. }
  990. else if (strcmp(newString[0], "auth") == 0)
  991. {
  992. GetAuthorizeFlag(newString[1]);
  993. }
  994. else if (strcmp(newString[0], "id") == 0)
  995. {
  996. GetOrClearId(newString[1]);
  997. }
  998. else if(strcmp(newString[0], "strchg") == 0)
  999. {
  1000. //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
  1001. if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
  1002. strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
  1003. {
  1004. printf ("Input cmd fail ------ strchg [vol 150-1000] [cru 2-100]\n");
  1005. continue;
  1006. }
  1007. // 槍狀態
  1008. RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
  1009. }
  1010. else
  1011. printf ("%s\n", msg);
  1012. usleep(100000);
  1013. }
  1014. return 0;
  1015. }