ReadCmdline.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. #include <sys/time.h>
  2. #include <sys/timeb.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <sys/ipc.h>
  9. #include <sys/shm.h>
  10. #include <sys/shm.h>
  11. #include <sys/mman.h>
  12. #include <linux/wireless.h>
  13. #include <arpa/inet.h>
  14. #include <netinet/in.h>
  15. #include <unistd.h>
  16. #include <stdarg.h>
  17. #include <stdio.h> /*標準輸入輸出定義*/
  18. #include <stdlib.h> /*標準函數庫定義*/
  19. #include <unistd.h> /*Unix 標準函數定義*/
  20. #include <fcntl.h> /*檔控制定義*/
  21. #include <termios.h> /*PPSIX 終端控制定義*/
  22. #include <errno.h> /*錯誤號定義*/
  23. #include <errno.h>
  24. #include <string.h>
  25. #include <time.h>
  26. #include <ctype.h>
  27. #include <ifaddrs.h>
  28. #include <math.h>
  29. #include <stdbool.h>
  30. #include "../../define.h"
  31. #include "VCCU.h"
  32. typedef unsigned char byte;
  33. #define PASS 1
  34. #define FAIL -1
  35. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  36. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  37. struct StatusCodeData *ShmStatusCodeData;
  38. struct PrimaryMcuData *ShmPrimaryMcuData;
  39. struct CHAdeMOData *ShmCHAdeMOData;
  40. struct CcsData *ShmCcsData;
  41. struct FanModuleData *ShmFanModuleData;
  42. struct RelayModuleData *ShmRelayModuleData;
  43. struct ATE *ate;
  44. struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  45. int gunCount = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
  46. char *msg = "stop : set ate stop (x) : \n"
  47. "targetCurrent : set&get ate targetCurrent (x) : \n"
  48. "targetVoltage : get ate targetVoltage (x) \n"
  49. "maximumCurrent : set&get ate maximumCurrent (x) \n"
  50. "maximumVoltage : set&get ate maximumVoltage (x) \n"
  51. "presentVoltage : set&get ccs presentVoltage (x) \n"
  52. "linkVoltage : set&get ate linkVoltage (x) \n"
  53. "contactorVoltage : set&get ate contactorVoltage (x) \n"
  54. "chademoPrmission : set chademo ate ChargingPermission (x) \n"
  55. "totalBatteryCap : set chademo ate totalBatteryCap (x) \n"
  56. "maxBatteryCurrent : set chademo ate maxBatteryCurrent (x) \n"
  57. "maxBatteryVoltage : set chademo ate maxBatteryVoltage (x) \n"
  58. "requireVoltage : set&get chademo ate requireVoltage (x) \n"
  59. "requireCurrent : set&get chademo ate requireCurrent (x) \n"
  60. "presentBattVoltage : set&get chademo ate presentBattVoltage (x) \n"
  61. "minimumChargeCurrent : set&get chademo ate minimumChargeCurrent (x) \n"
  62. "soc : set chademo ate soc (x) \n"
  63. "relay : set chademo ate relay (x) \n"
  64. "cstate : set chademo ate state (x) \n"
  65. "startstate : set start ate state (x) \n"
  66. "crelaystate : set chademo relay ate state (x) \n"
  67. "ccstate : set chademo relay 192 state (x) \n"
  68. "vccuinfo : show vccuinfo state \n"
  69. "chademoinfo : chademoinfo state \n"
  70. "chromainfo : chromainfo state \n"
  71. "modeChange : modeChange state (x) \n"
  72. "ateState : ateState (x) \n";
  73. #define ShmATEKey 1020
  74. int InitShareMemory()
  75. {
  76. int result = PASS;
  77. int MeterSMId;
  78. //initial ShmSysConfigAndInfo
  79. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0)
  80. {
  81. result = FAIL;
  82. }
  83. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  84. {
  85. result = FAIL;
  86. }
  87. else
  88. {}
  89. /*
  90. //initial ShmStatusCodeData
  91. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  92. {
  93. result = FAIL;
  94. }
  95. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  96. {
  97. result = FAIL;
  98. }
  99. else
  100. {}
  101. if(CHAdeMO_QUANTITY > 0)
  102. {
  103. if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),
  104. IPC_CREAT | 0777)) < 0) {
  105. result = FAIL;
  106. } else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0))
  107. == (void *) -1) {
  108. result = FAIL;
  109. } else {
  110. }
  111. }
  112. if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData),
  113. IPC_CREAT | 0777)) < 0) {
  114. result = FAIL;
  115. } else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
  116. result = FAIL;
  117. } else {
  118. }*/
  119. /*
  120. if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), IPC_CREAT | 0777)) < 0)
  121. {
  122. result = FAIL;
  123. }
  124. else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  125. {
  126. result = FAIL;
  127. }
  128. if ((MeterSMId = shmget(ShmFanBdKey, sizeof(struct FanModuleData), IPC_CREAT | 0777)) < 0)
  129. {
  130. result = FAIL;
  131. }
  132. else if ((ShmFanModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  133. {
  134. result = FAIL;
  135. }
  136. if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), IPC_CREAT | 0777)) < 0)
  137. {
  138. result = FAIL;
  139. }
  140. else if ((ate = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  141. {
  142. result = FAIL;
  143. }
  144. */
  145. if ((MeterSMId = shmget(ShmATEKey, sizeof(struct ATE), IPC_CREAT | 0777)) < 0)
  146. {
  147. result = FAIL;
  148. }
  149. else if ((ate = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  150. {
  151. result = FAIL;
  152. }
  153. return result;
  154. }
  155. bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
  156. {
  157. for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
  158. {
  159. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
  160. {
  161. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
  162. return true;
  163. }
  164. }
  165. for (byte index = 0; index < CCS_QUANTITY; index++)
  166. {
  167. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
  168. {
  169. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
  170. return true;
  171. }
  172. }
  173. for (byte index = 0; index < GB_QUANTITY; index++)
  174. {
  175. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
  176. {
  177. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183. void RunStatusProc(char *v1, char *v2)
  184. {
  185. int _index = atoi(v1);
  186. if (!FindChargingInfoData(_index, &_chargingData[0]))
  187. {
  188. printf ("FindChargingInfoData error\n");
  189. return;
  190. }
  191. if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
  192. {
  193. // get
  194. printf ("index = %x, status = %x\n", _index, _chargingData[_index]->SystemStatus);
  195. }
  196. else
  197. {
  198. // set
  199. _chargingData[_index]->SystemStatus = atoi(v2);
  200. }
  201. }
  202. void StopATE( char *v1){
  203. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  204. printf("ATEStatus = %d \n", ShmSysConfigAndInfo->ate.ATEStatus);
  205. }else{
  206. if(strcmp(v1, "0") == 0 ){
  207. ShmSysConfigAndInfo->ate.ATEStatus = 0;
  208. }else if(strcmp(v1, "1") == 0 ){
  209. ShmSysConfigAndInfo->ate.ATEStatus = 1;
  210. }else if(strcmp(v1, "2") == 0 ){
  211. ShmSysConfigAndInfo->ate.ATEStatus = 2;
  212. }else if(strcmp(v1, "3") == 0 ){
  213. ShmSysConfigAndInfo->ate.ATEStatus = 3;
  214. }
  215. }
  216. }
  217. void targetCurrent(char *v1){
  218. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  219. printf("targetCurrent = %d \n", ShmSysConfigAndInfo->ate.targetCurrent_Value);
  220. }else{
  221. int value = atoi(v1);
  222. ShmSysConfigAndInfo->ate.targetCurrent_Value = value;
  223. printf("targetCurrent = %d \n", ShmSysConfigAndInfo->ate.targetCurrent_Value);
  224. }
  225. }
  226. void targetVoltage(char *v1){
  227. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  228. printf("targetVoltage = %d \n", ShmSysConfigAndInfo->ate.targetVoltage_Value);
  229. }else{
  230. int value = atoi(v1);
  231. if(ShmSysConfigAndInfo->ate.ATEState == 1){//VCCU
  232. int voltage = value;
  233. int maxValue = 950;
  234. if(voltage > (maxValue - 10)){
  235. ShmSysConfigAndInfo->ate.maximumVoltage_value = maxValue;
  236. ShmSysConfigAndInfo->ate.targetVoltage_Value = maxValue - 20;
  237. ShmSysConfigAndInfo->ate.linkVoltage = maxValue - 20;
  238. }else{
  239. ShmSysConfigAndInfo->ate.maximumVoltage_value = voltage + 10;
  240. ShmSysConfigAndInfo->ate.targetVoltage_Value = voltage - 10;
  241. ShmSysConfigAndInfo->ate.linkVoltage = voltage - 10;
  242. }
  243. }else if(ShmSysConfigAndInfo->ate.ATEState == 2){//GB
  244. int voltage = value;
  245. int gbmaxValue = 750;
  246. if(voltage > (gbmaxValue - 100)){
  247. //ShmSysConfigAndInfo->ate.targetVoltage_Value = maxValue - 100;
  248. ShmSysConfigAndInfo->ate.chademoTargetVoltage_Value = gbmaxValue - 100;
  249. ShmSysConfigAndInfo->ate.RequireVoltage = gbmaxValue -100;
  250. ShmSysConfigAndInfo->ate.MaxBatteryVoltage = gbmaxValue;
  251. }else{
  252. ShmSysConfigAndInfo->ate.chademoTargetVoltage_Value = voltage;
  253. ShmSysConfigAndInfo->ate.RequireVoltage = voltage;
  254. ShmSysConfigAndInfo->ate.MaxBatteryVoltage = gbmaxValue;
  255. }
  256. }
  257. //ShmSysConfigAndInfo->ate.targetVoltage_Value = value;
  258. printf("targetVoltage = %d \n", ShmSysConfigAndInfo->ate.targetVoltage_Value);
  259. }
  260. }
  261. void maximumCurrent(char *v1){
  262. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  263. printf("maximumCurrent = %d \n", ShmSysConfigAndInfo->ate.maximumCurrent_value);
  264. }else{
  265. int value = atoi(v1);
  266. ShmSysConfigAndInfo->ate.maximumCurrent_value = value;
  267. printf("maximumCurrent = %d \n", ShmSysConfigAndInfo->ate.maximumCurrent_value);
  268. }
  269. }
  270. void maximumVoltage(char *v1){
  271. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  272. printf("maximumVoltage = %d \n", ShmSysConfigAndInfo->ate.maximumVoltage_value);
  273. }else{
  274. int value = atoi(v1);
  275. ShmSysConfigAndInfo->ate.maximumVoltage_value = value;
  276. printf("maximumVoltage = %d \n", ShmSysConfigAndInfo->ate.maximumVoltage_value);
  277. }
  278. }
  279. void presentVoltage(char *v1){
  280. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  281. printf("presentVoltage = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVSEPresentVoltage.VCCU_V2G_EVSEPresentVoltage_Va);
  282. }else{
  283. int value = atoi(v1);
  284. ShmSysConfigAndInfo->ate.vccu.v2g_EVSEPresentVoltage.VCCU_V2G_EVSEPresentVoltage_Va = value;
  285. printf("presentVoltage = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVSEPresentVoltage.VCCU_V2G_EVSEPresentVoltage_Va);
  286. }
  287. }
  288. void linkVoltage(char *v1){
  289. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  290. printf("linkVoltage = %d \n", ShmSysConfigAndInfo->ate.linkVoltage);
  291. }else{
  292. int value = atoi(v1);
  293. ShmSysConfigAndInfo->ate.linkVoltage = value;
  294. printf("linkVoltage = %d \n", ShmSysConfigAndInfo->ate.linkVoltage);
  295. }
  296. }
  297. void contactorVoltage(char *v1){
  298. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  299. printf("contactorVoltage = %d \n", ShmSysConfigAndInfo->ate.contactorVoltage);
  300. }else{
  301. int value = atoi(v1);
  302. ShmSysConfigAndInfo->ate.contactorVoltage = value;
  303. printf("contactorVoltage = %d \n", ShmSysConfigAndInfo->ate.contactorVoltage);
  304. }
  305. }
  306. void setChademoPrmission(char *v1){
  307. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  308. printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  309. //return;
  310. }else{
  311. int value = atoi(v1);
  312. ShmSysConfigAndInfo->ate.Permission = value;
  313. printf("Permission = %d ", ShmSysConfigAndInfo->ate.Permission);
  314. }
  315. }
  316. void setTotalBatteryCap(char *v1){
  317. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  318. printf("TotalBatteryCap = %d \n", ShmSysConfigAndInfo->ate.TotalBatteryCap);
  319. //return;
  320. }else{
  321. int value = atoi(v1);
  322. ShmSysConfigAndInfo->ate.TotalBatteryCap = value * 10;
  323. printf("TotalBatteryCap = %d ", ShmSysConfigAndInfo->ate.TotalBatteryCap);
  324. }
  325. }
  326. void setMaxBatteryCurrent(char *v1){
  327. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  328. printf("MaxBatteryCurrent = %d \n", ShmSysConfigAndInfo->ate.MaxBatteryCurrent);
  329. //return;
  330. }else{
  331. int value = atoi(v1);
  332. ShmSysConfigAndInfo->ate.MaxBatteryCurrent = value * 10;
  333. printf("MaxBatteryCurrent = %d ", ShmSysConfigAndInfo->ate.MaxBatteryCurrent);
  334. }
  335. }
  336. void setMaxBatteryVoltage(char *v1){
  337. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  338. printf("MaxBatteryVoltage = %d \n", ShmSysConfigAndInfo->ate.MaxBatteryVoltage);
  339. //return;
  340. }else{
  341. int value = atoi(v1);
  342. ShmSysConfigAndInfo->ate.MaxBatteryVoltage = value * 10;
  343. printf("MaxBatteryVoltage = %d ", ShmSysConfigAndInfo->ate.MaxBatteryVoltage);
  344. }
  345. }
  346. void SetChargingPermission(char *v1, char *v2, char *v3, char *v4){
  347. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  348. printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  349. //return;
  350. }else{
  351. int value = atoi(v1);
  352. ShmSysConfigAndInfo->ate.Permission = value;
  353. //printf("Permission = %d ", ShmSysConfigAndInfo->ate.Permission);
  354. }
  355. if(strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0 ){
  356. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  357. }else{
  358. int value = atoi(v2);
  359. ShmSysConfigAndInfo->ate.TotalBatteryCap = value * 10;
  360. //printf("TotalBatteryCapa = %d ", ShmSysConfigAndInfo->ate.TotalBatteryCapacity);
  361. }
  362. if(strcmp(v3, "-1") == 0 || strcmp(v3, "") == 0 ){
  363. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.MaximumBatteryCurrent);
  364. }else{
  365. int value = atoi(v3);
  366. if(value > 0){
  367. ShmSysConfigAndInfo->ate.MaxBatteryCurrent = value * 10;
  368. }else{
  369. if(strcmp(v3, "0") == 0 ){
  370. ShmSysConfigAndInfo->ate.MaxBatteryCurrent = value * 10;
  371. }
  372. }
  373. printf("=====%d, %d \n", value, ShmSysConfigAndInfo->ate.MaxBatteryCurrent);
  374. //printf("MaximumBatteryCurrent = %d ", ShmSysConfigAndInfo->ate.MaximumBatteryCurrent);
  375. }
  376. if(strcmp(v4, "-1") == 0 || strcmp(v4, "") == 0 ){
  377. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  378. }else{
  379. int value = atoi(v4);
  380. ShmSysConfigAndInfo->ate.MaxBatteryVoltage = value * 10;
  381. printf("=====%d, %d \n", value, ShmSysConfigAndInfo->ate.MaxBatteryVoltage);
  382. //printf("MaximumBatteryCurrent = %d ", ShmSysConfigAndInfo->ate.MaximumBatteryVoltage);
  383. }
  384. printf(" Permission : %d, TotalBatteryCapacity : %d, MaximumBatteryCurrent : %d, MaximumBatteryCurrent : %d \n", ShmSysConfigAndInfo->ate.Permission, ShmSysConfigAndInfo->ate.TotalBatteryCap, ShmSysConfigAndInfo->ate.MaxBatteryCurrent, ShmSysConfigAndInfo->ate.MaxBatteryVoltage);
  385. }
  386. void SetRequireVoltage(char *v1){
  387. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  388. printf("RequireVoltage = %d \n", ShmSysConfigAndInfo->ate.RequireVoltage);
  389. //return;
  390. }else{
  391. int value = atoi(v1);
  392. ShmSysConfigAndInfo->ate.RequireVoltage = value * 10;
  393. printf("RequireVoltage = %d ", ShmSysConfigAndInfo->ate.RequireVoltage);
  394. }
  395. }
  396. void SetRequireCurrent(char *v1){
  397. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  398. printf("RequireCurrent = %d \n", ShmSysConfigAndInfo->ate.RequireCurrent);
  399. //return;
  400. }else{
  401. int value = atoi(v1);
  402. ShmSysConfigAndInfo->ate.RequireCurrent = value * 10;
  403. printf("RequireCurrent = %d ", ShmSysConfigAndInfo->ate.RequireCurrent);
  404. }
  405. }
  406. void SetPresentBattVoltage(char *v1){
  407. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  408. printf("PresentBattVoltage = %d \n", ShmSysConfigAndInfo->ate.PresentBattVoltage);
  409. //return;
  410. }else{
  411. int value = atoi(v1);
  412. ShmSysConfigAndInfo->ate.PresentBattVoltage = value * 10;
  413. printf("PresentBattVoltage = %d ", ShmSysConfigAndInfo->ate.PresentBattVoltage);
  414. }
  415. }
  416. void SetMinimumChargeCurrent(char *v1){
  417. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  418. printf("MinimumChargeCurrent = %d \n", ShmSysConfigAndInfo->ate.MinimumChargeCurrent);
  419. //return;
  420. }else{
  421. int value = atoi(v1);
  422. ShmSysConfigAndInfo->ate.MinimumChargeCurrent = value * 10;
  423. printf("MinimumChargeCurrent = %d ", ShmSysConfigAndInfo->ate.MinimumChargeCurrent);
  424. }
  425. }
  426. /*
  427. void SetPresentInputRequirement(char *v1, char *v2, char *v3, char *v4){
  428. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  429. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  430. }else{
  431. int value = atoi(v1);
  432. ShmSysConfigAndInfo->ate.RequireVoltage = value * 10;
  433. //printf("Permission = %d ", ShmSysConfigAndInfo->ate.Permission);
  434. }
  435. if(strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0 ){
  436. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  437. }else{
  438. int value = atoi(v2);
  439. ShmSysConfigAndInfo->ate.RequireCurrent = value * 10;
  440. //printf("TotalBatteryCapacity = %d ", ShmSysConfigAndInfo->ate.TotalBatteryCapacity);
  441. }
  442. if(strcmp(v3, "-1") == 0 || strcmp(v3, "") == 0 ){
  443. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.MaximumBatteryCurrent);
  444. }else{
  445. int value = atoi(v3);
  446. ShmSysConfigAndInfo->ate.PresentBattVoltage = value * 10;
  447. //printf("MaximumBatteryCurrent = %d ", ShmSysConfigAndInfo->ate.MaximumBatteryCurrent);
  448. }
  449. if(strcmp(v4, "-1") == 0 || strcmp(v4, "") == 0 ){
  450. //printf("Permission = %d \n", ShmSysConfigAndInfo->ate.Permission);
  451. }else{
  452. int value = atoi(v4);
  453. ShmSysConfigAndInfo->ate.MinimumChargeCurrent = value * 10;
  454. //printf("MaximumBatteryCurrent = %d ", ShmSysConfigAndInfo->ate.MaximumBatteryVoltage);
  455. }
  456. printf(" RequireVoltage : %d, RequireCurrent : %d, PresentBattVoltage : %d, MinimumChargeCurrent : %d \n", ShmSysConfigAndInfo->ate.RequireVoltage, ShmSysConfigAndInfo->ate.RequireCurrent, ShmSysConfigAndInfo->ate.PresentBattVoltage, ShmSysConfigAndInfo->ate.MinimumChargeCurrent);
  457. }
  458. */
  459. void SetSoc(char *v1){
  460. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  461. printf("Soc = %d \n", ShmSysConfigAndInfo->ate.chademo.id0D_req.Soc);
  462. }else{
  463. int value = atoi(v1);
  464. ShmSysConfigAndInfo->ate.chademo.id0D_req.Soc = value;
  465. printf("Soc = %d ", ShmSysConfigAndInfo->ate.chademo.id0D_req.Soc);
  466. }
  467. printf("%d \n",ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.ControlPilot_DutyCycle.bits.value);
  468. }
  469. void SetRelay(char *v1){
  470. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  471. printf("relay = %d \n", ShmSysConfigAndInfo->ate.chademo.id0D_req.K1K2Status);
  472. }else{
  473. int value = atoi(v1);
  474. ShmSysConfigAndInfo->ate.chademo.id0D_req.K1K2Status = value;
  475. printf("relay = %d ", ShmSysConfigAndInfo->ate.chademo.id0D_req.K1K2Status);
  476. }
  477. }
  478. void SetState(char *v1){
  479. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  480. printf("state = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.state);
  481. }else{
  482. int value = atoi(v1);
  483. ShmSysConfigAndInfo->ate.chademo.id03.state = value;
  484. printf("state = %d ", ShmSysConfigAndInfo->ate.chademo.id03.state);
  485. }
  486. }
  487. void SetCState(char *v1){
  488. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  489. printf("cstatus = %d \n", ShmSysConfigAndInfo->ate.cstatus );
  490. }else{
  491. int value = atoi(v1);
  492. ShmSysConfigAndInfo->ate.cstatus = value;
  493. printf("cstatus = %d ", ShmSysConfigAndInfo->ate.cstatus );
  494. }
  495. }
  496. void SetStartState(char *v1){
  497. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  498. printf("start state = %d \n", ShmSysConfigAndInfo->ate.status);
  499. }else{
  500. int value = atoi(v1);
  501. ShmSysConfigAndInfo->ate.status = value;
  502. printf("start state = %d ", ShmSysConfigAndInfo->ate.status);
  503. }
  504. }
  505. void SetRelayState(char *v1){
  506. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  507. printf("relay state = %d \n", ShmSysConfigAndInfo->ate.chademo.relaystatus);
  508. }else{
  509. int value = atoi(v1);
  510. ShmSysConfigAndInfo->ate.chademo.relaystatus = value;
  511. printf("relay state = %d ", ShmSysConfigAndInfo->ate.chademo.relaystatus);
  512. }
  513. }
  514. void SetATEState(char *v1){
  515. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  516. printf("ATEState = %d \n", ShmSysConfigAndInfo->ate.ATEState);
  517. }else{
  518. int value = atoi(v1);
  519. ShmSysConfigAndInfo->ate.ATEState = value;
  520. printf("ATEState = %d ", ShmSysConfigAndInfo->ate.ATEState);
  521. }
  522. }
  523. void getVCCUInfo(){
  524. printf("VCCU_Vehicle_LinkVoltage = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.VCCU_Vehicle_LinkVoltage);
  525. printf("VCCU_Vehicle_ContactorVoltage = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.VCCU_Vehicle_ContactorVoltage);
  526. printf("VCCU_Vehicle_ContactorStatus = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.bits.VCCU_Vehicle_ContactorStatus);
  527. printf("VCCU_Vehicle_ChargePermission = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.DATA.bits.VCCU_Vehicle_ChargePermission);
  528. printf("VCCU_Vehicle_IsolationMeasurem = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.DATA.bits.VCCU_Vehicle_IsolationMeasurem);
  529. printf("VCCU_Vehicle_PlugLockPermissio = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.DATA.bits.VCCU_Vehicle_PlugLockPermissio);
  530. printf("VCCU_Vehicle_PlugUnlockPermiss = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeFromVehicle.DATA.bits.VCCU_Vehicle_PlugUnlockPermiss);
  531. printf("VCCU_ControlPilot_Frequency = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.ControlPilot_Frequency.bits.VCCU_ControlPilot_Frequency);
  532. printf("ControlPilot_Voltage = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.ControlPilot_Voltage.bits.value);
  533. printf("VCCU_ChargeUnit_Mode = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.DATA.bits.VCCU_ChargeUnit_Mode);
  534. printf("VCCU_ChargeUnit_State = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.DATA.bits.VCCU_ChargeUnit_State);
  535. printf("VCCU_ControlPilot_Wakeup = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.DATA.bits.VCCU_ControlPilot_Wakeup);
  536. printf("ControlPilot_Voltage = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.ChargeUnit_MaxCurrent);
  537. printf("ControlPilot_Voltage = %d \n", ShmSysConfigAndInfo->ate.vccu.controlPilotStatus.ControlPilot_DutyCycle.bits.value);
  538. printf("VCCU_Vehicle_ContactorRequest = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeToVehicle.bits.VCCU_Vehicle_ContactorRequest);
  539. printf("VCCU_Vehicle_IsolationMea_0000 = %d \n", ShmSysConfigAndInfo->ate.vccu.chargeToVehicle.bits.VCCU_Vehicle_IsolationMea_0000);
  540. printf("VCCU_PlugPresent_Status = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA2.VCCU_PlugPresent_Status);
  541. printf("VCCU_PlugPresent_SelfDiagnosti = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA2.VCCU_PlugPresent_SelfDiagnosti);
  542. printf("VCCU_PlugPresent_Resistance = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA2.VCCU_PlugPresent_Resistance);
  543. printf("VCCU_PlugPresent_Wakeup = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA3.VCCU_PlugPresent_Wakeup);
  544. printf("VCCU_PlugLock_MotorStatus = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA3.VCCU_PlugLock_MotorStatus);
  545. printf("VCCU_POSFeedback_SelfDiagnosti = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA3.VCCU_POSFeedback_SelfDiagnosti);
  546. printf("VCCU_Inlet_HWVariant = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA4.VCCU_Inlet_HWVariant);
  547. printf("VCCU_PlugLock_Output0_SelfDiag = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA4.VCCU_PlugLock_Output0_SelfDiag);
  548. printf("VCCU_PlugLock_Output1_SelfDiag = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA4.VCCU_PlugLock_Output1_SelfDiag);
  549. printf("VCCU_Inlet_MotorStatus = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA5.bits.VCCU_Inlet_MotorStatus);
  550. printf("VCCU_DigitalInput_Wakeup = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA5.bits.VCCU_DigitalInput_Wakeup);
  551. printf("VCCU_DigitalInput_Status = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA5.bits.VCCU_DigitalInput_Status);
  552. printf("VCCU_S3Switch_Status = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA7.bits.VCCU_S3Switch_Status);
  553. printf("VCCU_S3Switch_DebouncedStatus = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA7.bits.VCCU_S3Switch_DebouncedStatus);
  554. printf("VCCU_Inlet_ConnectionStatus = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA7.bits.VCCU_Inlet_ConnectionStatus);
  555. printf("VCCU_DigitalInput_DebouncedSta = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.DATA7.bits.VCCU_DigitalInput_DebouncedSta);
  556. printf("VCCU_Inlet_MaxCurrent = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.VCCU_Inlet_MaxCurrent);
  557. printf("VCCU_POSFeedback_Voltage = %d \n", ShmSysConfigAndInfo->ate.vccu.inletStatus.VCCU_POSFeedback_Voltage);
  558. printf("VCCU_V2G_EVErrorCode = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA1.VCCU_V2G_EVErrorCode);
  559. printf("VCCU_V2G_BulkChargingCompleteF = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA1.VCCU_V2G_BulkChargingCompleteF);
  560. printf("VCCU_V2G_BulkChargingComplete = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA1.VCCU_V2G_BulkChargingComplete);
  561. printf("VCCU_V2G_BulkSOCFlag = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA2.VCCU_V2G_BulkSOCFlag);
  562. printf("VCCU_V2G_ChargingComplete = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA2.VCCU_V2G_ChargingComplete);
  563. printf("VCCU_V2G_EVCabinConditioning = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA2.VCCU_V2G_EVCabinConditioning);
  564. printf("VCCU_V2G_FullSOCFlag = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA2.VCCU_V2G_FullSOCFlag);
  565. printf("VCCU_V2G_EVReady = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA3.VCCU_V2G_EVReady);
  566. printf("VCCU_V2G_EVRESSConditioningFla = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA3.VCCU_V2G_EVRESSConditioningFla);
  567. printf("VCCU_V2G_EVRESSConditioning = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA3.VCCU_V2G_EVRESSConditioning);
  568. printf("VCCU_V2G_EVCabinConditioningFl = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA3.VCCU_V2G_EVCabinConditioningFl);
  569. printf("VCCU_V2G_EVPowerDeliveryParame = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA4.VCCU_V2G_EVPowerDeliveryParame);
  570. printf("VCCU_V2G_StateM_EnergyTra_0000 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_VehicleStatus.DATA4.VCCU_V2G_StateM_EnergyTra_0000);
  571. printf("VCCU_V2G_StateM_StateMachineSt = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.VCCU_V2G_StateM_StateMachineSt);
  572. printf("VCCU_V2G_StateM_StateMachineMe = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.VCCU_V2G_StateM_StateMachineMe);
  573. printf("VCCU_V2G_StateM_StateMachineEr = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.VCCU_V2G_StateM_StateMachineEr);
  574. printf("VCCU_V2G_StateM_EnergyTransfer = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.VCCU_V2G_StateM_EnergyTransfer);
  575. printf("VCCU_V2G_StateM_InternetAvaila = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.DATA.bits.VCCU_V2G_StateM_InternetAvaila);
  576. printf("VCCU_V2G_Appl_SccFuncModeReq = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.DATA.bits.VCCU_V2G_Appl_SccFuncModeReq);
  577. printf("VCCU_V2G_Appl_SccChargeModeReq = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_StateM.DATA.bits.VCCU_V2G_Appl_SccChargeModeReq);
  578. printf("VCCU_V2G_EVTargetVoltage_Value = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetVoltage.VCCU_V2G_EVTargetVoltage_Value.value);
  579. printf("VCCU_V2G_EVTargetVoltage_UnitF = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetVoltage.VCCU_V2G_EVTargetVoltage_UnitF.value);
  580. printf("VCCU_V2G_EVTargetVoltage_Unit = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetVoltage.VCCU_V2G_EVTargetVoltage_Unit.value);
  581. printf("VCCU_V2G_EVTargetVoltage_Multi = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetVoltage.VCCU_V2G_EVTargetVoltage_Multi.value);
  582. printf("VCCU_V2G_EVTargetCurrent_Value = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetCurrent.VCCU_V2G_EVTargetCurrent_Value.value);
  583. printf("VCCU_V2G_EVTargetCurrent_UnitF = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetCurrent.VCCU_V2G_EVTargetCurrent_UnitF.value);
  584. printf("VCCU_V2G_EVTargetCurrent_Unit = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetCurrent.VCCU_V2G_EVTargetCurrent_Unit.value);
  585. printf("VCCU_V2G_EVTargetCurrent_Multi = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVTargetCurrent.VCCU_V2G_EVTargetCurrent_Multi.value);
  586. printf("VCCU_V2G_EVMaximumVoltage_0003 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumVoltageLimit.VCCU_V2G_EVMaximumVoltage_0003.value);
  587. printf("VCCU_V2G_EVMaximumVoltage_0001 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumVoltageLimit.VCCU_V2G_EVMaximumVoltage_0001.value);
  588. printf("VCCU_V2G_EVMaximumVoltage_0000 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumVoltageLimit.VCCU_V2G_EVMaximumVoltage_0000.value);
  589. printf("VCCU_V2G_EVMaximumVoltageLimit = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumVoltageLimit.DATA1.VCCU_V2G_EVMaximumVoltageLimit);
  590. printf("VCCU_V2G_EVMaximumVoltage_0002 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumVoltageLimit.DATA1.VCCU_V2G_EVMaximumVoltage_0002);
  591. printf("VCCU_V2G_EVMaximumCurrent_0003 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumCurrentLimit.VCCU_V2G_EVMaximumCurrent_0003.value);
  592. printf("VCCU_V2G_EVMaximumCurrent_0002 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumCurrentLimit.VCCU_V2G_EVMaximumCurrent_0002.value);
  593. printf("VCCU_V2G_EVMaximumCurrent_0001 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumCurrentLimit.VCCU_V2G_EVMaximumCurrent_0001.value);
  594. printf("VCCU_V2G_EVMaximumCurrentLimit = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumCurrentLimit.DATA1.VCCU_V2G_EVMaximumCurrentLimit);
  595. printf("VCCU_V2G_EVMaximumCurrent_0000 = %d \n", ShmSysConfigAndInfo->ate.vccu.v2g_EVMaximumCurrentLimit.DATA1.VCCU_V2G_EVMaximumCurrent_0000);
  596. }
  597. void getChademoInfo(){
  598. printf("id03 state = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.state);
  599. printf("id03 ProximitySignal = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.ProximitySignal);
  600. printf("id03 PilotVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.PilotVoltage);
  601. printf("id03 AlarmCode2 = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.AlarmCode2);
  602. printf("id03 AlarmCode3 = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.AlarmCode3);
  603. printf("id03 AlarmCode4 = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.AlarmCode4);
  604. printf("id03 AlarmCode5 = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.AlarmCode5);
  605. printf("id03 AlarmCode6 = %d \n", ShmSysConfigAndInfo->ate.chademo.id03.AlarmCode6);
  606. printf("id06 TotalBatteryCapacity = %d \n", ShmSysConfigAndInfo->ate.chademo.id06.TotalBatteryCapacity);
  607. printf("id06 Permission = %d \n", ShmSysConfigAndInfo->ate.chademo.id06.Permission);
  608. printf("id06 MaximumBatteryVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id06.MaximumBatteryVoltage);
  609. printf("id06 MaximumBatteryCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id06.MaximumBatteryCurrent);
  610. printf("id06 MaxChargingTimeMin = %d \n", ShmSysConfigAndInfo->ate.chademo.id06.MaxChargingTimeMin);
  611. printf("id07 PresentInputVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id07.PresentInputVoltage);
  612. printf("id07 PresentInputCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id07.PresentInputCurrent);
  613. printf("id08 RequireVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id08.RequireVoltage);
  614. printf("id08 RequireCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id08.RequireCurrent);
  615. printf("id08 PresentBattVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id08.PresentBattVoltage);
  616. printf("id08 MinimumChargeCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id08.MinimumChargeCurrent);
  617. printf("id08 ChargeAllow = %d \n", ShmSysConfigAndInfo->ate.chademo.id08.ChargeAllow);
  618. printf("id09_ack ChargingMode = %d \n", ShmSysConfigAndInfo->ate.chademo.id09_ack.ChargingMode);
  619. printf("id09_ack DcEvState = %d \n", ShmSysConfigAndInfo->ate.chademo.id09_ack.DcEvState);
  620. printf("id09_ack EvsePresentOutputCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id09_ack.EvsePresentOutputCurrent);
  621. printf("id09_ack EvsePresentOutputVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id09_ack.EvsePresentOutputVoltage);
  622. printf("id09_ack RemainingTimeSec = %d \n", ShmSysConfigAndInfo->ate.chademo.id09_ack.RemainingTimeSec);
  623. printf("id0A_ack EvseMinChargeVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id0A_ack.EvseMaxChargeCurrent);
  624. printf("id0A_ack EvseMaxChargeVoltage = %d \n", ShmSysConfigAndInfo->ate.chademo.id0A_ack.EvseMaxChargeVoltage);
  625. printf("id0A_ack EvseMinChargeCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id0A_ack.EvseMinChargeCurrent);
  626. printf("id0A_ack EvseMinChargeCurrent = %d \n", ShmSysConfigAndInfo->ate.chademo.id0A_ack.EvseMinChargeVoltage);
  627. printf("id0B AlarmCode1 = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.AlarmCode1);
  628. printf("id0B AlarmCode2 = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.AlarmCode2);
  629. printf("id0B AlarmCode3 = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.AlarmCode3);
  630. printf("id0B AlarmCode4 = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.AlarmCode4);
  631. printf("id0B AlarmCode5 = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.AlarmCode5);
  632. printf("id0B AlarmCode6 = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.AlarmCode6);
  633. printf("id0B EvStopReason = %d \n", ShmSysConfigAndInfo->ate.chademo.id0B.EvStopReason);
  634. printf("id0D_ack soc = %d \n", ShmSysConfigAndInfo->ate.chademo.id0D_ack.soc);
  635. printf("id0D_ack soc = %d \n", ShmSysConfigAndInfo->ate.chademo.id0D_ack.K1K2OnOff);
  636. printf("id0D_req K1K2Status = %d \n", ShmSysConfigAndInfo->ate.chademo.id0D_req.K1K2Status);
  637. printf("id0D_req Soc = %d \n", ShmSysConfigAndInfo->ate.chademo.id0D_req.Soc);
  638. printf("relaystatus = %d \n", ShmSysConfigAndInfo->ate.chademo.relaystatus);
  639. }
  640. void getChromaInfo(){
  641. printf("EVStatus = %d \n", ShmSysConfigAndInfo->ate.chroma.evstaus.data);
  642. printf("Connector_2 TargetVoltage = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_2.TargetVoltage);
  643. printf("Connector_2 TargetCurrent = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_2.TargetCurrent);
  644. printf("Connector_2 PresentVoltage = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_2.PresentVoltage);
  645. printf("Connector_2 PresentCurrent = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_2.PresentCurrent);
  646. printf("Connector_1 TargetVoltage = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_1.TargetVoltage);
  647. printf("Connector_1 TargetCurrent = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_1.TargetCurrent);
  648. printf("Connector_1 PresentVoltage = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_1.PresentVoltage);
  649. printf("Connector_1 PresentCurrent = %d \n", ShmSysConfigAndInfo->ate.chroma.ate_Connector_1.PresentCurrent);
  650. printf("Boot_Notification1 = %d \n", ShmSysConfigAndInfo->ate.chroma.bootNotification.boo1);
  651. printf("Boot_Notification2 = %d \n", ShmSysConfigAndInfo->ate.chroma.bootNotification.boo2);
  652. }
  653. void setModeChange(char *v1){
  654. if(strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0 ){
  655. printf("mode change = %d \n", ShmSysConfigAndInfo->ate.ateMode);
  656. }else{
  657. int value = atoi(v1);
  658. ShmSysConfigAndInfo->ate.ateMode = value;
  659. printf("setModeChange = %d ", ShmSysConfigAndInfo->ate.ateMode);
  660. }
  661. }
  662. int main()
  663. {
  664. if(InitShareMemory() == FAIL)
  665. {
  666. printf ("InitShareMemory = FAIL \n");
  667. if(ShmStatusCodeData != NULL)
  668. {
  669. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  670. }
  671. sleep(5);
  672. return 0;
  673. }
  674. for(;;)
  675. {
  676. char word[256];
  677. char newString[7][20];
  678. int i,j,ctr;
  679. fgets(word, sizeof(word), stdin);
  680. j=0; ctr=0;
  681. strcpy(newString[1], "-1");
  682. strcpy(newString[2], "-1");
  683. for (i = 0; i <= (strlen(word)); i++)
  684. {
  685. if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
  686. {
  687. newString[ctr][j] = '\0';
  688. ctr++;
  689. j = 0;
  690. }
  691. else
  692. {
  693. newString[ctr][j] = word[i];
  694. j++;
  695. }
  696. }
  697. //printf("=====%s %s\n", newString[0], newString[1]);
  698. if(strcmp(newString[0], "stop") == 0)
  699. {
  700. //if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
  701. //continue;
  702. // 槍狀態
  703. StopATE(newString[1]);
  704. continue;
  705. }else if(strcmp(newString[0], "targetCurrent") == 0){//
  706. targetCurrent(newString[1]);
  707. continue;
  708. }else if(strcmp(newString[0], "targetVoltage") == 0){//
  709. targetVoltage(newString[1]);
  710. continue;
  711. }else if(strcmp(newString[0], "maximumCurrent") == 0){//
  712. maximumCurrent(newString[1]);
  713. continue;
  714. }else if(strcmp(newString[0], "maximumVoltage") == 0){//
  715. maximumVoltage(newString[1]);
  716. continue;
  717. }else if(strcmp(newString[0], "presentVoltage") == 0){//
  718. presentVoltage(newString[1]);
  719. continue;
  720. }else if(strcmp(newString[0], "linkVoltage") == 0){//
  721. linkVoltage(newString[1]);
  722. continue;
  723. }else if(strcmp(newString[0], "contactorVoltage") == 0){//
  724. contactorVoltage(newString[1]);
  725. continue;
  726. }else if(strcmp(newString[0], "chademoPrmission") == 0){
  727. //SetChargingPermission(newString[1], newString[2], newString[3], newString[4]);
  728. setChademoPrmission(newString[1]);
  729. continue;
  730. }else if(strcmp(newString[0], "totalBatteryCap") == 0){
  731. setTotalBatteryCap(newString[1]);
  732. continue;
  733. }else if(strcmp(newString[0], "maxBatteryCurrent") == 0){
  734. setMaxBatteryCurrent(newString[1]);
  735. continue;
  736. }else if(strcmp(newString[0], "maxBatteryVoltage") == 0){
  737. setMaxBatteryVoltage(newString[1]);
  738. continue;
  739. }else if(strcmp(newString[0], "requireVoltage") == 0){
  740. SetRequireVoltage(newString[1]);
  741. continue;
  742. }else if(strcmp(newString[0], "requireCurrent") == 0){
  743. SetRequireCurrent(newString[1]);
  744. continue;
  745. }else if(strcmp(newString[0], "presentBattVoltage") == 0){
  746. SetPresentBattVoltage(newString[1]);
  747. continue;
  748. }else if(strcmp(newString[0], "minimumChargeCurrent") == 0){//
  749. SetMinimumChargeCurrent(newString[1]);
  750. continue;
  751. }else if(strcmp(newString[0], "soc") == 0){//
  752. SetSoc(newString[1]);
  753. continue;
  754. }else if(strcmp(newString[0], "relay") == 0){//
  755. SetRelay(newString[1]);
  756. continue;
  757. }else if(strcmp(newString[0], "cstate") == 0){//
  758. SetState(newString[1]);
  759. continue;
  760. }else if(strcmp(newString[0], "startstate") == 0){//
  761. SetStartState(newString[1]);
  762. continue;
  763. }else if(strcmp(newString[0], "crelaystate") == 0){//
  764. SetRelayState(newString[1]);
  765. continue;
  766. }else if(strcmp(newString[0], "ccstate") == 0){//
  767. SetCState(newString[1]);
  768. continue;
  769. }else if(strcmp(newString[0], "vccuinfo") == 0){//
  770. getVCCUInfo();
  771. continue;
  772. }else if(strcmp(newString[0], "chademoinfo") == 0){//
  773. getChademoInfo();
  774. continue;
  775. }else if(strcmp(newString[0], "chromainfo") == 0){//
  776. getChromaInfo();
  777. continue;
  778. }else if(strcmp(newString[0], "modeChange") == 0){//
  779. setModeChange(newString[1]);
  780. continue;
  781. }else if(strcmp(newString[0], "ateState") == 0){//
  782. SetATEState(newString[1]);
  783. continue;
  784. }
  785. printf ("%s\n", msg);
  786. usleep(100000);
  787. }
  788. return(0);
  789. }