ReadCmdline.c 37 KB

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