소스 검색

2019-12-30 / Alston Lin

Actions.
1. Move files to Apps folder

Files
1. As follow commit history
Alston 5 년 전
부모
커밋
56d0a09838
33개의 변경된 파일1156개의 추가작업 그리고 9994개의 파일을 삭제
  1. 0 137
      EVSE/Projects/DS60-120/Apps/Config.h
  2. 0 175
      EVSE/Projects/DS60-120/Apps/Ev_Comm.c
  3. 0 82
      EVSE/Projects/DS60-120/Apps/Makefile
  4. 0 1093
      EVSE/Projects/DS60-120/Apps/Module_EvComm.c
  5. 0 77
      EVSE/Projects/DS60-120/Apps/Module_EvComm.h
  6. 0 298
      EVSE/Projects/DS60-120/Apps/Module_EventLogging.c
  7. 0 1347
      EVSE/Projects/DS60-120/Apps/Module_InternalComm.c
  8. 0 150
      EVSE/Projects/DS60-120/Apps/Module_LcmContro.h
  9. 0 871
      EVSE/Projects/DS60-120/Apps/Module_LcmControl.c
  10. 0 361
      EVSE/Projects/DS60-120/Apps/Module_PrimaryComm.c
  11. 0 332
      EVSE/Projects/DS60-120/Apps/PrimaryComm.c
  12. 0 80
      EVSE/Projects/DS60-120/Apps/PrimaryComm.h
  13. 0 753
      EVSE/Projects/DS60-120/Apps/internalComm.c
  14. 0 185
      EVSE/Projects/DS60-120/Apps/internalComm.h
  15. 0 2832
      EVSE/Projects/DS60-120/Apps/main.c
  16. 0 5
      EVSE/Projects/DS60-120/Apps/timeout.c
  17. 0 52
      EVSE/Projects/DS60-120/Apps/timeout.h
  18. 297 297
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_System.map
  19. 289 289
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_kallsyms1.S
  20. 289 289
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_kallsyms2.S
  21. BIN
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_vmlinux1
  22. BIN
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_vmlinux2
  23. 1 1
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version
  24. 98 19
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp
  25. 80 36
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts
  26. 6 13
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/lib/.gen_crc32table.cmd
  27. 13 31
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/.conmakehash.cmd
  28. 15 33
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/.kallsyms.cmd
  29. 13 36
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/.sortextable.cmd
  30. 5 10
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/basic/.bin2c.cmd
  31. 20 38
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/basic/.fixdep.cmd
  32. 14 33
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/mod/.mk_elfconfig.cmd
  33. 16 39
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/usr/.gen_init_cpio.cmd

+ 0 - 137
EVSE/Projects/DS60-120/Apps/Config.h

@@ -1,137 +0,0 @@
-/*
- * Config.h
- *
- *  Created on: 2019年4月23日
- *      Author: foluswen
- */
-
-#ifndef CONFIG_H_
-#define CONFIG_H_
-
-typedef unsigned char			byte;
-
-#define TOTAL_QUANTITY_GUN			4				//Max Count
-#define MODE_BOOT					0
-#define MODE_IDLE					1
-#define MODE_AUTHORIZING			2
-#define MODE_REASSIGN_CHECK			3
-#define MODE_REASSIGN				4
-#define MODE_PRECHARGE				5
-#define MODE_PREPARE_FOR_EV			6
-#define MODE_PREPARE_FOR_EVSE		7
-#define MODE_CHARGING				8
-#define MODE_TERMINATING			9
-#define MODE_COMPLETE				10
-#define MODE_ALARM					11
-#define MODE_RESERVATION			12
-#define MODE_BOOKING				13
-#define MODE_MAINTAIN				14
-#define MODE_DEBUG					15
-#define MODE_CCS_PRECHARGE_STEP0	16 	// ready for ccs precharge processing, For D+ relay to precharge relay
-#define MODE_CCS_PRECHARGE_STEP1	17	// waitting for ev board inform to enter to charging, For precharge relay to D+ relay
-#define MODE_SINGLE_RUN				18
-
-#define GFD_WAIT			0
-#define GFD_PASS			1
-#define GFD_FAIL			2
-#define GFD_WARNING			3
-
-#define PRECHARGE_WAIT				0
-#define PRECHARGE_READY				1
-#define PRECHARGE_PRERELAY_PASS		2
-#define PRECHARGE_CHARELAY_PASS		3
-
-#define BOOTTING			0
-#define BOOT_COMPLETE		1
-
-enum _SYSTEM_STATUS
-{
-	S_BOOTING = 						0,
-    S_IDLE,
-	S_AUTHORIZING,
-	S_REASSIGN_CHECK,
-	S_REASSIGN,
-	S_PREPARNING,
-	S_PREPARING_FOR_EV,
-	S_PREPARING_FOR_EVSE,
-    S_CHARGING,
-	S_TERMINATING,
-	S_COMPLETE,
-	S_ALARM,
-	S_RESERVATION,
-	S_BOOKING,
-	S_MAINTAIN,
-	S_DEBUG,
-	S_CCS_PRECHARGE_ST0,
-	S_CCS_PRECHARGE_ST1,
-	S_SINGLE_RUN,
-	S_SP_MODE,
-	S_NONE,
-};
-
-enum _GUN_TYPE
-{
-	_Type_Chademo = 		0,
-	_Type_CCS,
-	_Type_GB,
-};
-
-enum _LCM_INDEX
-{
-	_LCM_INIT = 			0x00,
-	_LCM_IDLE = 			0x01,
-	_LCM_AUTHORIZING = 		0x04,
-	_LCM_AUTHORIZ_COMP = 	0x05,
-	_LCM_AUTHORIZ_FAIL = 	0x06,
-	_LCM_WAIT_FOR_PLUG = 	0x07,
-	_LCM_PRE_CHARGE = 		0x08,
-	_LCM_CHARGING = 		0x09,
-	_LCM_COMPLETE = 		0x0A,
-	_LCM_FIX = 				0x0B,
-	_LCM_NONE = 			0xFF,
-};
-
-enum _SELF_TEST_SEQ
-{
-	_STEST_VERSION = 0x00,
-	_STEST_AC_CONTACTOR = 0x01,
-	_STEST_PSU_DETECT = 0x02,
-	_STEST_PSU_CAP = 0x03,
-	_STEST_FAIL = 0x04,
-	_STEST_COMPLETE = 0xFE,
-};
-
-enum _MODULE_PSU_WORK_STEP
-{
-	ASSIGN_START 	= 			0,
-	ASSIGN_COMP 	= 			1,
-	ENABLE_POW		=			2,
-	_TEST_LINE_STEP 	= 		3,
-	_TEST_POWER_STEP 	= 		4,
-	_TEST_COMPLETE 		= 		5,
-
-	_WORK_CHARGING 	= 			10,
-
-	_NO_WORKING			= 		254,
-};
-
-enum _OFFLINE_POLICY
-{
-	_OFFLINE_POLICY_LOCAL_LIST = 0x00,
-	_OFFLINE_POLICY_PHIHONG_RFID_TAG = 0x01,
-	_OFFLINE_POLICY_FREE_CHARGING = 0x02,
-	_OFFLINE_POLICY_NO_CHARGING = 0x03,
-};
-
-enum _REASSIGNED_RESOURCE_STEP
-{
-	_REASSIGNED_NONE = 			0,	//
-	_REASSIGNED_PREPARE = 		1,	// 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
-	_REASSIGNED_GET_NEW_CAP = 	2,	// 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
-	_REASSIGNED_MAIN = 			3,  // 重新分配 PSU
-	_REASSIGNED_ADJUST = 		4,	// 模塊重新分配完成
-	_REASSIGNED_RELAY = 		5,	// 切斷橋接的 Relay
-	_REASSIGNED_COMP = 			6,	// 完成
-};
-
-#endif /* CONFIG_H_ */

+ 0 - 175
EVSE/Projects/DS60-120/Apps/Ev_Comm.c

@@ -1,175 +0,0 @@
-#include "Module_EvComm.h"
-#include 	<linux/can.h>
-#include 	<linux/can/raw.h>
-#include 	<string.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-
-//================================================
-//================================================
-// CANBUS send cmd
-//================================================
-//================================================
-
-int PackageIdCmd(int cmd)
-{
-	return cmd | 0x80000000;
-}
-
-void SendCmdToEvboard(int cmd, byte *data, byte dataLen)
-{
-    struct can_frame frame;
-
-    frame.can_id = cmd;
-    frame.can_dlc = dataLen;
-    memcpy(frame.data, data, sizeof(frame.data));
-
-    write(CanFd, &frame, sizeof(struct can_frame));
-}
-
-void SetTargetAddr(byte *target_number, byte index)
-{
-	int id = PackageIdCmd(Ev_Cmd.address_assignment + index);
-	//printf("intCmd = %x \n", cmd & CAN_EFF_MASK);
-	//cmd = cmd & CAN_EFF_MASK;
-
-	byte data[8];
-
-	data[0] = *target_number;
-	data[1] = *(target_number + 1);
-	data[2] = *(target_number + 2);
-	data[3] = *(target_number + 3);
-	data[4] = index;
-
-	SendCmdToEvboard(id, data, 5);
-}
-
-void GetFirmwareVersion(byte gun_index, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.get_firmware_ver + toId);
-	byte data[8];
-
-	SendCmdToEvboard(id, data, 0);
-}
-
-void GetHardwareVersion(byte gun_index, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.get_hardware_ver + toId);
-	byte data[8];
-
-	SendCmdToEvboard(id, data, 0);
-}
-
-void SetChargingPermission(byte gun_index, byte permissionStatus, short aOutputPw, short aOutputCur, short aOutputVol, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.charging_permission + toId);
-	byte data[8];
-
-	data[0] = permissionStatus;
-	data[1] = aOutputPw & 0xff;
-	data[2] = (aOutputPw >> 8) & 0xff;
-	data[3] = aOutputCur & 0xff;
-	data[4] = (aOutputCur >> 8) & 0xff;
-	data[5] = aOutputVol & 0xff;
-	data[6] = (aOutputVol >> 8) & 0xff;
-	data[7] = 0xff;
-
-	SendCmdToEvboard(id, data, sizeof(data));
-}
-
-void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2)
-{
-	int id = PackageIdCmd(Ev_Cmd.present_output_power);
-	byte data[8];
-
-	data[0] = outputVol_b1 & 0xff;
-	data[1] = (outputVol_b1 >> 8) & 0xff;
-	data[2] = outputCur_b1 & 0xff;
-	data[3] = (outputCur_b1 >> 8) & 0xff;
-	data[4] = outputVol_b2 & 0xff;
-	data[5] = (outputVol_b2 >> 8) & 0xff;
-	data[6] = outputCur_b2 & 0xff;
-	data[7] = (outputCur_b2 >> 8) & 0xff;
-
-	SendCmdToEvboard(id, data, 8);
-}
-
-void SetPresentOutputCapacity(short aOutputPw_b1, short aOutputCur_b1, short aOutputPw_b2, short aOutputCur_b2)
-{
-	int id = PackageIdCmd(Ev_Cmd.present_output_cap);
-	byte data[8];
-
-	data[0] = aOutputPw_b1 & 0xff;
-	data[1] = (aOutputPw_b1 >> 8) & 0xff;
-	data[2] = aOutputCur_b1 & 0xff;
-	data[3] = (aOutputCur_b1 >> 8) & 0xff;
-	data[4] = aOutputPw_b2 & 0xff;
-	data[5] = (aOutputPw_b2 >> 8) & 0xff;
-	data[6] = aOutputCur_b2 & 0xff;
-	data[7] = (aOutputCur_b2 >> 8) & 0xff;
-
-	SendCmdToEvboard(id, data, 8);
-}
-
-void GetOutputReq(byte gun_index, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.get_output_req + toId);
-	byte data[8];
-
-	SendCmdToEvboard(id, data, 0);
-}
-
-void GetEvBatteryInfo(byte gun_index, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.get_battery_info + toId);
-	byte data[8];
-
-	SendCmdToEvboard(id, data, 0);
-}
-
-void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.evse_stop_charging + toId);
-	byte data[8];
-
-	data[0] = stopResult;
-	data[1] = *stopReason;
-	data[2] = *(stopReason + 1);
-	data[3] = *(stopReason + 2);
-	data[4] = *(stopReason + 3);
-	data[5] = *(stopReason + 4);
-	data[6] = *(stopReason + 5);
-
-	SendCmdToEvboard(id, data, 7);
-}
-
-void GetMiscellaneousInfo(byte gun_index, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.get_miscellaneous_info + toId);
-	byte data[8];
-
-	SendCmdToEvboard(id, data, 0);
-}
-
-void SetIsolationStatus(byte gun_index, byte result, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.isolation_status + toId);
-	byte data[8];
-
-	data[0] = result;
-	SendCmdToEvboard(id, data, 1);
-}
-
-void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId)
-{
-	int id = PackageIdCmd(Ev_Cmd.evse_precharge_info + toId);
-	byte data[8];
-
-	data[0] = result;
-	SendCmdToEvboard(id, data, 1);
-}
-

+ 0 - 82
EVSE/Projects/DS60-120/Apps/Makefile

@@ -1,82 +0,0 @@
--include ../../../../Rules.make
-export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
-
-#define library variable
-Internal485ProtocolLib = -L ../../../Modularization/Internal485Protocol -lInternal485Protocol
-#PsuCommProtocolLib = -L ../../../Modularization/PsuCommProtocol -lPsuCommProtocol
-
-all: CopyFile apps
-#apps: Module_CSU Module_EvComm Module_EventLogging Module_InternalComm Module_LcmControl Module_PrimaryComm Module_PsuComm 
-# ReadCmdline kill.sh
-apps: MainTask EvCommTask EventLoggingTask InternalCommTask LcmControlTask PrimaryCommTask PsuCommTask ReadCmdlineTask WebService 4GTask OtherTools
-
-MainTask:
-	rm -f *.o
-	rm -f main;
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o timeout.o timeout.c
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o main.o main.c
-	$(CC) -o main main.o timeout.o ../../../Modularization/libModule_RFID.a ../../../Modularization/libModule_Upgrade.a	
-	cp -f main ../Images/root
-
-EvCommTask:
-	rm -f Module_EvComm;
-	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Ev_Comm.o Ev_Comm.c
-	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Module_EvComm.o Module_EvComm.c
-	$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o
-	cp -f Module_EvComm ../Images/root	
-	
-EventLoggingTask:
-	rm -f Module_EventLogging;
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o Module_EventLogging.o Module_EventLogging.c
-	$(CC) -o Module_EventLogging Module_EventLogging.o 	
-	cp -f Module_EventLogging ../Images/root	
-	
-InternalCommTask:
-	rm -f Module_InternalComm; 
-	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o internalComm.o internalComm.c
-	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Module_InternalComm.o Module_InternalComm.c
-	$(CC) -o Module_InternalComm Module_InternalComm.o internalComm.o 	
-	cp -f Module_InternalComm ../Images/root
-	
-LcmControlTask:
-	rm -f Module_LcmControl; 
-	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Module_LcmControl.o Module_LcmControl.c
-	$(CC) -o Module_LcmControl Module_LcmControl.o
-	cp -f Module_LcmControl ../Images/root			
-
-PrimaryCommTask:
-	rm -f Module_PrimaryComm; 
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o Module_PrimaryComm.o Module_PrimaryComm.c
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o PrimaryComm.o PrimaryComm.c
-	$(CC) -o Module_PrimaryComm Module_PrimaryComm.o PrimaryComm.o
-	cp -f Module_PrimaryComm ../Images/root	
-
-PsuCommTask:
-	rm -f Module_PsuComm; 
-	$(CC) -include../../../Modularization/Phihong_PsuCommObj.h -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Module_PsuComm.o Module_PsuComm.c
-	$(CC) -o Module_PsuComm Module_PsuComm.o ../../../Modularization/libPhihong_PsuCommObj.a
-	cp -f Module_PsuComm ../Images/root	
-	
-ReadCmdlineTask:
-	rm -f ReadCmdline; 
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o ReadCmdline.o ReadCmdline.c
-	$(CC) -o ReadCmdline ReadCmdline.o
-	cp -f ReadCmdline ../Images/root
-
-WebService:
-	cp -f ../../../Modularization/WebService ../Images/root
-
-4GTask:
-	cp -f ../../../Modularization/Module_4g ../Images/root
-
-OtherTools:
-	cp -f init.sh ../Images/root
-	cp -f kill.sh ../Images/root
-
-CopyFile: 
-	rm -rfv ../Images/root
-	mkdir -p ../Images/root
-
-
-
-	

+ 0 - 1093
EVSE/Projects/DS60-120/Apps/Module_EvComm.c

@@ -1,1093 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/can.h>
-#include 	<linux/can/raw.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include	"../../define.h"
-#include 	"Module_EvComm.h"
-
-#define Debug
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-#define START				1
-#define STOP				0
-#define YES					1
-#define NO					0
-#define DEMO 				0
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-struct FanModuleData			*ShmFanModuleData;
-struct CHAdeMOData				*ShmCHAdeMOData;
-struct CcsData					*ShmCcsData;
-
-byte gun_count = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
-int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-float maxChargingVol = 5000;			// 限制最大充電電壓,如依照模塊則填上 0
-float maxChargingCur = 100;				// 限制最大充電電流,如依照模塊則填上 0
-
-// 槍資訊
-struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-struct Ev_Board_Cmd Ev_Cmd={
-		0,
-		0x00000200,
-		0x00000400,
-		0x00000500,
-		0x00000600,
-		0x00000700,
-		0x00000800,
-		0x00000900,
-		0x00000A00,
-		0x00000C00,
-		0x00000D00,
-
-		0x00000E00,
-		0x00000F00,
-		0x00001000,
-		0x00001100,
-
-		0x00001200,
-		0x00001500,
-};
-
-unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
-
-void GetMaxVolAndCurMethod(byte index, float *vol, float *cur);
-unsigned long GetTimeoutValue(struct timeval _sour_time);
-
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-unsigned long GetTimeoutValue(struct timeval _sour_time)
-{
-	struct timeval _end_time;
-	gettimeofday(&_end_time, NULL);
-
-	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
-}
-
-int StoreLogMsg(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	time_t CurrentTime;
-	struct tm *tm;
-	va_list args;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1);
-	system(Buf);
-
-	return rc;
-}
-
-int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-	//return milli-second
-	unsigned int StartTime,StopTime;
-
-	StartTime=(unsigned int)ST.time;
-	StopTime=(unsigned int)ET.time;
-	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
-}
-
-//=================================
-// Common routine
-//=================================
-void getTimeString(char *buff)
-{
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
-
-	sprintf(buff, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-}
-
-bool CheckUniqNumber(byte value)
-{
-	for (byte index = 0; index < gun_count; index++)
-	{
-		if (_chargingData[index]->Evboard_id == value)
-		{
-			struct timeval _end_time;
-			gettimeofday(&_end_time, NULL);
-			unsigned long diff = 1000000 *	(_end_time.tv_sec - _id_assign_time.tv_sec) + _end_time.tv_usec - _id_assign_time.tv_usec;
-			if (diff >= 3000000)
-			{
-				gettimeofday(&_id_assign_time, NULL);
-				return true;
-			}
-			else
-			{
-				return false;
-			}
-		}
-	}
-
-	gettimeofday(&_id_assign_time, NULL);
-	return true;
-}
-
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-	int result = PASS;
-	int MeterSMId;
-
-	//initial ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-		#endif
-    	result = FAIL;
-   	 }
-    else
-    {}
-
-   	 //initial ShmStatusCodeData
-   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
-   		result = FAIL;
-	}
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
-    	result = FAIL;
-   	}
-    else
-    {}
-
-   	if(CHAdeMO_QUANTITY > 0)
-   	{
-   		if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),	IPC_CREAT | 0777)) < 0)
-   		{
-   			#ifdef SystemLogMessage
-   		   	DEBUG_ERROR("[shmget ShmCHAdeMOData NG \n");
-   			#endif
-   			return FAIL;
-   		}
-   		else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-   		{
-   			#ifdef SystemLogMessage
-   		   	DEBUG_ERROR("shmat ShmCHAdeMOData NG \n");
-   			#endif
-   			return FAIL;
-   		}
-   		else
-   		{}
-   	}
-
-   	if(CCS_QUANTITY > 0)
-   	{
-   		if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData),	IPC_CREAT | 0777)) < 0)
-   		{
-   			#ifdef SystemLogMessage
-   			DEBUG_ERROR("shmget ShmCcsData NG \n");
-   			#endif
-   			return FAIL;
-   		}
-   		else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
-   			#ifdef SystemLogMessage
-   		   	DEBUG_ERROR("shmat ShmCcsData NG \n");
-   			#endif
-   			return FAIL;
-   		}
-   		else
-   		{}
-   	}
-
-    return result;
-}
-
-//================================================
-// initial can-bus
-//================================================
-int InitCanBus()
-{
-	int 					s0,nbytes;
-	struct timeval			tv;
-	struct ifreq 			ifr0;
-	struct sockaddr_can		addr0;
-
-	system("/sbin/ip link set can0 down");
-	system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
-	system("/sbin/ip link set can0 up");
-
-	s0 = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-
-	tv.tv_sec = 0;
-	tv.tv_usec = 10000;
-   	if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct	timeval)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Set SO_RCVTIMEO NG");
-		#endif
-	}
-	nbytes=40960;
-	if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Set SO_RCVBUF NG");
-		#endif
-	}
-	nbytes=40960;
-	if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Set SO_SNDBUF NG");
-		#endif
-	}
-
-   	strcpy(ifr0.ifr_name, "can0" );
-	ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
-	addr0.can_family = AF_CAN;
-	addr0.can_ifindex = ifr0.ifr_ifindex;
-	bind(s0, (struct sockaddr *)&addr0, sizeof(addr0));
-	return s0;
-}
-
-//================================================
-//================================================
-// CANBUS receive task
-//================================================
-//================================================
-bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
-{
-	for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
-		{
-			chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < CCS_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
-		{
-			chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < GB_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
-		{
-			chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
-			return true;
-		}
-	}
-
-	return false;
-}
-
-void AddrAssignment(byte *data)
-{
-	byte target_number[8];
-	byte index = 0x00;
-
-	memcpy(target_number, data, sizeof(target_number));
-	index = *(data + 4);
-
-	if (CheckUniqNumber(index))
-	{
-		printf("EV board id = %x \n", index);
-//		printf("target_number[0] = %x \n", target_number[0]);
-//		printf("target_number[1] = %x \n", target_number[1]);
-//		printf("target_number[2] = %x \n", target_number[2]);
-//		printf("target_number[3] = %x \n", target_number[3]);
-//		printf("target_number[4] = %x \n", target_number[4]);
-
-		printf("SetTargetAddr = %d \n", index);
-		SetTargetAddr(target_number, index);
-	}
-}
-
-void ClearAbnormalStatus_Chadmoe(byte gun_index)
-{
-	int codeValue = 0;
-
-	if (strlen((char *)ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index]) == 6)
-	{
-		codeValue = atoi((char *)ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index]);
-
-		if (codeValue >= 23700 && codeValue <= 23736)
-		{
-			memcpy(&ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index][0], "", 7);
-			ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level = 0;
-		}
-	}
-
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = 0x00;
-	ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = 0x00;
-}
-
-void AbnormalStopAnalysis(byte gun_index, byte *errCode)
-{
-	char string[7];
-	sprintf(string, "%d%d%d%d%d%d", *(errCode + 5), *(errCode + 4), *(errCode + 3), *(errCode + 2), *(errCode + 1), *(errCode + 0));
-
-	if (gun_index < gun_count)
-	{
-		if (strlen((char *)ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index]) <= 0)
-		{
-			memcpy(&ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index][0], string, 7);
-			ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level = 0x00;
-		}
-	}
-	printf("NOTIFICATION_EV_STOP : Err Code = %s \n", string);
-
-	if (strcmp(string, "023700") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = 0x01;
-	if (strcmp(string, "023701") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = 0x01;
-	if (strcmp(string, "023702") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail = 0x01;
-	if (strcmp(string, "023703") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = 0x01;
-	if (strcmp(string, "023704") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = 0x01;
-	if (strcmp(string, "023705") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = 0x01;
-	if (strcmp(string, "023706") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = 0x01;
-	if (strcmp(string, "023707") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = 0x01;
-	if (strcmp(string, "023708") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = 0x01;
-	if (strcmp(string, "023709") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = 0x01;
-	if (strcmp(string, "023710") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = 0x01;
-	if (strcmp(string, "023711") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = 0x01;
-	if (strcmp(string, "023712") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = 0x01;
-	if (strcmp(string, "023713") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = 0x01;
-	if (strcmp(string, "023714") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = 0x01;
-	if (strcmp(string, "023715") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = 0x01;
-	if (strcmp(string, "023716") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = 0x01;
-	if (strcmp(string, "023717") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = 0x01;
-	if (strcmp(string, "023718") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = 0x01;
-	if (strcmp(string, "023719") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = 0x01;
-	if (strcmp(string, "023720") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = 0x01;
-	if (strcmp(string, "023721") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = 0x01;
-	if (strcmp(string, "023722") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = 0x01;
-	if (strcmp(string, "023723") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = 0x01;
-	if (strcmp(string, "023724") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = 0x01;
-	if (strcmp(string, "023725") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = 0x01;
-	if (strcmp(string, "023726") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = 0x01;
-	if (strcmp(string, "023727") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = 0x01;
-	if (strcmp(string, "023728") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = 0x01;
-	if (strcmp(string, "023729") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = 0x01;
-	if (strcmp(string, "023730") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = 0x01;
-	if (strcmp(string, "023731") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = 0x01;
-	if (strcmp(string, "023732") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = 0x01;
-	if (strcmp(string, "023733") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = 0x01;
-	if (strcmp(string, "023734") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = 0x01;
-	if (strcmp(string, "023735") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = 0x01;
-	if (strcmp(string, "023736") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = 0x01;
-}
-
-void CANReceiver()
-{
-	pid_t canRecPid;
-
-	canRecPid = fork();
-
-	if(canRecPid > 0)
-	{
-		int nbytes;
-		struct can_frame frame;
-		int intCmd;
-		// 槍資訊
-		struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-		struct timeval _cmd_ack_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-		bool isPass = false;
-		while(!isPass)
-		{
-			isPass = true;
-			for (byte _index = 0; _index < gun_count; _index++)
-			{
-				if (!FindChargingInfoData(_index, &_chargingData[0]))
-				{
-					DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
-					isPass = false;
-					break;
-				}
-			}
-		}
-
-		for (byte _index = 0; _index < gun_count; _index++)
-			gettimeofday(&_cmd_ack_timeout[_index], NULL);
-
-		while (1)
-		{
-			memset(&frame, 0, sizeof(struct can_frame));
-			nbytes = read(CanFd, &frame, sizeof(struct can_frame));
-
-			for (byte _index = 0; _index < gun_count; _index++)
-			{
-				if (GetTimeoutValue(_cmd_ack_timeout[_index]) >= 5000000)
-				{
-					// ACK timeout
-					//printf("gun = %x, ack timeout \n", _index);
-				}
-			}
-
-			if (nbytes > 0)
-			{
-				byte target;
-				byte targetGun = 0x00;
-				intCmd = (int) (frame.can_id & CAN_EFF_MASK);
-
-				if (intCmd == ADDRESS_REQ)
-				{
-					AddrAssignment(frame.data);
-					continue;
-				}
-
-				intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
-				target = ((byte) (frame.can_id & 0x000000FF));		// 0x01 or 0x02
-
-				for (byte _index = 0; _index < gun_count; _index++)
-				{
-					if (_chargingData[_index]->Evboard_id == target)
-					{
-						targetGun = _index;
-						break;
-					}
-				}
-
-				if(targetGun < 0 || targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)
-				{
-					printf("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
-					continue;
-				}
-				if(intCmd == 256)
-				{
-					continue;
-				}
-
-				gettimeofday(&_cmd_ack_timeout[targetGun], NULL);
-				switch (intCmd)
-				{
-					case NOTIFICATION_EV_STATUS:
-					{
-						_chargingData[targetGun]->ConnectorPlugIn = frame.data[0];
-						_chargingData[targetGun]->PilotVoltage = frame.data[1];
-
-						//printf("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
-						//printf("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
-					}
-						break;
-					case ACK_EV_FW_VERSION:
-					{
-						if (_chargingData[targetGun]->Type == _Type_Chademo)
-						{
-							memcpy(ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
-							ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-						}
-						else if (_chargingData[targetGun]->Type == _Type_CCS)
-						{
-							printf("Get FW HW = %s \n", frame.data);
-							if (ShmCcsData->CommProtocol == 0x01)
-							{
-								memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
-								ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-							}
-						}
-					}
-						break;
-					case ACK_EV_HW_VERSION:
-					{
-						//printf("Get EV HW = %s \n", frame.data);
-					}
-						break;
-					case ACK_GET_OUTPUT_REQ:
-					{
-						_chargingData[targetGun]->EvBatterySoc = frame.data[1];
-						_chargingData[targetGun]->EvBatterytargetVoltage = ((short) frame.data[3] << 8) + (short) frame.data[2];
-						_chargingData[targetGun]->EvBatterytargetCurrent = ((short) frame.data[5] << 8) + (short) frame.data[4];
-						_chargingData[targetGun]->PresentChargedDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
-
-						if (_chargingData[targetGun]->Type == _Type_Chademo)
-						{
-							if (ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
-							{
-								ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
-							}
-
-							ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
-							ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
-							ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = _chargingData[targetGun]->EvBatterytargetVoltage;
-							ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = _chargingData[targetGun]->EvBatterytargetCurrent;
-						}
-						else if (_chargingData[targetGun]->Type == _Type_CCS)
-						{
-							if(ShmCcsData->CommProtocol == 0x01)
-							{
-								ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
-							}
-						}
-
-						//printf("EvBatterytargetVoltage = %f \n", _chargingData[targetGun]->EvBatterytargetVoltage);
-						//printf("EvBatterytargetCurrent = %f \n", _chargingData[targetGun]->EvBatterytargetCurrent);
-						//printf("BatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
-						//printf("CurrentRequest = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
-					}
-						break;
-					case ACK_GET_EV_BATTERY_INFO:
-					{
-						//_chargingData[target].EvACorDCcharging = frame.data[0];
-						//_chargingData[target]->TotalBatteryCap = ((float) frame.data[4] << 8) + (short) frame.data[3];
-						_chargingData[targetGun]->EvBatteryMaxVoltage = ((short) frame.data[4] << 8) + (short) frame.data[3];
-						//_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
-						//_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
-						if (_chargingData[targetGun]->Type == _Type_Chademo)
-						{
-							ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
-							ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
-
-							//printf("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
-							//printf("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
-							//printf("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
-						}
-						else if (_chargingData[targetGun]->Type == _Type_CCS)
-						{
-
-						}
-					}
-						break;
-					case ACK_GET_MISCELLANEOUS_INFO:
-					{
-						if (_chargingData[targetGun]->Type == _Type_Chademo)
-						{
-							_chargingData[targetGun]->GunLocked = frame.data[0];
-							ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
-							ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
-							_chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
-							ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
-						}
-						else if (_chargingData[targetGun]->Type == _Type_CCS)
-						{
-							if (ShmCcsData->CommProtocol == 0x01)
-							{
-								_chargingData[targetGun]->GunLocked = frame.data[0];
-								//ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureP = frame.data[1];
-								//ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureN = frame.data[2];
-								_chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
-							}
-						}
-
-						//printf("EvboardStatus = %x \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].EvboardStatus);
-						//printf("ConnectorPlug locked = %x \n", frame.data[0]);
-						//printf("ConnectorTemp 0= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureP);
-						//printf("ConnectorTemp 1= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureN);
-						//printf("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
-					}
-						break;
-					case ACK_EVSE_ISOLATION_STATUS:	{}
-						break;
-					case ACK_EVSE_PRECHAGE_INFO:
-					{
-						_chargingData[targetGun]->PrechargeStatus = frame.data[0];
-					}
-						break;
-					case NOTIFICATION_EV_STOP:
-					{
-						// 車端要求停止
-						// frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
-						printf("NOTIFICATION_EV_STOP -----------------------------\n");
-						if (frame.data[0] == 0x02)
-						{
-							AbnormalStopAnalysis(targetGun, frame.data + 1);
-						}
-						_chargingData[targetGun]->StopChargeFlag = YES;
-					}
-						break;
-					default:
-						printf("EV board = %d, Ack none defined. intCmd = %d  \n", targetGun, intCmd);
-						break;
-				}
-			}
-			usleep(10000);
-		}
-	}
-}
-
-//================================================
-// Main process
-//================================================
-// 檢查 Byte 中某個 Bit 的值
-// _byte : 欲改變的 byte
-// _bit : 該 byte 的第幾個 bit
-unsigned char EvDetectionStatus(unsigned char _byte, unsigned char _bit)
-{
-	return ( _byte & mask_table[_bit] ) != 0x00;
-}
-
-bool IsConnectorPlugIn(struct ChargingInfoData *chargingData)
-{
-	return (chargingData->ConnectorPlugIn == 0x01) ? true : false;
-}
-
-void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
-{
-	float vol1 = 0, cur1 = 0;
-	float vol2 = 0, cur2 = 0;
-
-	//printf("f vol - 0 = %f \n", chargingData_1->FireChargingVoltage);
-	//printf("f cur - 0 = %f \n", chargingData_1->PresentChargingCurrent);
-	//printf("***********************f vol - 1 = %f \n", chargingData_2->FireChargingVoltage);
-	//printf("***********************f cur - 1 = %f \n", chargingData_2->PresentChargingCurrent);
-
-	vol1 = chargingData_1->FireChargingVoltage;
-	cur1 = chargingData_1->PresentChargingCurrent;
-
-	vol2 = chargingData_2->FireChargingVoltage;
-	cur2 = chargingData_2->PresentChargingCurrent;
-
-	SetPresentOutputPower(vol1, cur1, vol2, cur2);
-}
-
-void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
-{
-	float pow1 = 0, cur1 = 0;
-	float pow2 = 0, cur2 = 0;
-	float vol = 0;
-
-	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-	{
-		pow1 = chargingData_1->DeratingChargingPower;
-		cur1 = chargingData_1->DeratingChargingCurrent;
-	}
-	else
-	{
-		pow1 = chargingData_1->AvailableChargingPower;
-		cur1 = chargingData_1->AvailableChargingCurrent;
-	}
-	vol = chargingData_1->MaximumChargingVoltage;
-	GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
-
-	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-	{
-		pow2 = chargingData_2->DeratingChargingPower;
-		cur2 = chargingData_2->DeratingChargingCurrent;
-	}
-	else
-	{
-		pow2 = chargingData_2->AvailableChargingPower;
-		cur2 = chargingData_2->AvailableChargingCurrent;
-	}
-	vol = chargingData_2->MaximumChargingVoltage;
-	GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
-
-	printf("To EV Power_1 = %f, Cur_1 = %f, Power_2 = %f, Cur_2 = %f \n", pow1, cur1, pow2, cur2);
-	SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
-}
-
-void Initialization()
-{
-	bool isPass = false;
-	while(!isPass)
-	{
-		isPass = true;
-		for (byte _index = 0; _index < gun_count; _index++)
-		{
-			if (!FindChargingInfoData(_index, &_chargingData[0]))
-			{
-				DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
-				isPass = false;
-				break;
-			}
-		}
-	}
-}
-
-void GetMaxVolAndCurMethod(byte index, float *vol, float *cur)
-{
-	if (maxChargingVol != 0 && maxChargingVol <= *vol)
-		*vol = maxChargingVol;
-
-	if (maxChargingCur != 0 && maxChargingCur <= *cur)
-		*cur = maxChargingCur;
-}
-
-void GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
-{
-	if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == 0x01)
-	{
-		// 012251
-		*(reason + 5) = 0;
-		*(reason + 4)  = 1;
-		*(reason + 3)  = 2;
-		*(reason + 2)  = 2;
-		*(reason + 1)  = 5;
-		*(reason + 0)  = 1;
-	}
-	else if (_chargingData[gunIndex]->Type == _Type_Chademo &&
-			ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == 0x01)
-	{
-		// 011012
-		*(reason + 5) = 0;
-		*(reason + 4) = 1;
-		*(reason + 3) = 1;
-		*(reason + 2) = 0;
-		*(reason + 1) = 1;
-		*(reason + 0) = 2;
-	}
-	else if (_chargingData[gunIndex]->Type == _Type_CCS &&
-			ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault == 0x01)
-	{
-		// 011014
-		*(reason + 5) = 0;
-		*(reason + 4) = 1;
-		*(reason + 3) = 1;
-		*(reason + 2) = 0;
-		*(reason + 1) = 1;
-		*(reason + 0) = 4;
-	}
-}
-
-int main(int argc, char *argv[])
-{
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitShareMemory NG\n");
-		#endif
-		if(ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
-		}
-		sleep(5);
-		return 0;
-	}
-
-	Initialization();
-	CanFd = InitCanBus();
-	CANReceiver();
-
-	byte priorityLow = 1;
-#if (!DEMO)
-	while(CanFd)
-	{
-		for(byte _index = 0; _index < gun_count; _index++)
-		{
-			if (priorityLow == 1)
-			{
-				// 優先權較低 - 只要有回應即不會再詢問
-				if (_chargingData[_index]->Type == _Type_Chademo &&
-						ShmCHAdeMOData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
-				{
-					GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
-					GetHardwareVersion(_index, _chargingData[_index]->Evboard_id);
-				}
-				else if (_chargingData[_index]->Type == _Type_CCS)
-				{
-					if (ShmCcsData->CommProtocol == 0x01 &&
-						ShmCcsData->V2GMessage_DIN70121[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
-					{
-						GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
-						GetHardwareVersion(_index, _chargingData[_index]->Evboard_id);
-					}
-				}
-
-				// 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
-				//printf("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
-				GetMiscellaneousInfo(_index, _chargingData[_index]->Evboard_id);
-			}
-
-			switch (_chargingData[_index]->SystemStatus)
-			{
-				case S_IDLE:
-					_chargingData[_index]->PresentChargedEnergy = 0;
-					_chargingData[_index]->GroundFaultStatus = GFD_WAIT;
-					_chargingData[_index]->StopChargeFlag = NO;
-					chargingTime[_index] = 0;
-
-					if (_chargingData[_index]->Type == _Type_Chademo)
-					{
-						ClearAbnormalStatus_Chadmoe(_index);
-					}
-					else if (_chargingData[_index]->Type == _Type_CCS)
-					{
-
-					}
-					break;
-				case S_PREPARING_FOR_EV:
-				{
-					// 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
-					GetOutputReq(_index, _chargingData[_index]->Evboard_id);
-
-					//printf("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
-					//printf("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
-					//printf("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
-					//printf("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
-					//printf("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
-
-					// 設定當前輸出
-					if (gun_count == 1)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
-					else if (gun_count == 2)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
-
-					if (priorityLow == 1)
-					{
-						float maxVol, maxCur;
-						// 樁端輸出能力
-						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-						{
-							maxVol = _chargingData[_index]->MaximumChargingVoltage;
-							maxCur = _chargingData[_index]->DeratingChargingCurrent;
-						}
-						else
-						{
-							maxVol = _chargingData[_index]->MaximumChargingVoltage;
-							maxCur = _chargingData[_index]->AvailableChargingCurrent;
-						}
-						GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
-
-						printf("To EV Max_Vol = %f, Cap_Cur = %f \n", maxVol, maxCur);
-						SetChargingPermission(_index, START,
-						_chargingData[_index]->AvailableChargingPower,
-								maxCur,
-								maxVol,
-								_chargingData[_index]->Evboard_id);
-
-						// 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
-						GetEvBatteryInfo(_index, _chargingData[_index]->Evboard_id);
-					}
-				}
-					break;
-				case S_PREPARING_FOR_EVSE:
-				case S_CCS_PRECHARGE_ST0:
-				case S_CCS_PRECHARGE_ST1:
-				{
-					// 開始確認車端是否同意開始充電
-					GetOutputReq(_index, _chargingData[_index]->Evboard_id);
-
-					// 設定當前輸出
-					if (gun_count == 1)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
-					else if (gun_count == 2)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
-
-					if (priorityLow % 5 == 1)
-					{
-						// 樁端輸出能力改變
-						if (gun_count == 1)
-							SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
-						else if (gun_count == 2)
-							SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
-					}
-
-					// 持續通知 Isolation 測試狀態
-					if (priorityLow == 1)
-					{
-						// 拉 500 V 如果在一秒鐘內 GFD 都符合則 PASS
-						if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
-						{
-							SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, _chargingData[_index]->Evboard_id);
-						}
-
-						if(_chargingData[_index]->SystemStatus == S_CCS_PRECHARGE_ST0 &&
-							_chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
-						{
-							SetEvsePrechargeInfo(_index, PRECHARGE_PRERELAY_PASS, _chargingData[_index]->Evboard_id);
-						}
-					}
-				}
-					break;
-				case S_CHARGING:
-				{
-					// 計算 Power
-					_chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage / 10) * (_chargingData[_index]->PresentChargingCurrent / 10)) / 1000);
-
-					if (chargingTime[_index] == 0)
-					{
-						chargingTime[_index] = _chargingData[_index]->RemainChargingDuration;
-					}
-					else
-					{
-						int passTime = _chargingData[_index]->RemainChargingDuration - chargingTime[_index];
-
-						if (passTime > 0)
-						{
-							_chargingData[_index]->PresentChargedEnergy += (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
-							chargingTime[_index] = _chargingData[_index]->RemainChargingDuration;
-						}
-					}
-
-					// 開始確認車端是否同意開始充電
-					GetOutputReq(_index, _chargingData[_index]->Evboard_id);
-
-					// 設定當前輸出
-					if (gun_count == 1)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
-					else if (gun_count == 2)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
-
-					// for test end
-					if (priorityLow % 5 == 0)
-					{
-						// 樁端輸出能力改變
-						if (gun_count == 1)
-							SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
-						else if (gun_count == 2)
-							SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
-					}
-
-					// GFD 失敗再通知
-					if (priorityLow == 1)
-					{
-						if(_chargingData[_index]->GroundFaultStatus == GFD_FAIL)
-						{
-							SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, _chargingData[_index]->Evboard_id);
-						}
-
-						if(_chargingData[_index]->Type == _Type_CCS &&
-							_chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
-						{
-							SetEvsePrechargeInfo(_index, PRECHARGE_CHARELAY_PASS, _chargingData[_index]->Evboard_id);
-						}
-					}
-				}
-					break;
-				case S_TERMINATING:
-				{
-					// 設定當前輸出
-					if (gun_count == 1)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
-					else if (gun_count == 2)
-						SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
-
-					// 槍鎖還在,則代表是樁端要求的停止
-					if (_chargingData[_index]->GunLocked == START)
-					{
-						byte normalStop = 0x01;
-						byte stopReason[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-						if (strlen((char *)ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[_index]) > 0)
-						{
-							normalStop = 0x02;
-							GetStopChargingReasonByEvse(_index, stopReason);
-						}
-
-						EvseStopChargingEvent(normalStop, stopReason, _chargingData[_index]->Evboard_id);
-					}
-					GetOutputReq(_index, _chargingData[_index]->Evboard_id);
-				}
-					break;
-				case S_COMPLETE:
-				{
-					if (priorityLow == 1)
-					{
-						// 樁端輸出能力
-						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-						{
-							SetChargingPermission(_index, STOP,
-									_chargingData[_index]->DeratingChargingPower,
-									_chargingData[_index]->DeratingChargingCurrent,
-									_chargingData[_index]->MaximumChargingVoltage,
-									_chargingData[_index]->Evboard_id);
-						}
-						else
-						{
-							SetChargingPermission(_index, STOP,
-									_chargingData[_index]->AvailableChargingPower,
-									_chargingData[_index]->AvailableChargingCurrent,
-									_chargingData[_index]->MaximumChargingVoltage,
-									_chargingData[_index]->Evboard_id);
-						}
-					}
-				}
-					break;
-			}
-		}
-		priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
-		usleep(45000); //EV 小板通訊 (50 ms)
-	}
-#else
-#endif
-	DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
-	return FAIL;
-}

+ 0 - 77
EVSE/Projects/DS60-120/Apps/Module_EvComm.h

@@ -1,77 +0,0 @@
-#ifndef MODULE_EVCOMM_H_
-#define MODULE_EVCOMM_H_
-
-#include 	<stdbool.h>
-
-int CanFd;
-
-typedef unsigned char 		byte;
-
-extern struct Ev_Board_Cmd
-{
-	int none;							// 0
-	int address_assignment;				// 0x00000200
-	int get_firmware_ver;				// 0x00000400
-	int get_hardware_ver;				// 0x00000500
-	int charging_permission;			// 0x00000600
-	int present_output_power;			// 0x00000700
-	int present_output_cap;				// 0x00000800
-	int get_output_req;					// 0x00000900
-	int get_battery_info;				// 0x00000A00
-	int evse_stop_charging;				// 0x00000C00
-	int get_miscellaneous_info;			// 0x00000D00
-
-	int download_req;					// 0x00000E00
-	int start_block_transfer;			// 0x00000F00
-	int data_transfer;					// 0x00001000
-	int download_finish;				// 0x00001100
-
-	int isolation_status;				// 0x00001200
-	int evse_precharge_info;			// 0x00001500
-}Ev_Cmd;
-
-extern struct Ev_Cmd_Dir
-{
-	unsigned short master_to_slave;
-	unsigned short slave_to_master;
-}Ev_Dir;
-
-struct timeval _id_assign_time;
-
-// Send msg to can-bus
-void SetTargetAddr(byte *target_number, byte index);
-
-void GetFirmwareVersion(byte gun_index, byte toId);
-void GetHardwareVersion(byte gun_index, byte toId);
-void SetChargingPermission(byte gun_index, byte permissionStatus, short aOutputPw, short aOutputVol, short aOutputCur, byte toId);
-void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2);
-void SetPresentOutputCapacity(short aOutputPw_b1, short aOutputCur_b1, short aOutputPw_b2, short aOutputCur_b2);
-void GetOutputReq(byte gun_index, byte toId);
-void GetEvBatteryInfo(byte gun_index, byte toId);
-void GetMiscellaneousInfo(byte gun_index, byte toId);
-void SetIsolationStatus(byte gun_index, byte result, byte toId);
-void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId);
-// 發送電樁主動停止充電結果及原因
-void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId);
-
-// Receive msg From can-bus.
-
-enum Receieve_PSU_msgf
-{
-	// 車端主動
-	ADDRESS_REQ = 						0x080001FF,
-	NOTIFICATION_EV_STATUS = 			0x08000300,
-	NOTIFICATION_EV_STOP = 				0x08000B00,
-
-	// 車端回應
-	ACK_EV_FW_VERSION = 				0x08000400,
-	ACK_EV_HW_VERSION = 				0x08000500,
-	ACK_GET_OUTPUT_REQ =				0x08000900,
-	ACK_GET_EV_BATTERY_INFO =			0x08000A00,
-	ACK_GET_MISCELLANEOUS_INFO = 		0x08000D00,
-	ACK_EVSE_ISOLATION_STATUS = 		0x08001200,
-	ACK_EVSE_PRECHAGE_INFO = 			0x08001500,
-};
-
-#endif /* MODULE_EVCOMM_H_ */
-

+ 0 - 298
EVSE/Projects/DS60-120/Apps/Module_EventLogging.c

@@ -1,298 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include	"../../define.h"
-
-#define Debug
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-
-int StoreLogMsg(const char *fmt, ...);
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-int StoreLogMsg(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	time_t CurrentTime;
-	struct tm *tm;
-	va_list args;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1);
-	system(Buf);
-
-	return rc;
-}
-
-int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-	//return milli-second
-	unsigned int StartTime,StopTime;
-
-	StartTime=(unsigned int)ST.time;
-	StopTime=(unsigned int)ET.time;
-	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
-}
-
-//=================================
-// Common routine
-//=================================
-char* getTimeString(void)
-{
-	char *result=malloc(21);
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
-
-	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-
-	return result;
-}
-
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-	int result = PASS;
-	int MeterSMId;
-
-	//creat ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-		#endif
-    	result = FAIL;
-   	 }
-    else
-    {}
-
-   	 //creat ShmStatusCodeData
-   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
-   		result = FAIL;
-	}
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
-    	result = FAIL;
-   	}
-    else
-    {}
-
-    return result;
-}
-
-//================================================
-// Main process
-//================================================
-void AddFaultCodeToBuf(unsigned char *Code)
-{
-	if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount < 10)
-	{
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[ShmSysConfigAndInfo->SysWarningInfo.WarningCount][0], Code, 7);
-		ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
-	}
-}
-
-void RemoveFaultCodeToBuf(unsigned char *Code)
-{
-	unsigned char find = 0x00;
-	char _code[7];
-	sprintf(_code,"%s", Code);
-
-	for(unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
-	{
-		if (find == 0x00)
-		{
-			if(memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) != 0)
-			{
-				find = 0x01;
-			}
-		}
-		else
-		{
-			if(i == ShmSysConfigAndInfo->SysWarningInfo.WarningCount - 1)
-			{
-				memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "", 7);
-			}
-			else
-			{
-				memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
-						&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + 1][0], 7);
-			}
-		}
-	}
-
-	ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
-}
-
-int main(void)
-{
-	int ByteCount,BitCount;
-	unsigned char tmp, EventCodeTmp[7];
-
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitShareMemory NG\n");
-		#endif
-		if(ShmStatusCodeData!=NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
-		}
-		sleep(5);
-		return 0;
-	}
-
-	for(;;)
-	{
-		//check Fault Status
-		for(ByteCount=0;ByteCount<4;ByteCount++)
-		{
-			if(ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount] != ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount])
-			{
-				tmp=ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount]; //prevent be modified during following process
-				for(BitCount=0;BitCount<8;BitCount++)
-				{
-					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]>>BitCount)&0x01))
-					{
-						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
-						memcpy(EventCodeTmp,FaultStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
-						if(((tmp>>BitCount)&0x01)==0)//Recovered
-						{
-							//EventCodeTmp[0]=1;
-							DEBUG_INFO("Recovery Fault Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
-						}
-						else
-						{
-							DEBUG_INFO("Fault Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
-						}
-					}
-				}
-			}
-		}
-
-		//check Alarm Status
-		for(ByteCount=0;ByteCount<8;ByteCount++)
-		{
-			if(ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount] != ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount])
-			{
-				tmp=ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount]; //prevent be modified during following process
-				for(BitCount=0;BitCount<8;BitCount++)
-				{
-					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]>>BitCount)&0x01))
-					{
-						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
-						memcpy(EventCodeTmp,AlarmStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
-						if(((tmp>>BitCount)&0x01)==0)//Recovered
-						{
-							//EventCodeTmp[0]=1;
-							DEBUG_INFO("Recovery Alarm Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
-						}
-						else
-						{
-							DEBUG_INFO("Alarm Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
-						}
-					}
-				}
-			}
-		}
-
-		//check Info Status
-		for(ByteCount=0;ByteCount<8;ByteCount++)
-		{
-			if(ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount])
-			{
-				tmp=ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount]; //prevent be modified during following process
-				for(BitCount=0;BitCount<8;BitCount++)
-				{
-					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]>>BitCount)&0x01))
-					{
-						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
-						memcpy(EventCodeTmp,InfoStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
-						if(((tmp>>BitCount)&0x01)==0)//Recovered
-						{
-							//EventCodeTmp[0]=1;
-							DEBUG_INFO("Recovery Info Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
-						}
-						else
-						{
-							DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
-						}
-					}
-				}
-			}
-		}
-		usleep(500000);
-	}
-
-	return FAIL;
-}

+ 0 - 1347
EVSE/Projects/DS60-120/Apps/Module_InternalComm.c

@@ -1,1347 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include	"../../define.h"
-#include	"internalComm.h"
-#include 	<stdbool.h>
-
-#define Debug
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-#define YES					1
-#define NO					0
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-struct FanModuleData			*ShmFanModuleData;
-struct RelayModuleData			*ShmRelayModuleData;
-struct CHAdeMOData				*ShmCHAdeMOData;
-struct CcsData					*ShmCcsData;
-
-#define VIN_MAX_VOLTAGE		250	// 大於該值 : OVP
-#define VIN_MIN_VOLTAGE		170	// 小於該值 : UVP
-#define VIN_DROP_VOLTAGE	150	// 小於該值 : ac drop
-
-#define VOUT_MAX_VOLTAGE	750
-#define VOUT_MIN_VOLTAGE	150
-#define IOUT_MAX_CURRENT	50
-
-#define MAX_FAN_SPEED		6000
-#define MIN_FAN_SPEED		300
-
-// GFD Status
-#define GFD_IDLE			0
-#define GFD_CABLECHK		1
-#define GFD_PRECHARGE		2
-#define GFD_CHARGING		3
-
-// 最小切換 Relay 電壓
-#define SELF_TO_CHANGE_RELAY_STATUS			600
-// 透過電壓確認 Relay 是否搭上的依據電壓
-#define CHECK_RELAY_STATUS					300
-#define CHECK_RELAY_STATUS_GAP				100
-// 安全在停止充電程序中斷開 Relay 的電流
-#define SEFETY_SWITCH_RELAY_CUR				20
-// 確認 Relay Welding 電壓
-#define RELAY_WELDING_DET					300
-
-byte gunCount = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
-// 槍資訊
-struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-byte gfdChkFailCount[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData);
-
-int Uart5Fd;
-char *relayRs485PortName = "/dev/ttyS5";
-unsigned short fanSpeedSmoothValue = 100;
-
-struct timeval _priority_time;
-
-Ver ver;
-PresentInputVoltage inputVoltage;
-PresentOutputVoltage outputVoltage;
-FanSpeed fanSpeed;
-Temperature temperature;
-AuxPower auxPower;
-Gfd gfd_adc;
-Gfd_config gfd_config;
-Gpio_in gpio_in;
-Gpio_out gpio_out;
-Relay outputRelay;
-Relay regRelay;
-
-int StoreLogMsg(const char *fmt, ...);
-unsigned long GetTimeoutValue(struct timeval _sour_time);
-
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-unsigned long GetTimeoutValue(struct timeval _sour_time)
-{
-	struct timeval _end_time;
-	gettimeofday(&_end_time, NULL);
-
-	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
-}
-
-int StoreLogMsg(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	time_t CurrentTime;
-	struct tm *tm;
-	va_list args;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1);
-	system(Buf);
-
-	return rc;
-}
-
-int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-	//return milli-second
-	unsigned int StartTime,StopTime;
-
-	StartTime=(unsigned int)ST.time;
-	StopTime=(unsigned int)ET.time;
-	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
-}
-
-unsigned short MaxValue(unsigned short value1, unsigned short value2)
-{
-	return value1 >= value2 ? value1 : value2;
-}
-
-//==========================================
-// Communication Function
-//==========================================
-void GetFwAndHwVersion_Aux()
-{
-	if (Query_FW_Ver(Uart5Fd, Addr.Aux, &ver) == PASS)
-	{
-		// SystemInfo
-		strcpy((char *) ShmSysConfigAndInfo->SysInfo.AuxPwrFwRev, ver.Version_FW);
-		printf("s1 = %s \n", ver.Version_FW);
-	}
-
-	if (Query_HW_Ver(Uart5Fd, Addr.Aux, &ver) == PASS)
-	{
-		// SystemInfo
-		strcpy((char *) ShmSysConfigAndInfo->SysInfo.AuxPwrHwRev, ver.Version_HW);
-		printf("s2 = %s \n", ver.Version_HW);
-	}
-}
-
-void GetFwAndHwVersion_Fan()
-{
-	if(Query_FW_Ver(Uart5Fd, Addr.Fan, &ver) == PASS)
-	{
-		// FanModuleData
-		strcpy((char *) ShmFanModuleData->version, ver.Version_FW);
-		// SystemInfo
-		strcpy((char *) ShmSysConfigAndInfo->SysInfo.FanModuleFwRev, ver.Version_FW);
-		printf("GetFwAndHwVersion_Fan s1 = %s \n", ver.Version_FW);
-	}
-
-	if (Query_HW_Ver(Uart5Fd, Addr.Fan, &ver) == PASS)
-	{
-		// SystemInfo
-		strcpy((char *) ShmSysConfigAndInfo->SysInfo.FanModuleHwRev, ver.Version_FW);
-		printf("GetFwAndHwVersion_Fan s2 = %s \n", ver.Version_HW);
-	}
-}
-
-void GetFwAndHwVersion_Relay()
-{
-	if (Query_FW_Ver(Uart5Fd, Addr.Relay, &ver) == PASS)
-	{
-		// FanModuleData
-		strcpy((char *) ShmRelayModuleData->version, ver.Version_FW);
-		// SystemInfo
-		strcpy((char *) ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev, ver.Version_FW);
-		printf("GetFwAndHwVersion_Relay s1 = %s \n", ver.Version_FW);
-	}
-
-	if (Query_HW_Ver(Uart5Fd, Addr.Relay, &ver) == PASS)
-	{
-		// SystemInfo
-		strcpy((char *) ShmSysConfigAndInfo->SysInfo.RelayModuleHwRev, ver.Version_FW);
-		printf("GetFwAndHwVersion_Relay s2 = %s \n", ver.Version_HW);
-	}
-}
-
-void GetTemperature_Aux()
-{
-	memset(temperature.temperature, 0, ARRAY_SIZE(temperature.temperature));
-	if (Query_Temperature(Uart5Fd, Addr.Aux, &temperature) == PASS)
-	{
-		// aux temp
-		// UI 實際顯示溫度轉換
-		//char s[4];
-		//sprintf(s,"%d",(-60 + temperature[2].temperature[4])),
-		//printf("s = %s \n",s);
-
-		printf("Aux temp = %d,%d,%d,%d,%d,%d,%d,%d \n",
-				(-60 + temperature.temperature[0]),
-				(-60 + temperature.temperature[1]),
-				(-60 + temperature.temperature[2]),
-				(-60 + temperature.temperature[3]),
-				(-60 + temperature.temperature[4]),
-				(-60 + temperature.temperature[5]),
-				(-60 + temperature.temperature[6]),
-				(-60 + temperature.temperature[7]));
-	}
-}
-
-void GetTemperature_Relay()
-{
-	memset(temperature.temperature, 0, ARRAY_SIZE(temperature.temperature));
-	if (Query_Temperature(Uart5Fd, Addr.Relay, &temperature) == PASS)
-	{
-		// relay temp
-		printf("Relay temp = %d,%d,%d,%d,%d,%d,%d,%d \n",
-				(-60 + temperature.temperature[0]),
-				(-60 + temperature.temperature[1]),
-				(-60 + temperature.temperature[2]),
-				(-60 + temperature.temperature[3]),
-				(-60 + temperature.temperature[4]),
-				(-60 + temperature.temperature[5]),
-				(-60 + temperature.temperature[6]),
-				(-60 + temperature.temperature[7]));
-	}
-}
-
-// AC 三相輸入電壓
-void GetPresentInputVol()
-{
-	if (Query_Present_InputVoltage(Uart5Fd, Addr.Relay, &inputVoltage) == PASS)
-	{
-		// resolution : 0.1
-		//printf("InputVoltageR = %f \n", inputVoltage.L1N_L12);
-		//printf("InputVoltageS = %f \n", inputVoltage.L2N_L23);
-		//printf("InputVoltageT = %f \n", inputVoltage.L3N_L31);
-
-		ShmRelayModuleData->InputL1Volt = inputVoltage.L1N_L12;
-		ShmRelayModuleData->InputL2Volt = inputVoltage.L2N_L23;
-		ShmRelayModuleData->InputL3Volt = inputVoltage.L3N_L31;
-
-		//********************************************************************************************************//
-		// VIN < 170
-		if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = 0x01;
-		}
-		if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = 0x01;
-		}
-		if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = 0x01;
-		}
-
-		//********************************************************************************************************//
-		// VIN > 250
-		if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE)
-		{
-			//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = 0x01;
-		}
-		if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE)
-		{
-			//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = 0x01;
-		}
-		if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE)
-		{
-			//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = 0x01;
-		}
-		//********************************************************************************************************//
-		// VIN < 150
-		if (inputVoltage.L1N_L12 < VIN_DROP_VOLTAGE)
-		{
-			//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = 0x01;
-		}
-		if (inputVoltage.L2N_L23 < VIN_DROP_VOLTAGE)
-		{
-			//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop = 0x01;
-		}
-		if (inputVoltage.L3N_L31 < VIN_DROP_VOLTAGE)
-		{
-			//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop = 0x01;
-		}
-
-		//********************************************************************************************************//
-		// 150 <= VIN < 160
-//		if (inputVoltage.L1N_L12 >= VIN_MIN_VOLTAGE && inputVoltage.L1N_L12 <= VIN_LOW_VOLTAGE)
-//		{
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = 0x00;
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = 0x00;
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = 0x00;
-//		}
-//		if (inputVoltage.L2N_L23 >= VIN_MIN_VOLTAGE && inputVoltage.L2N_L23 <= VIN_LOW_VOLTAGE)
-//		{
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = 0x00;
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = 0x00;
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop = 0x00;
-//		}
-//		if (inputVoltage.L3N_L31 >= VIN_MIN_VOLTAGE && inputVoltage.L3N_L31 <= VIN_LOW_VOLTAGE)
-//		{
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = 0x00;
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = 0x00;
-//			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop = 0x00;
-//		}
-	}
-}
-
-// 左右槍的 Relay 前後的輸出電壓
-void GetPersentOutputVol()
-{
-	if (Query_Present_OutputVoltage(Uart5Fd, Addr.Relay, &outputVoltage) == PASS)
-	{
-//		printf("Conn1 fuse 1 = %f \n", outputVoltage.behindFuse_Voltage_C1);
-//		printf("Conn1 relay 1 = %f \n", outputVoltage.behindRelay_Voltage_C1);
-//		printf("Conn2 fuse 2 = %f \n", outputVoltage.behindFuse_Voltage_C2);
-//		printf("Conn2 relay 2 = %f \n", outputVoltage.behindRelay_Voltage_C2);
-
-		//printf("outputVoltage.behindFuse_Voltage_C1 = %f \n", outputVoltage.behindFuse_Voltage_C1);
-		//printf("outputVoltage.behindFuse_Voltage_C2 = %f \n", outputVoltage.behindFuse_Voltage_C2);
-
-		ShmRelayModuleData->Gun1FuseOutputVolt = outputVoltage.behindFuse_Voltage_C1;
-		ShmRelayModuleData->Gun1RelayOutputVolt = outputVoltage.behindRelay_Voltage_C1;
-		ShmRelayModuleData->Gun2FuseOutputVolt = outputVoltage.behindFuse_Voltage_C2;
-		ShmRelayModuleData->Gun2RelayOutputVolt = outputVoltage.behindRelay_Voltage_C2;
-
-		for (int index = 0; index < gunCount; index++)
-		{
-			if (index == 0)
-			{
-				if (_chargingData[index]->Evboard_id == 0x01)
-				{
-					_chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun1FuseOutputVolt;
-					_chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
-				}
-				else if (_chargingData[index]->Evboard_id == 0x02)
-				{
-					_chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
-					_chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
-				}
-			}
-			else if (index == 1)
-			{
-				_chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
-				_chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
-			}
-
-			unsigned short Ovp = 0;
-			unsigned short Ocp = 0;
-			//Ovp = MIN [VOUT_MAX_VOLTAGE, EV_BATTERY_VOLTAGE] 	// 最大輸出電壓與電池電壓最大值
-			//Ocp = MIN [IOUT_MAX_CURRENT, EV_CURRENT_REQ]		// 最大輸出電流與需求電流最小值
-			if (_chargingData[index]->Type == _Type_Chademo)
-			{
-				Ovp = MaxValue(_chargingData[index]->MaximumChargingVoltage, _chargingData[index]->EvBatteryMaxVoltage);
-				Ocp = MaxValue(_chargingData[index]->PresentChargingCurrent, ShmCHAdeMOData->ev[_chargingData[index]->type_index].ChargingCurrentRequest);
-				if (_chargingData[index]->PresentChargingVoltage >= Ovp)
-				{
-					//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = 0x01;
-				}
-				if (_chargingData[index]->PresentChargingCurrent >= Ocp)
-				{
-					//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOCP = 0x01;
-				}
-			}
-			else if (_chargingData[index]->Type == _Type_CCS)
-			{
-
-			}
-		}
-	}
-}
-
-// 風扇速度
-void GetFanSpeed()
-{
-	printf("Get fan board speed \n");
-	if (Query_Fan_Speed(Uart5Fd, Addr.Fan, &fanSpeed) == PASS)
-	{
-		ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0];
-		ShmFanModuleData->PresentFan2Speed = fanSpeed.speed[1];
-		ShmFanModuleData->PresentFan3Speed = fanSpeed.speed[2];
-		ShmFanModuleData->PresentFan4Speed = fanSpeed.speed[3];
-		printf("SystemFanRotaSpeed_1 = %d \n", fanSpeed.speed[0]);
-		printf("SystemFanRotaSpeed_2 = %d \n", fanSpeed.speed[1]);
-		printf("SystemFanRotaSpeed_3 = %d \n", fanSpeed.speed[2]);
-		printf("SystemFanRotaSpeed_4 = %d \n", fanSpeed.speed[3]);
-		// Config_Fan_Speed(Uart5Fd, Addr.Fan, &fanSpeed[0]);
-		//SysInfoData (SystemFanRotaSpeed)
-	}
-}
-
-// 讀取 Relay 狀態
-void GetRelayOutputStatus()
-{
-	if (Query_Relay_Output(Uart5Fd, Addr.Relay, &regRelay) == PASS)
-	{
-		regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-	}
-}
-
-// 確認 K1 K2 relay 的狀態
-void CheckK1K2RelayOutput(byte index)
-{
-	if (index == 0)
-	{
-		if (_chargingData[index]->Evboard_id == 0x01)
-		{
-			if (regRelay.relay_event.bits.Gun1_N == YES && regRelay.relay_event.bits.Gun1_P == YES)
-				_chargingData[index]->RelayK1K2Status = YES;
-			else
-				_chargingData[index]->RelayK1K2Status = NO;
-
-			if(_chargingData[index]->Type == _Type_CCS)
-			{
-				if (regRelay.relay_event.bits.Gun1_N == YES	&& regRelay.relay_event.bits.CCS_Precharge == YES)
-					_chargingData[index]->RelayKPK2Status = YES;
-				else
-					_chargingData[index]->RelayKPK2Status = NO;
-			}
-		}
-		else if (_chargingData[index]->Evboard_id == 0x02)
-		{
-			if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.Gun2_P == YES)
-				_chargingData[index]->RelayK1K2Status = YES;
-			else
-				_chargingData[index]->RelayK1K2Status = NO;
-
-			if(_chargingData[index]->Type == _Type_CCS)
-			{
-				if (regRelay.relay_event.bits.Gun2_N == YES	&& regRelay.relay_event.bits.CCS_Precharge == YES)
-					_chargingData[index]->RelayKPK2Status = YES;
-				else
-					_chargingData[index]->RelayKPK2Status = NO;
-			}
-
-		}
-	}
-	else if (index == 1)
-	{
-		if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.Gun2_P == YES)
-			_chargingData[index]->RelayK1K2Status = YES;
-		else
-			_chargingData[index]->RelayK1K2Status = NO;
-
-		if(_chargingData[index]->Type == _Type_CCS)
-		{
-			if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES)
-				_chargingData[index]->RelayKPK2Status = YES;
-			else
-				_chargingData[index]->RelayKPK2Status = NO;
-		}
-	}
-
-	if (regRelay.relay_event.bits.Gun1_Parallel_N == YES && regRelay.relay_event.bits.Gun1_Parallel_P == YES)
-		ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
-	else
-		ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = NO;
-}
-
-void GetGfdAdc()
-{
-	// define : 每 0.2 ~ 1 秒一次
-	// occur : <= 75k 歐姆 @ 150 - 750 Vdc
-	// warning : >= 100 歐姆 && <= 500 歐姆 @ 150-750 Vdc
-	if (Query_Gfd_Adc(Uart5Fd, Addr.Relay, &gfd_adc) == PASS)
-	{
-		for (int i = 0; i < gunCount; i++)
-		{
-			if (i == 0)
-			{
-				_chargingData[i]->GroundFaultStatus = gfd_adc.result_conn1;
-				if (_chargingData[i]->GroundFaultStatus == GFD_FAIL)
-				{
-					DEBUG_ERROR("GFD Fail. index = %d, R = %d, Vol = %d \n",
-							i, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
-				}
-			}
-			else if (i == 1)
-			{
-				_chargingData[i]->GroundFaultStatus = gfd_adc.result_conn2;
-				if (_chargingData[i]->GroundFaultStatus == GFD_FAIL)
-				{
-					DEBUG_ERROR("GFD Fail. index = %d, R = %d, Vol = %d \n",
-							i, gfd_adc.Resister_conn2, gfd_adc.voltage_conn2);
-				}
-			}
-		}
-
-		//if (gfd_adc.result_conn1 != 0)
-		{
-//			printf("******************Resister_conn1 = %d, voltage_conn1 = %d, result_conn1 = %d, step = %d \n",
-//				gfd_adc.Resister_conn1,
-//				gfd_adc.voltage_conn1,
-//				gfd_adc.result_conn1,
-//				gfd_adc.rb_step_1);
-		}
-	}
-}
-
-void GetGpioInput()
-{
-	if (Query_Gpio_Input(Uart5Fd, Addr.Aux, &gpio_in) == PASS)
-	{
-		// AC Contactor Status
-		//ShmSysConfigAndInfo->SysInfo.AcContactorStatus = gpio_in.AC_Connector;
-
-		if (gpio_in.AC_MainBreaker == 1)
-		{
-			// AC Main Breaker ON
-			printf("RB AC Main Breaker. \n");
-		}
-
-		if (gpio_in.SPD == 1)
-		{
-			// SPD (雷擊保護) ON
-			printf("RB SPD. \n");
-		}
-
-		if (gpio_in.Door_Open == 1)
-		{
-			// Door Open
-			printf("RB Door Open. \n");
-		}
-
-		if (gpio_in.GFD[0] == 1)
-		{
-			// GFD_1 Trigger
-		}
-
-		if (gpio_in.GFD[1] == 1)
-		{
-			// GFD_2 Trigger
-		}
-
-		if (gpio_in.AC_Drop == 1)
-		{
-			// AC Drop
-			printf("RB AC Drop. \n");
-		}
-
-		if (gpio_in.Emergency_IO == 1)
-		{
-			// Emergency IO ON
-			printf("RB Emergency IO ON. \n");
-		}
-
-		if (gpio_in.Button_Emergency_Press == 1)
-		{
-			// Emergency button Press
-		}
-
-		if (gpio_in.Button_On_Press == 1)
-		{
-			// On button Press
-		}
-
-		if (gpio_in.Button_Off_Press == 1)
-		{
-			// Off button Press
-		}
-
-		if (gpio_in.Key_1_Press == 1)
-		{
-			// key 1 press
-		}
-
-		if (gpio_in.Key_2_Press == 1)
-		{
-			// key 2 press
-		}
-
-		if (gpio_in.Key_3_Press == 1)
-		{
-			// key 3 press
-		}
-
-		if (gpio_in.Key_4_Press == 1)
-		{
-			// key 4 press
-		}
-	}
-}
-
-// 5V 12V 24V 48V
-void GetAuxPower()
-{
-	if (Query_Aux_PowerVoltage(Uart5Fd, Addr.Fan, &auxPower) == PASS)
-	{
-		ShmSysConfigAndInfo->SysInfo.AuxPower48V = auxPower.voltage[0];
-		ShmSysConfigAndInfo->SysInfo.AuxPower24V = auxPower.voltage[1];
-		//ShmSysConfigAndInfo->SysInfo.AuxPower12V = auxPower.voltage[4];
-		//ShmSysConfigAndInfo->SysInfo.AuxPower5V = auxPower.voltage[6];
-		// aux power voltage
-		//printf("aux1 = %x, \n", auxPower.voltage[0]);
-		//printf("aux2 = %x, \n", auxPower.voltage[1]);
-	}
-}
-
-void SetFanModuleSpeed()
-{
-	// 調整風扇速度要漸進式 : 500 rpm/p
-	if (ShmFanModuleData->PresentFan1Speed != ShmFanModuleData->SetFan1Speed ||
-			ShmFanModuleData->PresentFan2Speed != ShmFanModuleData->SetFan2Speed ||
-			ShmFanModuleData->PresentFan3Speed != ShmFanModuleData->SetFan3Speed ||
-			ShmFanModuleData->PresentFan4Speed != ShmFanModuleData->SetFan4Speed)
-	{
-		FanSpeed _fanSpeed;
-
-		unsigned short speed = ShmFanModuleData->PresentFan1Speed + fanSpeedSmoothValue;
-		if (speed >= ShmFanModuleData->SetFan1Speed)
-			speed = ShmFanModuleData->SetFan1Speed;
-		_fanSpeed.speed[0] = speed & 0xff;
-		_fanSpeed.speed[1] = (speed >> 8) & 0xff;
-
-		speed = ShmFanModuleData->PresentFan2Speed + fanSpeedSmoothValue;
-		if (speed >= ShmFanModuleData->SetFan2Speed)
-			speed = ShmFanModuleData->SetFan2Speed;
-		_fanSpeed.speed[2] = speed & 0xff;
-		_fanSpeed.speed[3] = (speed >> 8) & 0xff;
-
-		speed = ShmFanModuleData->PresentFan3Speed + fanSpeedSmoothValue;
-		if (speed >= ShmFanModuleData->SetFan3Speed)
-			speed = ShmFanModuleData->SetFan3Speed;
-		_fanSpeed.speed[4] = speed & 0xff;
-		_fanSpeed.speed[5] = (speed >> 8) & 0xff;
-
-		speed = ShmFanModuleData->PresentFan4Speed + fanSpeedSmoothValue;
-		if (speed >= ShmFanModuleData->SetFan4Speed)
-			speed = ShmFanModuleData->SetFan4Speed;
-		_fanSpeed.speed[6] = speed & 0xff;
-		_fanSpeed.speed[7] = (speed >> 8) & 0xff;
-
-		if (Config_Fan_Speed(Uart5Fd, Addr.Fan, &_fanSpeed) == PASS)
-		{
-			printf("successfully Fan\n");
-		}
-	}
-}
-
-void SetRelayModuleFanSpeed()
-{
-	// 調整風扇速度要漸進式 : 100 rpm/p
-	if (ShmFanModuleData->PresentFan1Speed != ShmFanModuleData->SetFan1Speed)
-	{
-		FanSpeed _fanSpeed;
-		unsigned short speed = 0;
-
-		if (ShmFanModuleData->SetFan1Speed > ShmFanModuleData->PresentFan1Speed)
-		{
-			speed = ShmFanModuleData->PresentFan1Speed + fanSpeedSmoothValue;
-			if (speed >= ShmFanModuleData->SetFan1Speed)
-				speed = ShmFanModuleData->SetFan1Speed;
-		}
-		else
-		{
-			speed = ShmFanModuleData->PresentFan1Speed - fanSpeedSmoothValue;
-			if (speed <= 0)
-				speed = ShmFanModuleData->SetFan1Speed;
-		}
-
-		_fanSpeed.speed[0] = speed & 0xff;
-		_fanSpeed.speed[1] = (speed >> 8) & 0xff;
-		ShmFanModuleData->PresentFan1Speed = speed;
-
-		Config_Fan_Speed(Uart5Fd, Addr.Relay, &_fanSpeed);
-	}
-}
-
-void GetRelayModuleFanSpeed()
-{
-	printf("Get fan board speed \n");
-	if (Query_Fan_Speed(Uart5Fd, Addr.Relay, &fanSpeed) == PASS)
-	{
-		ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0] + (fanSpeed.speed[1] >> 8);
-		printf("SystemFanRotaSpeed_1 = %d \n", fanSpeed.speed[0]);
-	}
-}
-
-//==========================================
-// Common Function
-//==========================================
-void SetK1K2RelayStatus(byte index)
-{
-	if (_chargingData[index]->SystemStatus < S_PREPARING_FOR_EVSE)
-	{
-		if (_chargingData[index]->Evboard_id == 0x01)
-		{
-			if(regRelay.relay_event.bits.Gun1_P == YES)
-				outputRelay.relay_event.bits.Gun1_P = NO;
-			else if (regRelay.relay_event.bits.Gun1_N == YES)
-				outputRelay.relay_event.bits.Gun1_N = NO;
-
-			if (_chargingData[index]->Type == _Type_CCS)
-			{
-				if(regRelay.relay_event.bits.CCS_Precharge == YES)
-					outputRelay.relay_event.bits.CCS_Precharge = NO;
-			}
-		}
-		else if (_chargingData[index]->Evboard_id == 0x02)
-		{
-			if(regRelay.relay_event.bits.Gun2_P == YES)
-				outputRelay.relay_event.bits.Gun2_P = NO;
-			else if (regRelay.relay_event.bits.Gun2_N == YES)
-				outputRelay.relay_event.bits.Gun2_N = NO;
-
-			if (_chargingData[index]->Type == _Type_CCS)
-			{
-				if(regRelay.relay_event.bits.CCS_Precharge == YES)
-					outputRelay.relay_event.bits.CCS_Precharge = NO;
-			}
-		}
-	}
-	else if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE && _chargingData[index]->SystemStatus <= S_CHARGING))
-	{
-		if (_chargingData[index]->Evboard_id == 0x01)
-		{
-			if(regRelay.relay_event.bits.Gun1_N == NO)
-				outputRelay.relay_event.bits.Gun1_N = YES;
-			else if (regRelay.relay_event.bits.Gun1_P == NO)
-				outputRelay.relay_event.bits.Gun1_P = YES;
-		}
-		else if (_chargingData[index]->Evboard_id == 0x02)
-		{
-			if(regRelay.relay_event.bits.Gun2_N == NO)
-				outputRelay.relay_event.bits.Gun2_N = YES;
-			else if (regRelay.relay_event.bits.Gun2_P == NO)
-				outputRelay.relay_event.bits.Gun2_P = YES;
-		}
-	}
-	else if (_chargingData[index]->SystemStatus == S_COMPLETE)
-	{
-		if (_chargingData[index]->PresentChargingCurrent <= SEFETY_SWITCH_RELAY_CUR)
-		{
-			if (_chargingData[index]->Evboard_id == 0x01)
-			{
-				if(regRelay.relay_event.bits.Gun1_P == YES)
-					outputRelay.relay_event.bits.Gun1_P = NO;
-				else if (regRelay.relay_event.bits.Gun1_N == YES)
-					outputRelay.relay_event.bits.Gun1_N = NO;
-			}
-			else if (_chargingData[index]->Evboard_id == 0x02)
-			{
-				if(regRelay.relay_event.bits.Gun2_P == YES)
-					outputRelay.relay_event.bits.Gun2_P = NO;
-				else if (regRelay.relay_event.bits.Gun2_N == YES)
-					outputRelay.relay_event.bits.Gun2_N = NO;
-			}
-		}
-	}
-	else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
-	{
-		if (_chargingData[index]->Evboard_id == 0x01)
-		{
-			if (_chargingData[index]->Type == _Type_CCS)
-			{
-				if (regRelay.relay_event.bits.CCS_Precharge == NO)
-					outputRelay.relay_event.bits.CCS_Precharge = YES;
-				else if (regRelay.relay_event.bits.CCS_Precharge == YES)
-					outputRelay.relay_event.bits.Gun1_P = NO;
-			}
-		}
-		else if (_chargingData[index]->Evboard_id == 0x02)
-		{
-			if (_chargingData[index]->Type == _Type_CCS)
-			{
-				if (regRelay.relay_event.bits.CCS_Precharge == NO)
-					outputRelay.relay_event.bits.CCS_Precharge = YES;
-				else if (regRelay.relay_event.bits.CCS_Precharge == YES)
-					outputRelay.relay_event.bits.Gun2_P = NO;
-			}
-		}
-	}
-	else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST1)
-	{
-		if (_chargingData[index]->Evboard_id == 0x01)
-		{
-			if (_chargingData[index]->Type == _Type_CCS)
-			{
-				if (regRelay.relay_event.bits.Gun1_P == NO)
-					outputRelay.relay_event.bits.Gun1_P = YES;
-				else if(regRelay.relay_event.bits.Gun1_P == YES)
-					outputRelay.relay_event.bits.CCS_Precharge = NO;
-			}
-		}
-		else if (_chargingData[index]->Evboard_id == 0x02)
-		{
-			if (_chargingData[index]->Type == _Type_CCS)
-			{
-				if (regRelay.relay_event.bits.Gun2_P == NO)
-					outputRelay.relay_event.bits.Gun2_P = YES;
-				else if(regRelay.relay_event.bits.Gun2_P == YES)
-					outputRelay.relay_event.bits.CCS_Precharge = NO;
-			}
-		}
-	}
-}
-
-void SetParalleRelayStatus()
-{
-	if (gunCount >= 2)
-	{
-		if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING)
-		{
-			// 初始化~ 不搭橋接
-			if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
-				outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-			else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
-				outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-		}
-		else
-		{
-			// 單槍充電中 - 搭上橋接
-			if((_chargingData[0]->IsReadyToCharging == YES && _chargingData[1]->IsReadyToCharging == NO) ||
-					(_chargingData[0]->IsReadyToCharging == NO && _chargingData[1]->IsReadyToCharging == YES))
-			{
-				if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY)
-				{
-					if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
-						outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-					else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
-						outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-				}
-				else
-				{
-					if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
-						outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
-					else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
-						outputRelay.relay_event.bits.Gun1_Parallel_P = YES;
-				}
-			}
-			else
-			{
-				// 雙槍充電中~ 不搭橋接
-				if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
-					outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-				else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
-					outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-			}
-		}
-	}
-}
-
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-	int result = PASS;
-	int MeterSMId;
-
-	//creat ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-	else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("[shmat ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	 }
-	 //creat ShmStatusCodeData
-	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
-		result = FAIL;
-	}
-	else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
-		result = FAIL;
-	}
-
-	//creat ShmFanModuleData
-	if ((MeterSMId = shmget(ShmFanBdKey, sizeof(struct FanModuleData),  0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmFanModuleData NG\n");
-		#endif
-		result = FAIL;
-	}
-	else if ((ShmFanModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmat ShmFanModuleData NG\n");
-		#endif
-		result = FAIL;
-	 }
-	 memset(ShmFanModuleData,0,sizeof(struct FanModuleData));
-	 //creat ShmRelayModuleData
-	if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData),  0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmRelayModuleData NG\n");
-		#endif
-		result = FAIL;
-	}
-	else if ((ShmRelayModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmat ShmRelayModuleData NG\n");
-		#endif
-		result = FAIL;
-	}
-
-	if(CHAdeMO_QUANTITY > 0)
-	{
-		if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),	IPC_CREAT | 0777)) < 0)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR("[shmget ShmCHAdeMOData NG \n");
-			#endif
-			return FAIL;
-		}
-		else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
-			#ifdef SystemLogMessage
-			DEBUG_ERROR("shmat ShmCHAdeMOData NG \n");
-			#endif
-			return FAIL;
-		}
-	}
-
-	if(CCS_QUANTITY > 0)
-	{
-		if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData),	IPC_CREAT | 0777)) < 0)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR("shmget ShmCcsData NG \n");
-			#endif
-			return FAIL;
-		}
-		else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-		{
-			#ifdef SystemLogMessage
-		   	DEBUG_ERROR("shmat ShmCcsData NG \n");
-			#endif
-			return FAIL;
-		}
-	}
-
-
-	return result;
-}
-
-int InitComPort()
-{
-	int fd;
-	struct termios tios;
-
-	fd = open(relayRs485PortName, O_RDWR);
-	if(fd <= 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Module_InternalComm. InitComPort NG\n");
-		#endif
-		if(ShmStatusCodeData!=NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed=1;
-		}
-		sleep(5);
-		return -1;
-	}
-	ioctl (fd, TCGETS, &tios);
-	tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
-	tios.c_lflag = 0;
-	tios.c_iflag = 0;
-	tios.c_oflag = 0;
-	tios.c_cc[VMIN]=0;
-	tios.c_cc[VTIME]=(byte)0;		// timeout 0.5 second
-	tios.c_lflag=0;
-	tcflush(fd, TCIFLUSH);
-	ioctl (fd, TCSETS, &tios);
-
-	return fd;
-}
-
-//================================================
-// Main process
-//================================================
-bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
-{
-	for (byte index = 0; index < CHAdeMO_QUANTITY; index++) {
-		if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index
-				== target) {
-			chargingData[target] =
-					&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < CCS_QUANTITY; index++) {
-		if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index
-				== target) {
-			chargingData[target] =
-					&ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < GB_QUANTITY; index++) {
-		if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index
-				== target) {
-			chargingData[target] =
-					&ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
-			return true;
-		}
-	}
-
-	return false;
-}
-
-void Initialization()
-{
-	bool isPass = false;
-
-	for (byte index = 0; index < ARRAY_SIZE(outputRelay.relay_event.relay_status); index++)
-	{
-		outputRelay.relay_event.relay_status[index] = 0x00;
-	}
-
-	while(!isPass)
-	{
-		isPass = true;
-		for (byte _index = 0; _index < gunCount; _index++)
-		{
-			if (!FindChargingInfoData(_index, &_chargingData[0]))
-			{
-				DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
-				isPass = false;
-				break;
-			}
-		}
-	}
-}
-
-bool IsNoneMatchRelayStatus()
-{
-	bool result = false;
-
-//	printf("Real Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
-//			regRelay.relay_event.bits.AC_Contactor,
-//			regRelay.relay_event.bits.Gun1_P,
-//			regRelay.relay_event.bits.Gun1_N,
-//			regRelay.relay_event.bits.Gun2_P,
-//			regRelay.relay_event.bits.Gun2_N,
-//			regRelay.relay_event.bits.CCS_Precharge,
-//			regRelay.relay_event.bits.Gun1_Parallel_P,
-//			regRelay.relay_event.bits.Gun1_Parallel_N);
-
-	if ((regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) ||
-		(regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) ||
-		(regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) ||
-		(regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) ||
-		(regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) ||
-		(regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) ||
-		(regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) ||
-		(regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N))
-	{
-		result = true;
-	}
-
-	return result;
-}
-
-void MatchRelayStatus()
-{
-	// 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
-	//regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
-	ShmSysConfigAndInfo->SysInfo.AcContactorStatus  = regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
-	regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
-	regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
-	regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
-	regRelay.relay_event.bits.Gun2_P = outputRelay.relay_event.bits.Gun2_P;
-	regRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_N;
-	regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
-	regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
-}
-
-void CheckRelayStatusByADC()
-{
-	if (ShmRelayModuleData->Gun1FuseOutputVolt > 0 && ShmRelayModuleData->Gun1RelayOutputVolt > 0 &&
-			(ShmRelayModuleData->Gun1FuseOutputVolt == ShmRelayModuleData->Gun1RelayOutputVolt))
-	{
-		// Relay 前後電壓一致
-		_chargingData[0]->RelayK1K2Status = 0x01;
-	}
-	else
-		_chargingData[0]->RelayK1K2Status = 0x00;
-
-	if (ShmRelayModuleData->Gun2FuseOutputVolt > 0 && ShmRelayModuleData->Gun2RelayOutputVolt > 0 &&
-				(ShmRelayModuleData->Gun2FuseOutputVolt == ShmRelayModuleData->Gun2RelayOutputVolt))
-	{
-		// Relay 前後電壓一致
-		_chargingData[1]->RelayK1K2Status = 0x01;
-	}
-	else
-		_chargingData[1]->RelayK1K2Status = 0x00;
-}
-
-void SetGfdConfig(byte index, byte resister)
-{
-	gfd_config.index = index;
-	gfd_config.state = resister;
-
-	//printf("************************GFD Vol = %d, GFD Res = %d \n", gfd_config.reqVol, gfd_config.resister);
-	if (Config_Gfd_Value(Uart5Fd, Addr.Relay, &gfd_config) == PASS)
-	{
-//		printf("Set reqVol = %f, resister = %d \n",
-//				gfd_config.reqVol,
-//				gfd_config.resister);
-	}
-}
-
-void CableCheckDetected(byte index)
-{
-	// Cable Check
-	// 當火線上的電壓 = 車端要求的電壓電流
-	// _chargingData[targetGun]->EvBatterytargetVoltage
-	// 才可以開始偵測 1s
-	// Warning : Rgfd <= 150 歐/V 假設電壓為 500V 則~ Rgfd <= 75000 歐
-	// Pre-Warning : 150 歐/V < Rgfd <= 500 歐/V 假設電壓為 500V 則 75000 歐 < Rgfd <= 250000
-	// SO Normal : Rgfd > 500 歐/V 假設電壓為 500 V 則 Rgfd > 250000 歐
-	if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE && _chargingData[index]->SystemStatus <= S_CHARGING) ||
-			(_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1))
-	{
-		if (_chargingData[index]->SystemStatus == S_PREPARING_FOR_EVSE)
-		{
-			SetGfdConfig(index, GFD_CABLECHK);
-		}
-		else if (_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-				_chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1)
-		{
-			SetGfdConfig(index, GFD_PRECHARGE);
-		}
-		else if (_chargingData[index]->SystemStatus <= S_CHARGING)
-		{
-			SetGfdConfig(index, GFD_CHARGING);
-		}
-	}
-	else if(_chargingData[index]->SystemStatus == S_COMPLETE || _chargingData[index]->SystemStatus == S_PREPARNING
-			|| _chargingData[index]->SystemStatus == S_IDLE)
-	{
-		SetGfdConfig(index, GFD_IDLE);
-	}
-}
-
-int main(void)
-{
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitShareMemory NG\n");
-		#endif
-		if(ShmStatusCodeData!=NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
-		}
-		sleep(5);
-		return 0;
-	}
-	// Open Uart5 for RB
-	Uart5Fd = InitComPort();
-	Initialization();
-	sleep(1);
-
-	if(Uart5Fd < 0)
-	{
-		printf ("open port error. \n");
-		return 0;
-	}
-
-	outputRelay.relay_event.bits.AC_Contactor = 0x00;
-	//outputRelay.relay_event.bits.CCS_Precharge = 0x00;
-	//outputRelay.relay_event.bits.Gun1_Parallel_P = 0x01;
-	//outputRelay.relay_event.bits.Gun1_Parallel_N = 0x01;
-	//outputRelay.relay_event.bits.Gun1_N = 0x01;
-	//outputRelay.relay_event.bits.Gun2_N = 0x01;
-	//outputRelay.relay_event.bits.Gun2_P = 0x01;
-	Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay);
-
-	gettimeofday(&_priority_time, NULL);
-	bool printRelayStatus = false;
-	for(;;)
-	{
-		bool isCharging = false;
-		// 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
-		if (ShmRelayModuleData->SelfTest_Comp == NO)
-		{
-			GetFwAndHwVersion_Relay();
-			sleep(1);
-		}
-
-		if (ShmFanModuleData->SelfTest_Comp == NO)
-		{
-			//GetFwAndHwVersion_Fan();
-			sleep(1);
-		}
-
-		if (ShmRelayModuleData->SelfTest_Comp == YES)
-		{
-			// ==============優先權最高 10 ms ==============
-			// 輸出電壓
-			GetPersentOutputVol();
-
-			// 三相輸入電壓
-			GetPresentInputVol();
-
-			// 讀取當前 relay 狀態
-			GetRelayOutputStatus();
-
-			for (int i = 0; i < gunCount; i++)
-			{
-				// Cable check (Set)
-				CableCheckDetected(i);
-
-				// check k1 k2 relay 狀態
-				CheckK1K2RelayOutput(i);
-
-				// 依據當前各槍的狀態選擇 搭上/放開 Relay
-				SetK1K2RelayStatus(i);
-
-				if (_chargingData[i]->SystemStatus == S_IDLE)
-					gfdChkFailCount[i] = 0;
-
-				if (_chargingData[i]->SystemStatus == S_BOOTING	||
-					(_chargingData[i]->SystemStatus >= S_PREPARNING && _chargingData[i]->SystemStatus <= S_COMPLETE) ||
-					(_chargingData[i]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[i]->SystemStatus <= S_CCS_PRECHARGE_ST1))
-				{
-					_chargingData[i]->IsReadyToCharging = YES;
-					isCharging = true;
-				}
-				else
-					_chargingData[i]->IsReadyToCharging = NO;
-			}
-			// Cable check (Get)
-			GetGfdAdc();
-
-			SetParalleRelayStatus();
-
-			// 搭上 AC Contactor
-			if (isCharging)
-				outputRelay.relay_event.bits.AC_Contactor = YES;
-			else
-				outputRelay.relay_event.bits.AC_Contactor = NO;
-
-			// 搭上/鬆開 Relay
-			// 放開 Relay 之前要先確認輸出的電壓電流是否已經降到某個值
-			if(IsNoneMatchRelayStatus())
-			{
-				printRelayStatus = false;
-				if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay))
-				{}
-			}
-			else
-			{
-				if (!printRelayStatus)
-				{
-					printf("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
-							regRelay.relay_event.bits.AC_Contactor,
-							regRelay.relay_event.bits.Gun1_P,
-							regRelay.relay_event.bits.Gun1_N,
-							regRelay.relay_event.bits.Gun2_P,
-							regRelay.relay_event.bits.Gun2_N,
-							regRelay.relay_event.bits.CCS_Precharge,
-							regRelay.relay_event.bits.Gun1_Parallel_P,
-							regRelay.relay_event.bits.Gun1_Parallel_N);
-				}
-				printRelayStatus = true;
-			}
-		}
-
-		if (ShmFanModuleData->SelfTest_Comp == YES)
-		{
-			//GetFanSpeed();
-
-			if (GetTimeoutValue(_priority_time) / 1000 >= 1000)
-			{
-				gettimeofday(&_priority_time, NULL);
-				if (isCharging)
-				{
-					if (ShmFanModuleData->PresentFan1Speed < MAX_FAN_SPEED ||
-						ShmFanModuleData->PresentFan2Speed < MAX_FAN_SPEED ||
-						ShmFanModuleData->PresentFan3Speed < MAX_FAN_SPEED ||
-						ShmFanModuleData->PresentFan4Speed < MAX_FAN_SPEED)
-					{
-						ShmFanModuleData->SetFan1Speed = MAX_FAN_SPEED;
-						ShmFanModuleData->SetFan2Speed = MAX_FAN_SPEED;
-						ShmFanModuleData->SetFan3Speed = MAX_FAN_SPEED;
-						ShmFanModuleData->SetFan4Speed = MAX_FAN_SPEED;
-					}
-				}
-				else
-				{
-					if (ShmFanModuleData->PresentFan1Speed > MIN_FAN_SPEED ||
-						ShmFanModuleData->PresentFan2Speed < MAX_FAN_SPEED ||
-						ShmFanModuleData->PresentFan3Speed < MAX_FAN_SPEED ||
-						ShmFanModuleData->PresentFan4Speed < MAX_FAN_SPEED)
-					{
-						ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
-						ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
-						ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
-						ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
-					}
-				}
-				//SetFanModuleSpeed();
-			}
-		}
-
-		usleep(10000);
-	}
-
-	return FAIL;
-}

+ 0 - 150
EVSE/Projects/DS60-120/Apps/Module_LcmContro.h

@@ -1,150 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<stdbool.h>
-#include	"../../define.h"
-
-#define Debug
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-
-typedef unsigned char 			byte;
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-struct FanModuleData			*ShmFanModuleData;
-
-#define CMD_TITLE_1				0x5A
-#define CMD_TITLE_2				0xA5
-#define CMD_READ				0x80
-#define CMD_WRITE				0x81
-#define CMD_MULTI_WRITE			0x82
-#define CMD_MULTI_READ			0x83
-
-#define CMD_BACKLIGHT			0x01
-#define CMD_REGISTER			0x03
-
-int _port;
-//char* pPortName = "/dev/ttyO2";
-char* pPortName = "/dev/ttyS3";
-char* moduleName = "DMT80480T070_09WT";
-byte _totalCount = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
-struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-// 當前選擇的槍號
-short _currentPage = _LCM_NONE;
-byte _gunIndex = 0;
-byte _idlePageRotate = 1;
-bool _backend_conn_status = false;
-bool _wifi_conn_status = false;
-bool _net_conn_status = false;
-
-// LCM - HW
-byte _everyPageRollChange = 0;
-short __conn_status = 0x0030;
-short __ethernet_status = 0x0036;
-short __wifi_status = 0x003C;
-
-short __sel_gun_btn = 0x0040;
-short __ret_home_btn = 0x0042;
-
-short __qr_code = 0x0050;
-
-short __plug_in_arrow = 0x0060;
-
-short __conn_line = 0x0066;
-
-short __gun_type_index = 0x0070;
-short __qr_code_pre = 0x0080;
-
-short __side_top = 0x0090;
-short __side_down = 0x0092;
-
-short __conn_line_chag = 0x0096;
-short __batt_map = 0x0100;
-short __soc_value_charging = 0x0102;
-short __remain_time_map = 0x0106;
-short __power_map = 0x0108;
-short __energy_map = 0x010A;
-short __remain_time_tx = 0x0110;
-short __output_eng_tx = 0x0120;
-short __total_out_eng_tx = 0x0130;
-short __conn_line_comp = 0x0140;
-
-// ICON ID
-byte _disappear = 0;
-byte _disconnect = 1;
-byte _connect = 2;
-byte _warning = 3;
-byte _arrow_dark = 4;
-byte _arrow_light = 5;
-byte _ethernet_disconnect = 6;
-byte _ethernet_connect = 7;
-byte _wifi_disconnect = 8;
-byte _wifi_connect = 9;
-byte _logo = 10;
-byte _conn_map1 = 11;
-byte _conn_map2 = 12;
-byte _sel_gun_btn = 13;
-byte _back_home_btn = 14;
-byte _stop_charging_btn = 15;
-byte _stop_charging_btn_scan = 16;
-byte _chademo_dark = 17;
-byte _ccs_dark = 18;
-byte _actype_dark = 19;
-byte _chademo_light = 20;
-byte _ccs_light = 21;
-byte _actype_light = 22;
-byte _side_rfid_1 = 23;
-byte _side_qr_1 = 24;
-byte _side_app_1 = 25;
-byte _side_rfid_2 = 26;
-byte _side_qr_2 = 27;
-byte _side_app_2 = 28;
-byte _charging_map1 = 29;
-byte _charging_map2 = 30;
-byte _battery_cap_20 = 31;
-byte _battery_cap_40 = 32;
-byte _battery_cap_60 = 33;
-byte _battery_cap_80 = 34;
-byte _battery_cap_100 = 35;
-byte _battery_map = 36;
-byte _power_map = 37;
-byte _time_map = 38;
-byte _complete_map = 39;
-byte _battery_soc_20 = 40;
-byte _battery_soc_40 = 41;
-byte _battery_soc_60 = 42;
-byte _battery_soc_80 = 43;
-byte _battery_soc_100 = 44;
-byte _battery_eng_map = 45;
-byte _money_map = 46;
-byte _elapse_time_map = 47;
-
-

+ 0 - 871
EVSE/Projects/DS60-120/Apps/Module_LcmControl.c

@@ -1,871 +0,0 @@
-#include "Module_LcmContro.h"
-
-int StoreLogMsg(const char *fmt, ...);
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-char* getTimeString(void);
-
-//=================================
-// Common routine
-//=================================
-int StoreLogMsg(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	time_t CurrentTime;
-	struct tm *tm;
-	va_list args;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1);
-	system(Buf);
-
-	return rc;
-}
-
-char* getTimeString(void)
-{
-	char *result=malloc(21);
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
-
-	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-
-	return result;
-}
-
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-	int result = PASS;
-	int MeterSMId;
-
-	//creat ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-		#endif
-    	result = FAIL;
-   	 }
-    else
-    {}
-
-   	 //creat ShmStatusCodeData
-   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
-   		result = FAIL;
-	}
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
-    	result = FAIL;
-   	}
-    else
-    {}
-
-    return result;
-}
-
-//==========================================
-// Open and Close RS232 and R/W
-//==========================================
-int CreateCommunicationLcmPort()
-{
-	int fd;
-	struct termios tios;
-
-	fd = open(pPortName, O_RDWR);
-	if (fd <= 0) {
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("open /dev/ttyS3 NG \n");
-		#endif
-		return -1;
-	}
-	ioctl(fd, TCGETS, &tios);
-	tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
-	tios.c_lflag = 0;
-	tios.c_iflag = 0;
-	tios.c_oflag = 0;
-	tios.c_cc[VMIN] = 0;
-	tios.c_cc[VTIME] = (unsigned char) 5;
-	tios.c_lflag = 0;
-	tcflush(fd, TCIFLUSH);
-	ioctl(fd, TCSETS, &tios);
-
-	return fd;
-}
-
-void CloseCommunicationLcmPort()
-{
-	close(_port);
-}
-
-void WriteCmdToLcm(byte *cmd, byte cmdLen)
-{
-	int len = write(_port, cmd, cmdLen);
-	if(len >= sizeof(cmd))
-	{
-		//printf("Write cmd to LCM successfully. \n");
-	}
-}
-
-void ReadMsgFromLcm(byte *msg, byte readLen)
-{
-	read(_port, msg, readLen);
-
-	if(*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2)
-	{
-		if(*(msg + 3) == CMD_WRITE)
-		{
-			switch (*(msg + 4))
-			{
-				case CMD_REGISTER:
-				{
-					// 頁面
-					_currentPage = (unsigned short) (*(msg + 6) << 8) + (unsigned short) *(msg + 7);
-				}
-				break;
-			}
-		}
-		else if (*(msg + 3) == CMD_MULTI_READ)
-		{
-//			switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
-//			{
-//				case BUTTON_GUN_INDEX:
-//				{
-//					// 當前選的槍號
-//					_curGunIndex = (*(msg + 8));
-//				}
-//				break;
-//			}
-		}
-	}
-
-//	for (byte idx = 0; idx < len; idx++)
-//		printf("[system_command]-RX: %X\n", *(msg + idx));
-}
-
-//================================================
-// Function
-//================================================
-void ChangeToOtherPage(short newPage)
-{
-	byte cmd[7];
-	memset(cmd, 0x00, sizeof(cmd));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x02 + sizeof(newPage);
-	cmd[3] = CMD_READ;
-	cmd[4] = CMD_REGISTER;
-	cmd[5] = newPage >> 8;
-	cmd[6] = newPage & 0x00FF;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(100000);
-}
-
-void ChangeBackLight(bool islight)
-{
-	byte value = 0x01;
-
-	if (islight)
-	{
-		value = 0x20;
-	}
-	byte cmd[7];
-	memset(cmd, 0x00, sizeof(cmd));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x03;
-	cmd[3] = CMD_READ;
-	cmd[4] = CMD_BACKLIGHT;
-	cmd[5] = value;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(100000);
-}
-
-void GetCurrentPage()
-{
-	byte cmd[6];
-	memset(cmd, 0x00, sizeof(cmd));
-	byte msg[8];
-	memset(msg, 0x00, sizeof(msg));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x03;				// 底下總長度
-	cmd[3] = CMD_WRITE;
-	cmd[4] = CMD_REGISTER;
-	cmd[5] = 0x02;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(100000);
-	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-void DisplayValueToLcm(short address, byte *data, byte len)
-{
-	byte cmd[256];
-	memset(cmd, 0x00, sizeof(cmd));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x03 + len;
-	cmd[3] = CMD_MULTI_WRITE;
-	cmd[4] = address >> 8;
-	cmd[5] = address & 0x00FF;
-
-	for(byte count = 0; count < len; count++)
-	{
-		cmd[6 + count] = *(data + count);
-	}
-
-	WriteCmdToLcm(cmd, cmd[2] + 3);
-}
-
-void ChangeDisplay2Value(short address, short value)
-{
-	byte data[2];
-	data[0] = value >> 8;
-	data[1] = value & 0x00FF;
-
-	DisplayValueToLcm(address, data, sizeof(data));
-}
-
-void GetBtnStatus(short address, byte len)
-{
-	byte cmd[8];
-	memset(cmd, 0x00, sizeof(cmd));
-	byte msg[8];
-	memset(msg, 0x00, sizeof(msg));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x03 + len;
-	cmd[3] = CMD_MULTI_READ;
-	cmd[4] = address >> 8;
-	cmd[5] = address & 0x00FF;
-	cmd[6] = 0x00 + len;
-
-	WriteCmdToLcm(cmd, cmd[2] + 3);
-	usleep(100000);
-	ReadMsgFromLcm(msg, (len * 2) + sizeof(msg));
-}
-
-//================================================
-// Warning process
-//================================================
-void string2ByteArray(unsigned char *input, byte *output)
-{
-    int loop;
-    int i;
-
-    loop = 0;
-    i = 0;
-
-    while(input[loop] != '\0')
-    {
-        output[i++] = input[loop++];
-    }
-    output[loop] = '\0';
-}
-
-void ChangeWarningFunc()
-{
-	byte cmd[7];
-	byte i = 0;
-	//printf("ChangeWarningFunc \n");
-	// 最多一次五筆
-	//printf("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
-	//printf("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
-	for(i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
-	{
-		memset(cmd, 0x00, sizeof(cmd));
-		if(i >= 5)
-		{
-			break;
-		}
-		//error code
-		string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
-		DisplayValueToLcm(0x0010 + (i * 6), cmd, sizeof(cmd));
-		//警告標示
-		memset(cmd, 0x00, sizeof(cmd));
-
-		cmd[0] = 0x00;
-		cmd[1] = 0x01;
-		DisplayValueToLcm(0x0002 + (i * 2), cmd, 2);
-	}
-
-	memset(cmd, 0x00, sizeof(cmd));
-	for(; i < 5; i++)
-	{
-		DisplayValueToLcm(0x0010 + (i * 6), cmd, sizeof(cmd));
-		DisplayValueToLcm(0x0002 + (i * 2), cmd, 2);
-	}
-}
-
-//================================================
-// QR Code process
-//================================================
-void ChangeQrCode_Idle(char *input)
-{
-	int len = strlen(input);
-	byte cmd[len];
-
-	int loop = 0;
-	int i = 0;
-
-	while(input[loop] != '\0')
-	{
-		cmd[i++] = input[loop++];
-	}
-
-	DisplayValueToLcm(__qr_code, cmd, len);
-}
-
-void ChangeQrCode_Charge(char *input)
-{
-	int len = strlen(input);
-	byte cmd[len];
-
-	int loop = 0;
-	int i = 0;
-
-	while(input[loop] != '\0')
-	{
-		cmd[i++] = input[loop++];
-	}
-
-	DisplayValueToLcm(__qr_code_pre, cmd, len);
-}
-
-//================================================
-// Change current page
-//================================================
-void ChangeCurPage()
-{
-	//printf("cur = %d, new = %d \n", _currentPage, ShmSysConfigAndInfo->SysInfo.PageIndex);
-	if (_currentPage != ShmSysConfigAndInfo->SysInfo.PageIndex)
-	{
-		_currentPage = ShmSysConfigAndInfo->SysInfo.PageIndex;
-		ChangeToOtherPage(_currentPage);
-		_everyPageRollChange = 0;
-	}
-}
-
-//================================================
-// Main process
-//================================================
-byte demoCount = 0;
-void DemoFunction()
-{
-	if (demoCount == 0)
-	{
-		ShmSysConfigAndInfo->SysWarningInfo.WarningCount = 6;
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[0][0], "000001", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[1][0], "000002", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[2][0], "000003", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[3][0], "000004", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[4][0], "000005", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[5][0], "000006", 7);
-	}
-	else
-	{
-		if (demoCount == 20) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_IDLE;
-		} else if (demoCount == 80) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZING;
-		} else if (demoCount == 100) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_COMP;
-		} else if (demoCount == 120) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_FAIL;
-		} else if (demoCount == 140) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_PRE_CHARGE;
-		} else if (demoCount == 180) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_CHARGING;
-		}
-	}
-
-	if (demoCount < 180)
-		demoCount++;
-}
-
-//================================================
-// Main process
-//================================================
-bool FindChargingInfoData(byte target, struct ChargingInfoData **_chargingData)
-{
-	for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
-		{
-			_chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < CCS_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
-		{
-			_chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < GB_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
-		{
-			_chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
-			return true;
-		}
-	}
-
-	return false;
-}
-
-void ChangeBattMapAndValue(short page, int soc)
-{
-//	srand(time(NULL));
-//	int min = 10;
-//	int max = 90;
-//	soc = rand() % (max - min + 1) + min;
-
-	if (page == _LCM_CHARGING)
-	{
-		if (soc < 20)
-			ChangeDisplay2Value(__batt_map, _battery_cap_20);
-		else if (soc >= 20 && soc < 40)
-			ChangeDisplay2Value(__batt_map, _battery_cap_40);
-		else if (soc >= 40 && soc < 60)
-			ChangeDisplay2Value(__batt_map, _battery_cap_60);
-		else if (soc >= 60 && soc < 80)
-			ChangeDisplay2Value(__batt_map, _battery_cap_80);
-		else if (soc >= 80 && soc <= 100)
-			ChangeDisplay2Value(__batt_map, _battery_cap_100);
-	}
-	else if (page == _LCM_COMPLETE)
-	{
-		if (soc < 20)
-			ChangeDisplay2Value(__batt_map, _battery_soc_20);
-		else if (soc >= 20 && soc < 40)
-			ChangeDisplay2Value(__batt_map, _battery_soc_40);
-		else if (soc >= 40 && soc < 60)
-			ChangeDisplay2Value(__batt_map, _battery_soc_60);
-		else if (soc >= 60 && soc < 80)
-			ChangeDisplay2Value(__batt_map, _battery_soc_80);
-		else if (soc >= 80 && soc <= 100)
-			ChangeDisplay2Value(__batt_map, _battery_soc_100);
-	}
-
-	byte cmd[4];
-	byte value[4];
-
-	memset(cmd, 0x00, sizeof(cmd));
-	sprintf((char *)value, "%d%%", soc);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
-}
-
-void ChangeRemainTime(int sec)
-{
-	int h, m, s;
-	byte cmd[10];
-	byte value[10];
-
-	memset(cmd, 0x00, sizeof(cmd));
-
-//	srand(time(NULL));
-//	int min = 0;
-//	int max = 65536;
-//	sec = rand() % (max - min + 1) + min;
-
-	h = (sec / 3600);
-	m = (sec - (3600 * h)) / 60;
-	s = (sec - (3600 * h) - (m * 60));
-	sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingPowerValue(float pow)
-{
-	byte cmd[10];
-	byte value[10];
-
-	memset(cmd, 0x00, sizeof(cmd));
-
-//	float min = 0.0;
-//	float max = 50;
-//	pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
-
-	sprintf((char *) value, "%.1f kW", pow);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
-}
-
-void RefreshPageAnimation(byte value)
-{
-	switch(_currentPage)
-	{
-		case _LCM_IDLE:
-		{
-			if (value == 0)
-			{
-				ChangeToOtherPage(_currentPage);
-			}
-			else if (value == 15)
-			{
-				ChangeToOtherPage(_currentPage + 1);
-			}
-			else if (value == 30)
-			{
-				ChangeToOtherPage(_currentPage + 2);
-			}
-
-			_everyPageRollChange > 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-		}
-			break;
-		case _LCM_WAIT_FOR_PLUG:
-		{
-			if(_everyPageRollChange == 0)
-				ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
-			else if(_everyPageRollChange == 15)
-				ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
-
-			_everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-		}
-			break;
-		case _LCM_PRE_CHARGE:
-		case _LCM_CHARGING:
-		case _LCM_COMPLETE:
-		{
-			if (_currentPage == _LCM_PRE_CHARGE)
-			{
-				if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
-					ChangeDisplay2Value(__conn_line, _conn_map1);
-				else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
-					ChangeDisplay2Value(__conn_line, _conn_map2);
-			}
-			else if (_currentPage == _LCM_CHARGING)
-			{
-				if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
-					ChangeDisplay2Value(__conn_line_chag, _charging_map1);
-				else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
-					ChangeDisplay2Value(__conn_line_chag, _charging_map2);
-			}
-			else if (_currentPage == _LCM_COMPLETE)
-			{
-				if (_everyPageRollChange == 0)
-					ChangeDisplay2Value(__conn_line_comp, _complete_map);
-			}
-
-			if (_totalCount == 2 && _currentPage != _LCM_PRE_CHARGE)
-			{
-				byte index = 0;
-				for (index = 0; index < _totalCount; index++) {
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != index)
-					{
-						break;
-					}
-				}
-
-				if (_chargingInfoData[index]->SystemStatus == S_IDLE)
-				{
-					ChangeDisplay2Value(__sel_gun_btn, _disappear);
-					if(value == 0)
-					{
-						ChangeDisplay2Value(__side_top, _side_rfid_1);
-						ChangeDisplay2Value(__side_down, _side_rfid_2);
-					}
-					else if (value == 15)
-					{
-						ChangeDisplay2Value(__side_top, _side_qr_1);
-						ChangeDisplay2Value(__side_down, _side_qr_2);
-					}
-					else if (value == 30)
-					{
-						ChangeDisplay2Value(__side_top, _side_app_1);
-						ChangeDisplay2Value(__side_down, _side_app_2);
-					}
-				}
-				else
-				{
-					ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-					ChangeDisplay2Value(__side_top, _disappear);
-					ChangeDisplay2Value(__side_down, _disappear);
-					ChangeDisplay2Value(__qr_code_pre, _disappear);
-				}
-			}
-			else
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _disappear);
-				ChangeDisplay2Value(__side_top, _disappear);
-				ChangeDisplay2Value(__side_down, _disappear);
-				ChangeDisplay2Value(__qr_code_pre, _disappear);
-			}
-
-			_everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-		}
-			break;
-	}
-}
-
-void RefreshConnStatus()
-{
-	// Wifi priority is higher than Ethernet
-	if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == 0x01)
-	{
-		if (!_wifi_conn_status)
-		{
-			_wifi_conn_status = true;
-			ChangeDisplay2Value(__wifi_status, _wifi_connect);
-			ChangeDisplay2Value(__ethernet_status, _disappear);
-		}
-	}
-	else
-	{
-		if(_wifi_conn_status)
-		{
-			_wifi_conn_status = false;
-			ChangeDisplay2Value(__wifi_status, _disappear);
-		}
-	}
-
-	if (!_wifi_conn_status)
-	{
-		if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == PASS)
-		{
-			if(!_net_conn_status)
-			{
-				_net_conn_status = true;
-				ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
-			}
-		}
-		else
-		{
-			if(_net_conn_status)
-			{
-				_net_conn_status = false;
-				ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
-			}
-		}
-	}
-
-	// 連線到後台
-
-}
-
-void ProcessPageInfo()
-{
-	switch(_currentPage)
-	{
-		case _LCM_IDLE:
-		{
-			// QR Code 處理
-			ChangeQrCode_Idle("http://google.com.tw");
-		}
-			break;
-		case _LCM_PRE_CHARGE:
-		case _LCM_CHARGING:
-		case _LCM_COMPLETE:
-		{
-			// gun type and charging info
-			for(byte i = 0; i < _totalCount; i++)
-			{
-				switch(_chargingInfoData[i]->Type)
-				{
-					case _Type_Chademo:
-					{
-						if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-						{
-							ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_light);
-						}
-						else
-						{
-							ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_dark);
-						}
-					}
-						break;
-					case _Type_CCS:
-					{
-						if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-						{
-							ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_light);
-						}
-						else
-						{
-							ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_dark);
-						}
-					}
-						break;
-				}
-
-				if (_currentPage == _LCM_CHARGING)
-				{
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-					{
-						ChangeBattMapAndValue(_LCM_CHARGING, _chargingInfoData[i]->EvBatterySoc);
-						if (_chargingInfoData[i]->RemainChargingDuration < 0)
-							ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
-						ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
-					}
-				}
-				else if (_currentPage == _LCM_COMPLETE)
-				{
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-					{
-						ChangeBattMapAndValue(_LCM_COMPLETE, _chargingInfoData[i]->EvBatterySoc);
-						if (_chargingInfoData[i]->RemainChargingDuration < 0)
-							ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
-						ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
-					}
-				}
-			}
-
-			// gun btn and QR code
-			if (_totalCount == 2 && _currentPage != _LCM_PRE_CHARGE)
-			{
-				byte index = 0;
-				for(index = 0; index < _totalCount; index++)
-				{
-					if(ShmSysConfigAndInfo->SysInfo.CurGunSelected != index)
-					{
-						break;
-					}
-				}
-
-				if (_chargingInfoData[index]->SystemStatus == S_IDLE || _chargingInfoData[index]->SystemStatus == S_BOOTING)
-				{
-					// QR Code 處理
-					ChangeQrCode_Charge("http://google.com.tw");
-				}
-				else
-				{
-					ChangeDisplay2Value(__sel_gun_btn, _disappear);
-				}
-			}
-		}
-			break;
-	}
-}
-
-void Initialization()
-{
-	strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
-
-	bool isPass = false;
-	byte count = 5;
-	while(!isPass && count > 0)
-	{
-		isPass = true;
-		for (byte _index = 0; _index < _totalCount; _index++)
-		{
-			if (!FindChargingInfoData(_index, &_chargingInfoData[0]))
-			{
-				DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
-				isPass = false;
-				count--;
-				break;
-			}
-		}
-	}
-
-	if (count == 0)
-		printf("LCM Initialization Gun Fail.............\n");
-}
-
-int main(void)
-{
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitShareMemory NG\n");
-		#endif
-		if (ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory =	1;
-		}
-		sleep(5);
-		return 0;
-	}
-
-	_port = CreateCommunicationLcmPort();
-	byte changeWarningPriority = 0;
-	byte curWarningCount = 255;
-	//ChangeBackLight(true);
-	Initialization();
-
-	while(_port != -1)
-	{
-		//DemoFunction();
-
-		// Warning 處理
-		if(curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
-		{
-			changeWarningPriority = 0;
-			ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
-			curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
-			ChangeWarningFunc();
-		}
-		else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0)
-		{
-			// 當有兩頁 Warning 則每隔三秒改變一次
-			if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
-				ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
-			else
-				ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
-
-			ChangeWarningFunc();
-		}
-
-		// 頁面資訊處理
-		ProcessPageInfo();
-
-		// 網路 - wifi - 連線訊號處理
-		RefreshConnStatus();
-
-		// 換頁處理
-		ChangeCurPage();
-
-		RefreshPageAnimation(_everyPageRollChange);
-
-		changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
-		usleep(100000);
-	}
-
-	CloseCommunicationLcmPort();
-	return FAIL;
-}

+ 0 - 361
EVSE/Projects/DS60-120/Apps/Module_PrimaryComm.c

@@ -1,361 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include	"../../define.h"
-#include	"PrimaryComm.h"
-#include 	<stdbool.h>
-
-#define Debug
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-
-typedef unsigned char 		byte;
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-struct PrimaryMcuData			*ShmPrimaryMcuData;
-
-void trim(char *s);
-int mystrcmp(char *p1,char *p2);
-void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
-void split(char **arr, char *str, const char *del);
-
-int Uart1Fd;
-char *priPortName = "/dev/ttyS1";
-Ver ver;
-Gpio_in gpio_in;
-
-int StoreLogMsg(const char *fmt, ...);
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-int StoreLogMsg(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	time_t CurrentTime;
-	struct tm *tm;
-	va_list args;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1);
-	system(Buf);
-
-	return rc;
-}
-
-int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-	//return milli-second
-	unsigned int StartTime,StopTime;
-
-	StartTime=(unsigned int)ST.time;
-	StopTime=(unsigned int)ET.time;
-	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
-}
-
-//=================================
-// Common routine
-//=================================
-char* getTimeString(void)
-{
-	char *result=malloc(21);
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
-
-	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-
-	return result;
-}
-
-void trim(char *s)
-{
-    int i=0, j, k, l=0;
-
-    while((s[i]==' ')||(s[i]=='\t')||(s[i]=='\n'))
-        i++;
-
-    j = strlen(s)-1;
-    while((s[j]==' ')||(s[j]=='\t')||(s[j]=='\n'))
-        j--;
-
-    if(i==0 && j==strlen(s)-1) { }
-    else if(i==0) s[j+1] = '\0';
-    else {
-        for(k=i; k<=j; k++) s[l++] = s[k];
-        s[l] = '\0';
-    }
-}
-
-int mystrcmp(char *p1,char *p2)
-{
-    while(*p1==*p2)
-    {
-        if(*p1=='\0' || *p2=='\0')
-            break;
-        p1++;
-        p2++;
-    }
-    if(*p1=='\0' && *p2=='\0')
-        return(PASS);
-    else
-        return(FAIL);
-}
-
-void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
-{
-	strncpy(dest, src + start, cnt);
-	dest[cnt] = 0;
-}
-
-void split(char **arr, char *str, const char *del)
-{
-	char *s = strtok(str, del);
-
-	while(s != NULL)
-	{
-		*arr++ = s;
-		s = strtok(NULL, del);
-	}
-}
-
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-	int result = PASS;
-	int MeterSMId;
-
-	//creat ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-		#endif
-    	result = FAIL;
-   	 }
-
-   	 //creat ShmStatusCodeData
-   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
-   		result = FAIL;
-	}
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
-    	result = FAIL;
-   	}
-
-	//creat ShmStatusCodeData
-	if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmPrimaryMcuData NG\n");
-		#endif
-		result = FAIL;
-	}
-	else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef ShmPrimaryMcuData
-		DEBUG_ERROR("shmat ShmPrimaryMcuData NG\n");
-		#endif
-		result = FAIL;
-	}
-
-    return result;
-}
-
-//================================================
-// Function
-//================================================
-void GetFwAndHwVersion()
-{
-	if(Query_FW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS)
-	{
-		printf("s1 = %s \n", ver.Version_FW);
-		strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
-	}
-
-	if (Query_HW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS)
-		printf("s2 = %s \n", ver.Version_HW);
-}
-
-void GetInputGpioStatus()
-{
-	//printf("GetInputGpioStatus \n");
-	if (Query_Gpio_Input(Uart1Fd, Addr.IoExtend, &gpio_in) == PASS)
-	{
-		ShmSysConfigAndInfo->SysInfo.AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
-		ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
-		ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-		ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
-
-		ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
-		ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
-		ShmPrimaryMcuData->InputDet.bits.EmergencyButton = gpio_in.Emergency_Btn;
-
-		//printf("left = %d \n", ShmPrimaryMcuData->InputDet.bits.Button1);
-		//printf("right = %d \n", ShmPrimaryMcuData->InputDet.bits.Button2);
-		//printf("ShmSysConfigAndInfo->SysInfo.AcContactorStatus = %d \n", ShmSysConfigAndInfo->SysInfo.AcContactorStatus);
-	}
-}
-
-void SetOutputGpio()
-{
-	Gpio_out gpio;
-	gpio.Button_LED[0] = 0x01;
-	gpio.Button_LED[1] = 0x01;
-
-	gpio.System_LED[0] = 0x00;
-	gpio.System_LED[1] = 0x00;
-	gpio.System_LED[2] = 0x00;
-	gpio.System_LED[3] = 0x00;
-
-	gpio.AC_Connector = 0x00;
-	gpio.AC_Breaker = 0x00;
-
-	if (Config_Gpio_Output(Uart1Fd, Addr.IoExtend, &gpio) == PASS)
-		printf("SetOutputGpio sucessfully. \n");
-	else
-		printf("SetOutputGpio fail. \n");
-}
-
-//================================================
-// Main process
-//================================================
-int InitComPort()
-{
-	int fd;
-	struct termios tios;
-
-	fd = open(priPortName, O_RDWR);
-	if(fd<=0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("open 407 Communication port NG \n");
-		#endif
-		return -1;
-	}
-	ioctl (fd, TCGETS, &tios);
-	tios.c_cflag = B115200| CS8 | CLOCAL | CREAD;
-	tios.c_lflag = 0;
-	tios.c_iflag = 0;
-	tios.c_oflag = 0;
-	tios.c_cc[VMIN]=0;
-	tios.c_cc[VTIME]=(unsigned char)1;
-	tios.c_lflag=0;
-	tcflush(fd, TCIFLUSH);
-	ioctl (fd, TCSETS, &tios);
-
-	return fd;
-}
-
-int main(void)
-{
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitShareMemory NG\n");
-		#endif
-		if(ShmStatusCodeData!=NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
-		}
-		sleep(5);
-		return 0;
-	}
-	Uart1Fd = InitComPort();
-	printf("407 Port id = %d \n", Uart1Fd);
-
-	if(Uart1Fd < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitComPort (Uart1 : AM3352 - STM32) NG");
-		#endif
-
-		if (ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-		}
-		sleep(5);
-		return 0;
-	}
-
-	SetOutputGpio();
-	for(;;)
-	{
-		// 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
-		// 模組更新 FW 後,需重新做
-		if(ShmPrimaryMcuData->SelfTest_Comp != PASS)
-		{
-			printf("(407) Get Fw and Hw Ver. \n");
-			GetFwAndHwVersion();
-			usleep(1000000);
-			ShmPrimaryMcuData->SelfTest_Comp = PASS;
-		}
-		else
-		{
-			GetInputGpioStatus();
-		}
-
-		usleep(100000);
-	}
-
-	return FAIL;
-}
-
-
-
-

+ 0 - 332
EVSE/Projects/DS60-120/Apps/PrimaryComm.c

@@ -1,332 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	"PrimaryComm.h"
-
-#define PASS				1
-#define FAIL				-1
-
-struct Address Addr={0x01,0x02,0x03,0x04,0xFF};
-struct Command Cmd={0x01,0x02,0x0a,0x86,0xe0,0xe1,0xe2,0xe3};
-
-int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx)
-{
-	int len;
-	//sleep(2); //required to make flush work, for some reason
-	tcflush(fd,TCIOFLUSH);
-	if(write(fd, cmd, cmd_len) >= cmd_len)
-	{
-		usleep(50000);
-		len = read(fd, rx, 512);
-	}
-	else
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Serial command %s response fail.\n", cmd);
-		#endif
-	}
-
-	return len;
-}
-
-unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_FW_Ver, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 0)
-	{
-		for(int idx = 0; idx < (rx[4] | rx[5]<<8); idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			memcpy(Ret_Buf->Version_FW, (char *)rx+6, (rx[4] | rx[5]<<8));
-			*(Ret_Buf->Version_FW + 8) = 0x00;
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_HW_Ver, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			memcpy(Ret_Buf->Version_HW, (char *)rx+6, (rx[4] | rx[5]<<8));
-			//*(Ret_Buf->Version_HW + 8) = 0x00;
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr, Gpio_in *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Gpio_In, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 0)
-	{
-		for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			Ret_Buf->AC_Connector 		= (rx[6] >> 0) & 0x01;
-			Ret_Buf->AC_MainBreaker 	= (rx[6] >> 1) & 0x01;
-			Ret_Buf->SPD 				= (rx[6] >> 2) & 0x01;
-			Ret_Buf->Door_Open 			= (rx[6] >> 3) & 0x01;
-			Ret_Buf->GFD[0] 			= (rx[6] >> 4) & 0x01;
-			Ret_Buf->GFD[1] 			= (rx[6] >> 5) & 0x01;
-			Ret_Buf->AC_Drop 			= (rx[6] >> 6) & 0x01;
-			Ret_Buf->Emergency_IO 		= (rx[6] >> 7) & 0x01;
-
-			Ret_Buf->Emergency_Btn		= (rx[7] >> 0) & 0x01;
-			Ret_Buf->Button[0] 			= (rx[7] >> 1) & 0x01;
-			Ret_Buf->Button[1] 			= (rx[7] >> 2) & 0x01;
-			Ret_Buf->Key[0]				= (rx[7] >> 3) & 0x01;
-			Ret_Buf->Key[1]				= (rx[7] >> 4) & 0x01;
-			Ret_Buf->Key[2]				= (rx[7] >> 5) & 0x01;
-			Ret_Buf->Key[3]				= (rx[7] >> 6) & 0x01;
-
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[9] = {0xaa, 0x00, targetAddr, Cmd.config_Gpio_Output, 0x01, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for (int idx = 0; idx < 2; idx++)
-		tx[6] |= (Set_Buf->Button_LED[idx] ? 0x01:0x00) << (0+idx);
-
-	for (int idx = 0; idx < 4; idx++)
-			tx[6] |= (Set_Buf->System_LED[idx] ? 0x01:0x00) << (2+idx);
-
-	tx[6] |= (Set_Buf->AC_Connector ? 0x01:0x00) << 6;
-	tx[6] |= (Set_Buf->AC_Breaker ? 0x01:0x00) << 7;
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6+idx];
-	tx[7] = chksum;
-
-	if (tranceive(fd, tx, sizeof(tx), rx) > 0)
-	{
-		chksum = 0x00;
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == tx[6]))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[11] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, (crc32>>0)&0xff, (crc32>>8)&0xff, (crc32>>16)&0xff, (crc32>>24)&0xff, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6+idx];
-	tx[10] = chksum;
-
-
-	if(tranceive(fd, tx, sizeof(tx), rx) > 0)
-	{
-		for(int rr = 0; rr < 8; rr++)
-			printf("rx = %x \n", rx[rr]);
-
-		chksum = 0x00;
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Abord(unsigned char fd, unsigned char targetAddr)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[11 + length];
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	tx[0] = 0xaa;
-	tx[1] = 0x00;
-	tx[2] = targetAddr;
-	tx[3] = Cmd.update_Transfer;
-	tx[4] = (4 + length) & 0xff;
-	tx[5] = ((4 + length)>>8) & 0xff;
-	tx[6] = (startAddr>>0) & 0xff;
-	tx[7] = (startAddr>>8) & 0xff;
-	tx[8] = (startAddr>>16) & 0xff;
-	tx[9] = (startAddr>>24) & 0xff;
-	memcpy(tx+10, data, length);
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6+idx];
-	tx[sizeof(tx)-1] = chksum;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Finish(unsigned char fd, unsigned char targetAddr)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Finish, 0x04, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-

+ 0 - 80
EVSE/Projects/DS60-120/Apps/PrimaryComm.h

@@ -1,80 +0,0 @@
-#ifndef PRIMARYCOMM_H_
-#define PRIMARYCOMM_H_
-
-extern struct Address
-{
-	unsigned char Aux;
-	unsigned char Fan;
-	unsigned char Relay;
-	unsigned char IoExtend;
-	unsigned char Broadcast;
-}Addr;
-
-extern struct Command
-{
-	unsigned char query_FW_Ver; 		//0x01
-	unsigned char query_HW_Ver;		//0x02
-	unsigned char query_Gpio_In;		//0x0a
-
-	unsigned char config_Gpio_Output;	//0x86
-
-	unsigned char update_Start;		//0xe0
-	unsigned char update_Abort;		//0xe1
-	unsigned char update_Transfer;		//0xe2
-	unsigned char update_Finish;		//0xe3
-
-}Cmd;
-
-typedef struct Verion
-{
-	char Version_FW[16];
-	char Version_HW[16];
-}Ver;
-
-typedef struct GPIO_IN
-{
-	unsigned char AC_Connector;
-	unsigned char AC_MainBreaker;
-	unsigned char SPD;
-	unsigned char Door_Open;
-	unsigned char GFD[2];
-	unsigned char AC_Drop;
-	unsigned char Emergency_IO;
-
-	unsigned char Emergency_Btn;
-	unsigned char Button[2];
-	unsigned char Key[4];
-}Gpio_in;
-
-typedef struct GPIO_OUT
-{
-	unsigned char Button_LED[2];
-	unsigned char System_LED[4];
-	unsigned char AC_Connector;
-	unsigned char AC_Breaker;
-}Gpio_out;
-
-typedef struct RTC
-{
-	unsigned char AC_Connector;
-	unsigned char Button_LED[2];
-	unsigned char System_LED[4];
-	unsigned char AC_Breaker;
-}Rtc;
-
-extern unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
-extern unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
-extern unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr, Gpio_in *Ret_Buf);
-
-extern unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf);
-// 13 bytes
-// year : 4, month : 2, day : 2, hour : 2, min : 2, sec : 2
-//extern unsigned char Config_RTC();
-
-extern unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32);
-extern unsigned char Update_Abord(unsigned char fd, unsigned char targetAddr);
-extern unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length);
-extern unsigned char Update_Finish(unsigned char fd, unsigned char targetAddr);
-
-
-#endif /* PRIMARYCOMM_H_ */

+ 0 - 753
EVSE/Projects/DS60-120/Apps/internalComm.c

@@ -1,753 +0,0 @@
-/*
- * internalComm.c
- *
- *  Created on: 2019年5月7日
- *      Author: foluswen
- */
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	"internalComm.h"
-
-#define PASS				1
-#define FAIL				-1
-
-struct Address Addr={0x01,0x02,0x03,0xFF};
-struct Command Cmd={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x81,0x85,0x86,0x87,0xe0,0xe1,0xe2,0xe3};
-
-int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx)
-{
-	int len;
-	//sleep(2); //required to make flush work, for some reason
-	tcflush(fd,TCIOFLUSH);
-	if(write(fd, cmd, cmd_len) >= cmd_len)
-	{
-		usleep(10000);
-		len = read(fd, rx, 512);
-	}
-	else
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Serial command %s response fail.\n", cmd);
-		#endif
-	}
-
-	return len;
-}
-
-unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_FW_Ver, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			memcpy(Ret_Buf->Version_FW, (char *)rx+6, (rx[4] | rx[5]<<8));
-			*(Ret_Buf->Version_FW + 8) = 0x00;
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_HW_Ver, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			memcpy(Ret_Buf->Version_HW, (char *)rx+6, (rx[4] | rx[5]<<8));
-			*(Ret_Buf->Version_HW + 8) = 0x00;
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Present_InputVoltage(unsigned char fd, unsigned char targetAddr, PresentInputVoltage *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Present_InputVoltage, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			Ret_Buf->inputType = rx[6];
-			Ret_Buf->L1N_L12 =(rx[7] | (rx[8]<<8))/10.0;
-			Ret_Buf->L2N_L23 =(rx[9] | (rx[10]<<8))/10.0;
-			Ret_Buf->L3N_L31 =(rx[11] | (rx[12]<<8))/10.0;
-
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Present_OutputVoltage(unsigned char fd, unsigned char targetAddr, PresentOutputVoltage *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Present_OutputVoltage, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-
-			Ret_Buf->behindFuse_Voltage_C1 =(rx[6] | (rx[7]<<8));
-			Ret_Buf->behindRelay_Voltage_C1 =(rx[8] | (rx[9]<<8));
-			if((rx[4] | rx[5]<<8) > 4)
-			{
-				Ret_Buf->behindFuse_Voltage_C2 =(rx[10] | (rx[11]<<8));
-				Ret_Buf->behindRelay_Voltage_C2 =(rx[12] | (rx[13]<<8));
-			}
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Fan_Speed, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-		for (int i = 0; i < 7; i++)
-			printf("tx = %x \n", tx[i]);
-		for (int i = 0; i < len; i++)
-			printf("rx = %x \n", rx[i]);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			for(int idx=0;idx < 4;idx++)
-				Ret_Buf->speed[idx] = (rx[6+(2*idx)] | (rx[6+(2*idx)+1]<<8));
-
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Temperature(unsigned char fd, unsigned char targetAddr, Temperature *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Temperature, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			for(int idx=0;idx < 4;idx++)
-				Ret_Buf->temperature[idx] = rx[6+idx] - 60;
-
-			result = PASS;
-		}
-	}
-
-
-	return result;
-}
-
-unsigned char Query_Aux_PowerVoltage(unsigned char fd, unsigned char targetAddr, AuxPower *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Aux_PowerVoltage, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-				Ret_Buf->voltage[idx] = rx[6+idx];
-
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Relay_Output(unsigned char fd, unsigned char targetAddr, Relay *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Relay_Output, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-//	for (int i = 0; i < 7; i++)
-//		printf("tx = %x \n", tx[i]);
-//	for (int i = 0; i < len; i++)
-//		printf("rx = %x \n", rx[i]);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			Ret_Buf->relay_event.bits.AC_Contactor = (rx[6] >> 0) & 0x01;
-			Ret_Buf->relay_event.bits.CCS_Precharge = (rx[6] >> 1) & 0x01;
-
-			Ret_Buf->relay_event.bits.Gun1_N = (rx[7] >> 0) & 0x01;
-			Ret_Buf->relay_event.bits.Gun1_P = (rx[7] >> 1) & 0x01;
-			Ret_Buf->relay_event.bits.Gun1_Parallel_N = (rx[7] >> 2) & 0x01;
-			Ret_Buf->relay_event.bits.Gun1_Parallel_P = (rx[7] >> 3) & 0x01;
-
-			Ret_Buf->relay_event.bits.Gun2_N = (rx[8] >> 0) & 0x01;
-			Ret_Buf->relay_event.bits.Gun2_P = (rx[8] >> 1) & 0x01;
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Gfd_Adc(unsigned char fd, unsigned char targetAddr, Gfd *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Gfd_Adc, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-//	for(int i = 0; i < 7; i++)
-//		printf ("tx = %d \n", tx[i]);
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-		{
-			printf("Query_Gfd_Adc fail \n");
-			return result;
-		}
-
-//		for(int i = 0; i < len; i++)
-//			printf ("rx = %d \n", rx[i]);
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			Ret_Buf->Resister_conn1 = (rx[6] | (rx[7] << 8));
-			Ret_Buf->voltage_conn1 = (rx[8] | (rx[9] << 8));
-			Ret_Buf->result_conn1 = rx[10];
-			Ret_Buf->rb_step_1 = rx[11];
-
-			Ret_Buf->Resister_conn2 = (rx[12] | (rx[13] << 8));
-			Ret_Buf->voltage_conn2 = (rx[14] | (rx[15] << 8));
-			Ret_Buf->result_conn2 = rx[16];
-			Ret_Buf->rb_step_2 = rx[17];
-
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr, Gpio_in *Ret_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Gpio_In, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			Ret_Buf->AC_Connector 		= (rx[6] >> 0) & 0x01;
-			Ret_Buf->AC_MainBreaker 	= (rx[6] >> 1) & 0x01;
-			Ret_Buf->SPD 				= (rx[6] >> 2) & 0x01;
-			Ret_Buf->Door_Open 			= (rx[6] >> 3) & 0x01;
-			Ret_Buf->GFD[0] 			= (rx[6] >> 4) & 0x01;
-			Ret_Buf->GFD[1] 			= (rx[6] >> 5) & 0x01;
-			Ret_Buf->AC_Drop 			= (rx[6] >> 6) & 0x01;
-
-			Ret_Buf->Emergency_IO		= (rx[7] >> 0) & 0x01;
-
-			Ret_Buf->Button_Emergency_Press	= (rx[8] >> 0) & 0x01;
-			Ret_Buf->Button_On_Press 	= (rx[8] >> 1) & 0x01;
-			Ret_Buf->Button_Off_Press	= (rx[8] >> 2) & 0x01;
-			Ret_Buf->Key_1_Press 		= (rx[8] >> 3) & 0x01;
-			Ret_Buf->Key_2_Press 		= (rx[8] >> 4) & 0x01;
-			Ret_Buf->Key_3_Press 		= (rx[8] >> 5) & 0x01;
-			Ret_Buf->Key_4_Press 		= (rx[8] >> 6) & 0x01;
-
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Set_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[15] = {0xaa, 0x00, targetAddr, Cmd.config_Fan_Speed, 0x08, 0x00, Set_Buf->speed[0]&0xff, (Set_Buf->speed[0]>>8)&0xff, Set_Buf->speed[1]&0xff, (Set_Buf->speed[1]>>8)&0xff, Set_Buf->speed[2]&0xff, (Set_Buf->speed[2]>>8)&0xff, Set_Buf->speed[3]&0xff, (Set_Buf->speed[3]>>8)&0xff, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for(int idx = 0;idx<(tx[4] | tx[5]<<8);idx++)
-		chksum ^= tx[6+idx];
-	tx[14] = chksum;
-
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		chksum = 0x00;
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Config_Relay_Output(unsigned char fd, unsigned char targetAddr, Relay *Set_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[10] = {0xaa, 0x00, targetAddr, Cmd.config_Relay_Output, 0x03, 0x00, Set_Buf->relay_event.relay_status[0], Set_Buf->relay_event.relay_status[1], Set_Buf->relay_event.relay_status[2]};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for(int idx = 6;idx<8;idx++)
-		chksum ^= tx[idx];
-	tx[9] = chksum;
-
-//	for (int i = 0; i < 10; i++)
-//		printf("set relay cmd : tx = %x \n", tx[i]);
-
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-//		for (int i = 0; i < len; i++)
-//			printf("set relay cmd : rx = %x \n", rx[i]);
-
-		chksum = 0x00;
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x01))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[9] = {0xaa, 0x00, targetAddr, Cmd.config_Gpio_Output, 0x01, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	tx[6] |= (Set_Buf->AC_Connector?0x01:0x00);
-
-	for(int idx = 0;idx<2;idx++)
-		tx[6] |= (Set_Buf->Button_LED[idx]?0x01:0x00)<<(1+idx);
-
-	for(int idx = 0;idx<4;idx++)
-			tx[6] |= (Set_Buf->System_LED[idx]?0x01:0x00)<<(3+idx);
-
-	for(int idx = 0;idx<(tx[4] | tx[5]<<8);idx++)
-		chksum ^= tx[6+idx];
-	tx[14] = chksum;
-
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		chksum = 0x00;
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == tx[6]))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Config_Gfd_Value(unsigned char fd, unsigned char targetAddr, Gfd_config *Set_Buf)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[9] = {0xaa, 0x00, targetAddr, Cmd.config_Gfd_Value, 0x02, 0x00, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	tx[6] = Set_Buf->index;
-	tx[7] = Set_Buf->state;
-
-	for(int idx = 0; idx<(tx[4] | tx[5]<<8);idx++)
-		chksum ^= tx[6+idx];
-	tx[8] = chksum;
-
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		chksum = 0x00;
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == tx[6]))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[11] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, (crc32>>0)&0xff, (crc32>>8)&0xff, (crc32>>16)&0xff, (crc32>>24)&0xff, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for(int idx = 0;idx<(tx[4] | tx[5]<<8);idx++)
-		chksum ^= tx[6+idx];
-	tx[10] = chksum;
-
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		chksum = 0x00;
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Abord(unsigned char fd, unsigned char targetAddr)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[11 + length];
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	tx[0] = 0xaa;
-	tx[1] = 0x00;
-	tx[2] = targetAddr;
-	tx[3] = Cmd.update_Transfer;
-	tx[4] = (4 + length) & 0xff;
-	tx[5] = ((4 + length)>>8) & 0xff;
-	tx[6] = (startAddr>>0) & 0xff;
-	tx[7] = (startAddr>>8) & 0xff;
-	tx[8] = (startAddr>>16) & 0xff;
-	tx[9] = (startAddr>>24) & 0xff;
-	memcpy(tx+10, data, length);
-
-	for(int idx = 0;idx<(tx[4] | tx[5]<<8);idx++)
-		chksum ^= tx[6+idx];
-	tx[sizeof(tx)-1] = chksum;
-
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}
-
-unsigned char Update_Finish(unsigned char fd, unsigned char targetAddr)
-{
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Finish, 0x04, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 6)
-	{
-		if (len < 6+(rx[4] | rx[5]<<8))
-			return result;
-
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
-}

+ 0 - 185
EVSE/Projects/DS60-120/Apps/internalComm.h

@@ -1,185 +0,0 @@
-/*
- * internalComm.h
- *
- *  Created on: 2019¦~5¤ë7¤é
- *      Author: foluswen
- */
-
-#ifndef INTERNALCOMM_H_
-#define INTERNALCOMM_H_
-
-extern struct Address
-{
-	unsigned char Aux;
-	unsigned char Fan;
-	unsigned char Relay;
-	unsigned char Broadcast;
-}Addr;
-
-extern struct Command
-{
-	unsigned char query_FW_Ver; 				//0x01
-	unsigned char query_HW_Ver; 				//0x02
-	unsigned char query_Present_InputVoltage;	//0x03
-	unsigned char query_Present_OutputVoltage;	//0x04
-	unsigned char query_Fan_Speed;				//0x05
-	unsigned char query_Temperature;			//0x06
-	unsigned char query_Aux_PowerVoltage;		//0x07
-	unsigned char query_Relay_Output;			//0x08
-	unsigned char query_Gfd_Adc;				//0x09
-	unsigned char query_Gpio_In;				//0x0a
-
-	unsigned char config_Fan_Speed;			//0x81
-	unsigned char config_Relay_Output;			//0x85
-	unsigned char config_Gpio_Output;			//0x86
-	unsigned char config_Gfd_Value;			//0x87
-
-	unsigned char update_Start;				//0xe0
-	unsigned char update_Abort;				//0xe1
-	unsigned char update_Transfer;				//0xe2
-	unsigned char update_Finish;				//0xe3
-
-}Cmd;
-
-typedef struct Verion
-{
-	char Version_FW[9];
-	char Version_HW[9];
-}Ver;
-
-typedef struct PRESENTINPUTVOLTAGE
-{
-	unsigned char inputType;	// 0x00: Line to Line       0x01: Line to Neutral
-	double L1N_L12;
-	double L2N_L23;
-	double L3N_L31;
-}PresentInputVoltage;
-
-typedef struct PRESENTOUTPUTVOLTAGE
-{
-	double behindFuse_Voltage_C1;
-	double behindRelay_Voltage_C1;
-	double behindFuse_Voltage_C2;
-	double behindRelay_Voltage_C2;
-}PresentOutputVoltage;
-
-typedef struct FANSPEED
-{
-	unsigned short int speed[8];
-}FanSpeed;
-
-typedef struct TEMPERATURE
-{
-	unsigned char temperature[8];
-}Temperature;
-
-typedef struct AUXPOWER
-{
-	unsigned char voltage[8];
-}AuxPower;
-
-typedef struct RELAY
-{
-	union
-	{
-		unsigned char relay_status[8];
-		struct
-		{
-			unsigned char AC_Contactor :1;		//bit 0
-			unsigned char CCS_Precharge :1;	//bit 1
-			unsigned char :1;  				//bit 2 reserved
-			unsigned char :1;					//bit 3 reserved
-			unsigned char :1;					//bit 4 reserved
-			unsigned char :1;					//bit 5 reserved
-			unsigned char :1;					//bit 6 reserved
-			unsigned char :1;					//bit 7 reserved
-
-			unsigned char Gun1_N :1;			//bit 0
-			unsigned char Gun1_P :1;			//bit 1
-			unsigned char Gun1_Parallel_N :1;  //bit 2
-			unsigned char Gun1_Parallel_P :1;	//bit 3
-			unsigned char :1;					//bit 4 reserved
-			unsigned char :1;					//bit 5 reserved
-			unsigned char :1;					//bit 6 reserved
-			unsigned char :1;					//bit 7 reserved
-
-			unsigned char Gun2_N :1;			//bit 0
-			unsigned char Gun2_P :1;			//bit 1
-			unsigned char :1; 					//bit 2 reserved
-			unsigned char :1;					//bit 3 reserved
-			unsigned char :1;					//bit 4 reserved
-			unsigned char :1;					//bit 5 reserved
-			unsigned char :1;					//bit 6 reserved
-			unsigned char :1;					//bit 7 reserved
-		}bits;
-	}relay_event;
-}Relay;
-
-typedef struct GFD
-{
-	unsigned short Resister_conn1;
-	unsigned short voltage_conn1;
-	unsigned char result_conn1;
-	unsigned char rb_step_1;
-
-	unsigned short Resister_conn2;
-	unsigned short voltage_conn2;
-	unsigned char result_conn2;
-	unsigned char rb_step_2;
-}Gfd;
-
-typedef struct Gfd_CONFIG
-{
-	unsigned char index;
-	unsigned char state;
-}Gfd_config;
-
-typedef struct GPIO_IN
-{
-	unsigned char AC_Connector;			// bit 0
-	unsigned char AC_MainBreaker;			// bit 1
-	unsigned char SPD;						// bit 2
-	unsigned char Door_Open;				// bit 3
-	unsigned char GFD[2];					// bit 4,5
-	unsigned char AC_Drop;					// bit 6
-
-	unsigned char Emergency_IO;			// bit 0
-
-	unsigned char Button_Emergency_Press;	// bit 0
-	unsigned char Button_On_Press;			// bit 1
-	unsigned char Button_Off_Press;		// bit 2
-	unsigned char Key_1_Press;				// bit 3
-	unsigned char Key_2_Press;				// bit 4
-	unsigned char Key_3_Press;				// bit 5
-	unsigned char Key_4_Press;				// bit 6
-}Gpio_in;
-
-typedef struct GPIO_OUT
-{
-	unsigned char AC_Connector;
-	unsigned char Button_LED[2];
-	unsigned char System_LED[4];
-}Gpio_out;
-
-extern unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
-extern unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
-extern unsigned char Query_Present_InputVoltage(unsigned char fd, unsigned char targetAddr, PresentInputVoltage *Ret_Buf);
-extern unsigned char Query_Present_OutputVoltage(unsigned char fd, unsigned char targetAddr, PresentOutputVoltage *Ret_Buf);
-extern unsigned char Query_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Ret_Buf);
-extern unsigned char Query_Temperature(unsigned char fd, unsigned char targetAddr, Temperature *Ret_Buf);
-extern unsigned char Query_Aux_PowerVoltage(unsigned char fd, unsigned char targetAddr, AuxPower *Ret_Buf);
-extern unsigned char Query_Relay_Output(unsigned char fd, unsigned char targetAddr, Relay *Ret_Buf);
-extern unsigned char Query_Gfd_Adc(unsigned char fd, unsigned char targetAddr, Gfd *Ret_Buf);
-extern unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr, Gpio_in *Ret_Buf);
-
-extern unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Set_Buf);
-extern unsigned char Config_Relay_Output(unsigned char fd, unsigned char targetAddr, Relay *Set_Buf);
-extern unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf);
-extern unsigned char Config_Gfd_Value(unsigned char fd, unsigned char targetAddr, Gfd_config *Set_Buf);
-
-extern unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32);
-extern unsigned char Update_Abord(unsigned char fd, unsigned char targetAddr);
-extern unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length);
-extern unsigned char Update_Finish(unsigned char fd, unsigned char targetAddr);
-
-#endif /* INTERNALCOMM_H_ */

+ 0 - 2832
EVSE/Projects/DS60-120/Apps/main.c

@@ -1,2832 +0,0 @@
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	"../../define.h"
-#include 	"Config.h"
-#include 	<stdbool.h>
-#include 	<dirent.h>
-#include	"timeout.h"
-
-#define 	Debug
-#define 	ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define 	PASS				1
-#define 	FAIL				-1
-#define 	BUFFER_SIZE			128
-#define 	YES					1
-#define 	NO					0
-#define 	NORMAL				0
-#define		ABNORMAL			1
-#define 	EQUAL				0
-#define 	BTN_RELEASE			0
-#define 	BTN_PRESS			1
-#define 	MAX_BUF 			64
-#define 	SYSFS_GPIO_DIR 		"/sys/class/gpio"
-
-unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
-int whileLoopTime = 10000; // 10 ms
-
-bool IsAuthorizingMode();
-void ClearAuthorizedFlag();
-bool isDetectPlugin();
-void ClearDetectPluginFlag();
-int mystrcmp(unsigned char *p1, unsigned char *p2);
-
-unsigned char DetectBitValue(unsigned char _byte, unsigned char _bit);
-void SetBitValue(unsigned char *_byte, unsigned char _bit, unsigned char value);
-void ChargingTerminalProcess(byte gunIndex);
-void ChkPrimaryStatus();
-void StartSystemTimeoutDet(unsigned char flag);
-void StopSystemTimeoutDet();
-void StartGunInfoTimeoutDet(unsigned char gunIndex, unsigned char flag);
-void StopGunInfoTimeoutDet(unsigned char gunIndex);
-int StoreLogMsg_1(const char *fmt, ...);
-unsigned long GetTimeoutValue(struct timeval _sour_time);
-
-#define DEBUG_INFO_1(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN_1(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR_1(format, args...) StoreLogMsg_1("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-struct PsuData 					*ShmPsuData;
-struct CHAdeMOData				*ShmCHAdeMOData;
-struct CcsData					*ShmCcsData;
-struct PrimaryMcuData			*ShmPrimaryMcuData;
-struct FanModuleData			*ShmFanModuleData;
-struct RelayModuleData			*ShmRelayModuleData;
-struct OCPP16Data				*ShmOCPP16Data;
-
-struct ChargingInfoData			*chargingInfo[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-struct timeb 					startChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-struct timeb 					endChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-byte _gunCount = 0;
-// for initial index to check EV board type is correct
-byte _gunIndex = 0;
-byte _chademoIndex = 0;
-byte _ccsIndex = 0;
-byte _gb_Index = 0;
-byte bd0_1_status = 0;
-byte bd0_2_status = 0;
-byte bd1_1_status = 0;
-byte bd1_2_status = 0;
-
-bool isCardScan = false;
-
-int rfidFd = -1;
-char* rfidPortName = "/dev/ttyS2";
-byte autoReturnTimeoutFlag = 0x00;
-
-//================================================
-// initial can-bus
-//================================================
-int InitCanBus()
-{
-	int 					s0,nbytes;
-	struct timeval			tv;
-	struct ifreq 			ifr0;
-	struct sockaddr_can		addr0;
-
-	system("/sbin/ip link set can0 down");
-	system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
-	system("/sbin/ip link set can0 up");
-
-	s0 = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-
-	tv.tv_sec = 0;
-	tv.tv_usec = 10000;
-   	if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct	timeval)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("Set SO_RCVTIMEO NG");
-		#endif
-	}
-	nbytes=40960;
-	if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("Set SO_RCVBUF NG");
-		#endif
-	}
-	nbytes=40960;
-	if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("Set SO_SNDBUF NG");
-		#endif
-	}
-
-   	strcpy(ifr0.ifr_name, "can0" );
-	ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
-	addr0.can_family = AF_CAN;
-	addr0.can_ifindex = ifr0.ifr_ifindex;
-	bind(s0, (struct sockaddr *)&addr0, sizeof(addr0));
-	return s0;
-}
-
-//================================================
-// initial uart port
-//================================================
-char *priPortName = "/dev/ttyS1";
-
-int InitComPort(byte id)
-{
-	int fd;
-	struct termios tios;
-
-	if (id == 0x04)
-		fd = open(priPortName, O_RDWR);
-
-	if(fd<=0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("open 407 Communication port NG \n");
-		#endif
-		return -1;
-	}
-	ioctl (fd, TCGETS, &tios);
-	tios.c_cflag = B115200| CS8 | CLOCAL | CREAD;
-	tios.c_lflag = 0;
-	tios.c_iflag = 0;
-	tios.c_oflag = 0;
-	tios.c_cc[VMIN]=0;
-	tios.c_cc[VTIME]=(unsigned char)1;
-	tios.c_lflag=0;
-	tcflush(fd, TCIFLUSH);
-	ioctl (fd, TCSETS, &tios);
-
-	return fd;
-}
-
-//=================================
-// Common routine
-//=================================
-int StoreLogMsg_1(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	time_t CurrentTime;
-	struct tm *tm;
-	va_list args;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1);
-	system(Buf);
-
-	return rc;
-}
-
-unsigned long GetTimeoutValue(struct timeval _sour_time)
-{
-	struct timeval _end_time;
-	gettimeofday(&_end_time, NULL);
-
-	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
-}
-
-int mystrcmp(unsigned char *p1, unsigned char *p2)
-{
-    while(*p1==*p2)
-    {
-        if(*p1=='\0' || *p2=='\0')
-            break;
-        p1++;
-        p2++;
-    }
-    if(*p1=='\0' && *p2=='\0')
-        return(PASS);
-    else
-        return(FAIL);
-}
-
-int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-	//return milli-second
-	unsigned int StartTime,StopTime;
-
-	StartTime=(unsigned int)ST.time;
-	StopTime=(unsigned int)ET.time;
-	//return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
-	return (StopTime-StartTime);
-}
-
-void setChargerMode(byte gun_index, byte mode)
-{
-	chargingInfo[gun_index]->SystemStatus = mode;
-}
-
-//==========================================
-// Check interface status
-//==========================================
-int isInterfaceUp(const char *interface)
-{
-	int result = FAIL;
-
-	FILE *fp;
-	char cmd[256];
-	char buf[512];
-
-	strcpy(cmd, "ifconfig");
-	fp = popen(cmd, "r");
-	if(fp != NULL)
-	{
-		while(fgets(buf, sizeof(buf), fp) != NULL)
-		{
-			if(strstr(buf, interface) > 0)
-			{
-				result = PASS;
-			}
-		}
-	}
-	pclose(fp);
-
-	return result;
-}
-
-//=================================
-// Create all share memory
-//=================================
-int CreateShareMemory()
-{
-	int MeterSMId;
-
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey,	sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmSysConfigAndInfo NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))	== (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmSysConfigAndInfo NG \n");
-		#endif
-		return 0;
-	}
-	memset(ShmSysConfigAndInfo, 0, sizeof(struct SysConfigAndInfo));
-
-	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmStatusCodeData NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmStatusCodeData NG \n");
-		#endif
-		return 0;
-	}
-
-	memset(ShmStatusCodeData, 0, sizeof(struct StatusCodeData));
-
-	//creat ShmPsuData
-	if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmPsuData NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmPsuData NG \n");
-		#endif
-		return 0;
-	}
-	memset(ShmPsuData, 0, sizeof(struct PsuData));
-
-	if(CHAdeMO_QUANTITY > 0)
-	{
-		if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),	IPC_CREAT | 0777)) < 0)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmCHAdeMOData NG \n");
-			#endif
-			return 0;
-		}
-		else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmCHAdeMOData NG \n");
-			#endif
-			return 0;
-		}
-		memset(ShmCHAdeMOData, 0, sizeof(struct CHAdeMOData));
-	}
-
-	//creat ShmCcsData
-	if(CCS_QUANTITY > 0)
-	{
-		if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData),	IPC_CREAT | 0777)) < 0)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmCcsData NG \n");
-			#endif
-			return 0;
-		}
-		else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmCcsData NG \n");
-			#endif
-			return 0;
-		}
-		memset(ShmCcsData, 0, sizeof(struct CcsData));
-	}
-
-	//creat ShmPrimaryMcuData
-	if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmPrimaryMcuData NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmPrimaryMcuData NG \n");
-		#endif
-		return 0;
-	}
-	memset(ShmPrimaryMcuData, 0, sizeof(struct PrimaryMcuData));
-
-	//creat ShmFanModuleData
-	if ((MeterSMId = shmget(ShmFanBdKey, sizeof(struct FanModuleData),	IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmFanModuleData NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmFanModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmFanModuleData NG \n");
-		#endif
-		return 0;
-	}
-	memset(ShmFanModuleData, 0, sizeof(struct FanModuleData));
-
-	//creat ShmRelayModuleData
-	if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData),	IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmRelayModuleData NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmRelayModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmRelayModuleData NG \n");
-		#endif
-		return 0;
-	}
-	memset(ShmRelayModuleData, 0, sizeof(struct RelayModuleData));
-
-	//creat ShmOCPP16Data
-	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), IPC_CREAT | 0777)) < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmget ShmOCPP16Data NG \n");
-		#endif
-		return 0;
-	}
-	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]CreatShareMemory:shmat ShmOCPP16Data NG \n");
-		#endif
-		return 0;
-	}
-	// memset(ShmOCPP16Data,0,sizeof(struct OCPP16Data));
-	return 1;
-}
-
-//=================================
-// LCM Page
-//=================================
-void ChangeLcmByIndex(byte page_index)
-{
-	if (ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level != 2 ||
-			page_index == _LCM_COMPLETE || page_index == _LCM_FIX)
-	{
-		ShmSysConfigAndInfo->SysInfo.PageIndex = page_index;
-	}
-}
-
-//======================================================
-// Peripheral initial
-//======================================================
-void InitGPIO()
-{
-	/*****************0~3, 4 bank, bank x 32+ num*********************/
-	/***************************************************************/
-	/*************** GPIO 0 ***************************************/
-	/***************************************************************/
-	/* GPMC_AD8			=> 	GPIO0_22 *//*ID BD1_1*/
-	system("echo 22 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio22/direction");
-	/* GPMC_AD9			=>	GPIO0_23 *//*ID BD1_2*/
-	system("echo 23 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio23/direction");
-	/* GPMC_AD10		=>	GPIO0_26 *//*IO BD1_1*/
-	system("echo 26 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio26/direction");
-	system("echo 1 > /sys/class/gpio/gpio26/value");
-	/* GPMC_AD11		=>	GPIO0_27 *//*IO BD1_2*/
-	system("echo 27 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio27/direction");
-	/* RMII1_REF_CLK		=>	GPIO0_29 *//*USB 0 OCP detection*/
-	system("echo 29 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio29/direction");
-	/*XDMA_EVENT_INTR0	=>	GPIO0_19 *//*AM_RFID_RST*/
-	system("echo 19 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio19/direction");
-	system("echo 0 > /sys/class/gpio/gpio19/value");
-	/*XDMA_EVENT_INTR1	=>	GPIO0_20 *//*AM_RFID_ICC*/
-	system("echo 20 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio20/direction");
-	/***************************************************************/
-	/*************** GPIO 1 ***************************************/
-	/***************************************************************/
-	/* GPMC_AD12	=> 	GPIO1_12 *//*ID BD2_1*/
-	system("echo 44 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio44/direction");
-	/* GPMC_AD13	=>	GPIO1_13 *//*ID BD2_2*/
-	system("echo 45 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio45/direction");
-	/* GPMC_AD14	=>	GPIO1_14 *//*IO BD2_1*/
-	system("echo 46 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio46/direction");
-	system("echo 0 > /sys/class/gpio/gpio46/value");
-	/* GPMC_AD15	=>	GPIO1_15 *//*IO BD2_2*/
-	system("echo 47 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio47/direction");
-	/***************************************************************/
-	/*************** GPIO 2 ***************************************/
-	/***************************************************************/
-	/*LCD_AC_BIAS_EN	=>	GPIO2_25*//*RS-485 for module DE control*/
-	system("echo 89 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio89/direction");
-	system("echo 1 > /sys/class/gpio/gpio89/value");
-	/*LCD_HSYNC		=>	GPIO2_23*//*RS-485 for module RE control*/
-	system("echo 87 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio87/direction");
-	system("echo 0 > /sys/class/gpio/gpio87/value");
-	/*LCD_PCLK		=>	GPIO2_24*//*CCS communication board 1 proximity*/
-	system("echo 88 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio88/direction");
-	/*LCD_VSYNC		=>	GPIO2_22*//*CCS communication board 2 proximity*/
-	system("echo 86 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio86/direction");
-	/***************************************************************/
-	/*************** GPIO 3 ***************************************/
-	/***************************************************************/
-	/*MCASP0_FSX		=>	GPIO3_15*//*Emergency Stop button detect*/
-	system("echo 111 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio111/direction");
-	/*MCASP0_ACLKR	=>	GPIO3_18*//*USB1 OCP detect*/
-	system("echo 114 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio114/direction");
-	/*MCASP0_AHCLKR	=>	GPIO3_17*//*Emergency IO for AM3352 and STM32F407*/
-	system("echo 113 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio113/direction");
-	/*MCASP0_ACLKX	=>	GPIO3_14*//*Ethernet PHY reset*/
-	system("echo 110 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio110/direction");
-	system("echo 0 > /sys/class/gpio/gpio110/value");
-	/* MCASP0_FSR		=>	GPIO3_19 *//*SMR Enable control_1 for Pskill_1*/
-	system("echo 115 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio115/direction");
-	system("echo 0 > /sys/class/gpio/gpio115/value");
-	/* MCASP0_AXR0	=>	GPIO3_16 *//*CSU board function OK indicator.*/
-	system("echo 112 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio112/direction");
-	system("echo 0 > /sys/class/gpio/gpio112/value");
-	/* MCASP0_AXR1	=>	GPIO3_20 *//*SMR Enable control_2 for Pskill_2*/
-	system("echo 116 > /sys/class/gpio/export");
-	system("echo \"out\" > /sys/class/gpio/gpio116/direction");
-	system("echo 0 > /sys/class/gpio/gpio116/value");
-#ifdef SystemLogMessage
-	DEBUG_ERROR_1("[main]InitGPIO: Initial GPIO OK");
-#endif
-}
-
-int LoadSysConfigAndInfo(struct SysConfigData *ptr)
-{
-	int fd,wrd;
-	struct SysConfigData *buf;
-	byte *PtrBuf;
-	unsigned int ChkSum, ChkSumOrg;
-
-	if ((buf = malloc(sizeof(struct SysConfigData))) == NULL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]LoadSysConfigAndInfo:malloc buffer NG,rebooting..");
-		#endif
-		if (ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-		}
-		sleep(5);
-		system("reboot -f");
-		sleep(5);
-		system("reboot -f");
-	}
-	memset(buf, 0, sizeof(struct SysConfigData));
-
-	fd = open("/dev/mtdblock10", O_RDWR);
-	if (fd < 0)
-	{
-		free(buf);
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]LoadSysConfigAndInfo:open mtdblock10 NG,rebooting..");
-		#endif
-		if (ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-		}
-		sleep(5);
-		system("reboot -f");
-		sleep(5);
-		system("reboot -f");
-	}
-	wrd = read(fd, buf, sizeof(struct SysConfigData));
-	close(fd);
-	if (wrd != (sizeof(struct SysConfigData)))
-	{
-		free(buf);
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: read SysConfigData data NG,rebooting..");
-		#endif
-		if (ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-		}
-		sleep(5);
-		system("reboot -f");
-		sleep(5);
-		system("reboot -f");
-	}
-	PtrBuf = (byte *) buf;
-	ChkSum = 0;
-	for (wrd = 0; wrd < (sizeof(struct SysConfigData) - 4); wrd++)
-	{
-		ChkSum += PtrBuf[wrd];
-	}
-	ChkSumOrg = buf->Checksum;
-
-	if (ChkSum != ChkSumOrg)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: Primary SysConfigData checksum NG, read backup");
-		#endif
-		fd = open("/dev/mtdblock11", O_RDWR);
-		if (fd < 0)
-		{
-			free(buf);
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: open mtdblock11 (backup) NG,rebooting..");
-			#endif
-			if (ShmStatusCodeData != NULL)
-			{
-				ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-			}
-			sleep(5);
-			system("reboot -f");
-			sleep(5);
-			system("reboot -f");
-		}
-		memset(buf, 0, sizeof(struct SysConfigData));
-		wrd = read(fd, buf, sizeof(struct SysConfigData));
-		close(fd);
-		if (wrd != sizeof(struct SysConfigData))
-		{
-			free(buf);
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: read backup SysConfigData data NG,rebooting..");
-			#endif
-			if (ShmStatusCodeData != NULL)
-			{
-				ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-			}
-			sleep(5);
-			system("reboot -f");
-			sleep(5);
-			system("reboot -f");
-		}
-		PtrBuf = (byte *) buf;
-		ChkSum = 0;
-		for (wrd = 0; wrd < (sizeof(struct SysConfigData) - 4); wrd++)
-		{
-			ChkSum += PtrBuf[wrd];
-		}
-		ChkSumOrg = buf->Checksum;
-		if (ChkSum != ChkSumOrg)
-		{
-			#ifdef SystemLogMessage
-			DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: backup SysConfigData checksum NG, read Factory default");
-			#endif
-			fd = open("/dev/mtdblock12", O_RDWR);
-			if (fd < 0)
-			{
-				free(buf);
-				#ifdef SystemLogMessage
-				DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: open mtdblock12 (Factory default) NG,rebooting..");
-				#endif
-				if (ShmStatusCodeData != NULL)
-				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-				}
-				sleep(5);
-				system("reboot -f");
-				sleep(5);
-				system("reboot -f");
-			}
-			memset(buf, 0, sizeof(struct SysConfigData));
-			wrd = read(fd, buf, sizeof(struct SysConfigData));
-			close(fd);
-			if (wrd != sizeof(struct SysConfigData))
-			{
-				free(buf);
-				#ifdef SystemLogMessage
-				DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: read factory default  SysConfigData data NG,rebooting..");
-				#endif
-				if (ShmStatusCodeData != NULL)
-				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-				}
-				sleep(5);
-				system("reboot -f");
-				sleep(5);
-				system("reboot -f");
-			}
-			PtrBuf = (byte *) buf;
-			ChkSum = 0;
-			for (wrd = 0; wrd < (sizeof(struct SysConfigData) - 4); wrd++)
-			{
-				ChkSum += PtrBuf[wrd];
-			}
-			ChkSumOrg = buf->Checksum;
-			if (ChkSum != ChkSumOrg)
-			{
-				#ifdef SystemLogMessage
-				DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: factory default  SysConfigData checksum NG, restore factory default");
-				#endif
-				goto DefaultShm;
-			}
-		}
-	}
-	//load OK
-	memcpy((struct SysConfigData *) ptr, (struct SysConfigData *) buf,	sizeof(struct SysConfigData));
-	free(buf);
-	#ifdef SystemLogMessage
-	DEBUG_ERROR_1("[main]LoadSysConfigAndInfo: Load SysConfigData OK");
-	#endif
-	return 1;
-
-	DefaultShm: system("cd /root;./FactoryConfig");
-	system("sync");
-	sleep(5);
-	system("reboot -f");
-	sleep(5);
-	system("reboot -f");
-	return FAIL;
-}
-
-void InitEthernet()
-{
-	char tmpbuf[256];
-	// /sbin/ifconfig eth0 192.168.1.10 netmask 255.255.255.0 down
-	system("echo 1 > /sys/class/gpio/gpio110/value");//reset PHY
-	sleep(2);
-	//Init Eth0 for internet
-	return;
-	memset(tmpbuf,0,256);
-	sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up",
-	ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
-	ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
-	system(tmpbuf);
-	memset(tmpbuf,0,256);
-	sprintf(tmpbuf,"route add default gw %s eth0 ",
-	ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
-    system(tmpbuf);
-
-    //Init Eth1 for administrator tool
-	memset(tmpbuf,0,256);
-	sprintf(tmpbuf,"/sbin/ifconfig eth1 %s netmask %s up",
-	ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress,
-	ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress);
-	system(tmpbuf);
-
-    //Run DHCP client if enabled
-	system("killall udhcpc");
-	system("rm -rf /etc/resolv.conf");
-	system("echo nameserver 8.8.8.8 > /etc/resolv.conf");		//Google DNS server
-	system("echo nameserver 180.76.76.76 > /etc/resolv.conf");	//Baidu DNS server
-	if(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0)
-		system("/sbin/udhcpc -i eth0 -s /root/simple.script > /dev/null &");
-
-	#ifdef SystemLogMessage
-	DEBUG_ERROR_1("[main]InitEthernet: Initial Ethernet OK");
-	#endif
-}
-
-int InitialRfidPort()
-{
-	int uartO2 = open(rfidPortName, O_RDWR);
-	struct termios tios;
-
-	if (uartO2 != FAIL)
-	{
-		ioctl (uartO2, TCGETS, &tios);
-		tios.c_cflag = B19200 | CS8 | CLOCAL | CREAD;
-		tios.c_lflag = 0;
-		tios.c_iflag = 0;
-		tios.c_oflag = 0;
-		tios.c_cc[VMIN] = 0;
-		tios.c_cc[VTIME] = (unsigned char) 1;
-		tios.c_lflag = 0;
-		tcflush(uartO2, TCIFLUSH);
-		ioctl(uartO2, TCSETS, &tios);
-	}
-
-	if (uartO2 < 0)
-	{
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RfidModuleCommFail = 1;
-	}
-
-	return uartO2;
-}
-
-int Initialization()
-{
-	//InitGPIO();
-	//LoadSysConfigAndInfo(&ShmSysConfigAndInfo->SysConfig);
-	//InitEthernet();
-
-	sprintf((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, "Internet");
-	sprintf((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, " ");
-	sprintf((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, " ");
-
-	// 初始化卡號驗證的 Flag
-	ClearAuthorizedFlag();
-	// 初始化插槍驗證的 Flag
-	ClearDetectPluginFlag();
-
-	// UART 2 for Rfid
-	rfidFd = InitialRfidPort();
-
-	memset(ShmSysConfigAndInfo->SysInfo.FanModuleFwRev, 0, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
-	memset(ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev, 0, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
-	ShmPrimaryMcuData->SelfTest_Comp = NO;
-	ShmRelayModuleData->SelfTest_Comp = NO;
-	ShmFanModuleData->SelfTest_Comp = NO;
-	ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-
-	for (byte count = 0; count < _gunCount; count++)
-	{
-		if (chargingInfo[count]->Type == _Type_Chademo)
-		{
-			ShmCHAdeMOData->evse[chargingInfo[count]->type_index].SelfTest_Comp = NO;
-		}
-		else if (chargingInfo[count]->Type == _Type_CCS)
-		{
-			if (ShmCcsData->CommProtocol == 0x01)
-			{
-				ShmCcsData->V2GMessage_DIN70121[chargingInfo[count]->type_index].SelfTest_Comp = NO;
-			}
-		}
-	}
-
-	#ifdef SystemLogMessage
-	printf("Initialization OK \n");
-	#endif
-
-	return PASS;
-}
-
-void SelfTestRun()
-{
-	bool evInitFlag = false;
-
-	StartSystemTimeoutDet(Timeout_SelftestChk);
-	ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_VERSION;
-	while (ShmSysConfigAndInfo->SysInfo.SelfTestSeq != _STEST_COMPLETE)
-	{
-		ChkPrimaryStatus();
-		if (ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level == 2)
-		{
-			ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_FAIL;
-			return;
-		}
-
-		if (_gunCount > 0)
-		{
-			if (ShmPsuData->Work_Step == _NO_WORKING)
-			{
-				ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_FAIL;
-				break;
-			}
-
-			switch(ShmSysConfigAndInfo->SysInfo.SelfTestSeq)
-			{
-				case _STEST_VERSION:
-				{
-					if (strlen((char *)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev) != 0 ||
-							ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev[0] != '\0')
-					{
-						//printf("RB pass \n");
-						ShmRelayModuleData->SelfTest_Comp = YES;
-					}
-
-					//if  (strlen((char *)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev) != 0 ||
-					//		ShmSysConfigAndInfo->SysInfo.FanModuleFwRev[0] != '\0')
-					{
-						//printf("Fan pass \n");
-						ShmFanModuleData->SelfTest_Comp = YES;
-					}
-
-					if (strlen((char *)ShmPrimaryMcuData->version) != 0 ||
-							ShmPrimaryMcuData->version[0] != '\0')
-					{
-						//printf("407 pass \n");
-						ShmPrimaryMcuData->SelfTest_Comp = YES;
-					}
-					// EV 小板
-					if (!evInitFlag)
-					{
-						evInitFlag = YES;
-						for (byte index = 0; index < _gunCount; index++)
-						{
-							if (chargingInfo[index]->Type == _Type_Chademo)
-							{
-								if (strlen((char *)ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version) != 0 ||
-										ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version[0] != '\0')
-								{
-									//printf("chademo pass \n");
-									ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp = YES;
-								}
-								else
-								{
-									printf("chademo fw lose...... \n");
-									evInitFlag = NO;
-								}
-							}
-							else if (chargingInfo[index]->Type == _Type_CCS)
-							{
-								if (ShmCcsData->CommProtocol == 0x01)
-								{
-									if (strlen((char *)ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version) != 0 ||
-										ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version[0] != '\0')
-									{
-										ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].SelfTest_Comp = YES;
-									}
-									else
-									{
-										printf("ccs fw lose \n");
-										evInitFlag = NO;
-									}
-								}
-							}
-						}
-					}
-
-					if (ShmFanModuleData->SelfTest_Comp &&
-							ShmRelayModuleData->SelfTest_Comp &&
-							ShmPrimaryMcuData->SelfTest_Comp &&
-							evInitFlag)
-					{
-						ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_AC_CONTACTOR;
-					}
-				}
-					break;
-				case _STEST_AC_CONTACTOR:
-				{
-					//ShmPsuData->Work_Step = _TEST_COMPLETE;
-					// 因為 30KW 以下沒有 Relay feedback 功能,所以暫時先直接跳過
-					if (ShmSysConfigAndInfo->SysInfo.AcContactorStatus == YES)
-					{
-						ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_PSU_DETECT;
-						printf("Communication board pass. \n");
-					}
-				}
-					break;
-				case _STEST_PSU_DETECT:
-				{
-					// 此測試主要測試 PSU 對應是否為正確的火線上電壓
-					// 如果沒有 PSU 模組請 bypass
-					if (ShmPsuData->Work_Step == _TEST_POWER_STEP || ShmPsuData->Work_Step == _TEST_COMPLETE)
-					{
-						ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_PSU_CAP;
-					}
-				}
-					break;
-				case _STEST_PSU_CAP:
-				{
-					// 此測試是要確認當前總輸出能力
-					// 如果沒有 PSU 模組請 bypass
-					if (ShmPsuData->Work_Step == _TEST_COMPLETE)
-					{
-						sleep(1);
-						ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_COMPLETE;
-						ShmSysConfigAndInfo->SysInfo.BootingStatus = BOOT_COMPLETE;
-					}
-				}
-					break;
-			}
-		}
-		else
-			break;
-
-		usleep(100000);
-	}
-}
-
-int SpawnTask()
-{
-	system("/root/Module_EventLogging &");
-	system("/root/Module_PrimaryComm &");
-	system("/root/Module_EvComm &");
-	system("/root/Module_LcmControl &");
-	system("/root/Module_InternalComm &");
-	system("/root/Module_PsuComm &");
-
-	//system("/root/OcppBackend &");
-	//system("/root/Module_4g &");
-	//system("/root/Module_Wifi &");
-	//system("/root/Module_PsuComm &");
-	//system("/root/InfyPowerPsu_Comm &");
-
-	// 加入參數
-//	char str[64];
-//	memset(str, '\0', sizeof(65));
-//	sprintf(str, "/root/Module_EvComm %x &", (CHAdeMO_QUANTITY + CCS_QUANTITY));
-//	printf("%s \n", str);
-//	system(str);
-
-	return PASS;
-}
-
-int StoreUsrConfigData(struct SysConfigData *UsrData)
-{
-	int fd,wrd;
-	unsigned int i, Chk;
-	byte *ptr;
-
-	Chk = 0;
-	ptr = (byte *) UsrData;
-	for (i = 0; i < sizeof(struct SysConfigData) - 4; i++)
-	{
-		Chk += *(ptr + i);
-	}
-	UsrData->Checksum = Chk;
-
-	fd = open("/dev/mtdblock10", O_RDWR);
-	if (fd < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]StoreUsrConfigData: open /dev/mtdblock10 NG");
-		#endif
-		return 0;
-	}
-	wrd = write(fd, UsrData, sizeof(struct SysConfigData));
-	close(fd);
-	if (wrd != (sizeof(struct SysConfigData)))
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]StoreUsrConfigData: write /dev/mtdblock10 NG");
-		#endif
-		return 0;
-	}
-
-	fd = open("/dev/mtdblock11", O_RDWR);
-	if (fd < 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]StoreUsrConfigData: open /dev/mtdblock11(backup) NG");
-		#endif
-		return 0;
-	}
-	wrd = write(fd, UsrData, sizeof(struct SysConfigData));
-	close(fd);
-	if (wrd != (sizeof(struct SysConfigData)))
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("[main]StoreUsrConfigData: write /dev/mtdblock11(backup) NG");
-		#endif
-		return 0;
-	}
-	return 1;
-}
-
-//===============================================
-// Common Detect Chk - Stop Charging ?
-//===============================================
-bool isEvBoardStopChargeFlag(byte gunIndex)
-{
-	return chargingInfo[gunIndex]->StopChargeFlag;
-}
-
-//===============================================
-// Common Detect Chk - Chademo
-//===============================================
-bool isEvGunLocked_chademo(byte gunIndex)
-{
-	return (DetectBitValue(chargingInfo[gunIndex]->GunLocked , 0) == 0)? NO : YES;
-}
-
-bool isEvContactorWelding_chademo(byte gunIndex)
-{
-	return DetectBitValue(ShmCHAdeMOData->ev[chargingInfo[gunIndex]->type_index].EvDetection, 3);
-}
-
-bool isEvStopReq_chademo(byte gunIndex)
-{
-	return DetectBitValue(ShmCHAdeMOData->ev[chargingInfo[gunIndex]->type_index].EvDetection, 4);
-}
-
-bool isEvStopCharging_chademo(byte gunIndex)
-{
-	if (isEvGunLocked_chademo(gunIndex) == NO)
-	{
-		// 無鎖槍 = 停止
-		printf("gun locked none. \n");
-		return YES;
-	}
-
-	return NO;
-}
-
-byte isPrechargeStatus_chademo(byte gunIndex)
-{
-	byte result = 0x00;
-
-	result = ShmCHAdeMOData->ev[chargingInfo[gunIndex]->type_index].PresentMsgFlowStatus;
-
-	return result;
-}
-//===============================================
-// Common Detect Chk - CCS
-//===============================================
-bool isEvGunLocked_ccs(byte gunIndex)
-{
-	return (DetectBitValue(chargingInfo[gunIndex]->GunLocked , 0) == 0)? NO : YES;
-}
-
-byte isPrechargeStatus_ccs(byte gunIndex)
-{
-	byte result = 0x00;
-
-	if (ShmCcsData->CommProtocol == 0x01)
-	{
-		result = ShmCcsData->V2GMessage_DIN70121[chargingInfo[gunIndex]->type_index].PresentMsgFlowStatus;
-	}
-
-	return result;
-}
-
-bool isEvStopCharging_ccs(byte gunIndex)
-{
-	if (isEvGunLocked_ccs(gunIndex) == NO)
-	{
-		// 無鎖槍 = 停止
-		printf("gun locked none. \n");
-		return YES;
-	}
-
-	return NO;
-}
-
-//===============================================
-// Callback
-//===============================================
-void _AutoReturnTimeout()
-{
-	if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG)
-	{
-		ClearDetectPluginFlag();
-	}
-
-	ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-//
-//	for (byte i = 0; i < CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; i++)
-//	{
-//		if (chargingInfo[i]->SystemStatus > S_IDLE)
-//		{
-//			switch(chargingInfo[i]->SystemStatus)
-//			{
-//				case S_PREPARNING:
-//				case S_PREPARING_FOR_EV:
-//				case S_PREPARING_FOR_EVSE:
-//				{
-//					ChangeLcmByIndex(i, _LCM_PRE_CHARGE);
-//				}
-//					break;
-//				case S_CHARGING:
-//				{
-//					ChangeLcmByIndex(i, _LCM_CHARGING);
-//				}
-//					break;
-//				case S_TERMINATING:
-//				{
-//					ChangeLcmByIndex(i, _LCM_COMPLETE);
-//				}
-//					break;
-//			}
-//			return;
-//		}
-//	}
-
-//	if (!IsAuthorizingMode())
-//		ChangeLcmByIndex(255, _LCM_IDLE);
-}
-
-void _SelfTestTimeout()
-{
-	if (ShmSysConfigAndInfo->SysInfo.BootingStatus != BOOT_COMPLETE)
-	{
-		for (byte gun_index = 0; gun_index < _gunCount; gun_index++)
-		{
-			setChargerMode(gun_index, MODE_ALARM);
-		}
-		ShmPsuData->Work_Step = _NO_WORKING;
-	}
-}
-
-void _AuthorizedTimeout()
-{
-	if(IsAuthorizingMode())
-	{
-		printf("_AuthorizedTimeout \n");
-		ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_AUTHORIZ_FAIL;
-		//ChangeLcmByIndex(_LCM_AUTHORIZ_FAIL);
-		ClearAuthorizedFlag();
-	}
-}
-
-void _DetectPlugInTimeout()
-{
-	if(isDetectPlugin())
-	{
-		printf("_DetectPlugInTimeout \n");
-		ClearDetectPluginFlag();
-	}
-	ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-}
-
-void _DetectEvChargingEnableTimeout(byte gunIndex)
-{
-	if (chargingInfo[gunIndex]->Type == _Type_Chademo)
-	{
-		if(!isEvGunLocked_chademo(gunIndex))
-		{
-			printf("_DetectEvChargingEnableTimeout (chademo) \n");
-			ChargingTerminalProcess(gunIndex);
-			_AutoReturnTimeout();
-		}
-	}
-	else if (chargingInfo[gunIndex]->Type == _Type_CCS)
-	{
-		if(!isEvGunLocked_ccs(gunIndex))
-		{
-			printf("_DetectEvChargingEnableTimeout (ccs) \n");
-			ChargingTerminalProcess(gunIndex);
-			_AutoReturnTimeout();
-		}
-	}
-}
-
-void _DetectEvseChargingEnableTimeout(byte gunIndex)
-{
-	printf("_DetectEvseChargingEnableTimeout (GFD timeout) \n");
-	if (chargingInfo[gunIndex]->GroundFaultStatus != GFD_PASS)
-	{
-		setChargerMode(gunIndex, MODE_IDLE);
-		_AutoReturnTimeout();
-	}
-}
-
-void _PrepareTimeout(byte gunIndex)
-{
-	printf("_PrechargeTimeout \n");
-	setChargerMode(gunIndex, MODE_IDLE);
-	_AutoReturnTimeout();
-}
-
-void _CompleteTimeout(byte gunIndex)
-{
-	printf("_CompleteTimeout ====> %d \n", gunIndex);
-	setChargerMode(gunIndex, MODE_IDLE);
-}
-
-void _CcsPrechargeTimeout(byte gunIndex)
-{
-	printf("_CcsPrechargeTimeout \n");
-	setChargerMode(gunIndex, MODE_IDLE);
-}
-
-//===============================================
-// 取得卡號與卡號驗證
-//===============================================
-bool canStartCharging()
-{
-	char buf2[16] = "";
-	memset(buf2, 0, ARRAY_SIZE(buf2));
-
-	for (byte index = 0; index < strlen((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status); index++)
-	{
-		sprintf(buf2 + (index - 1) * 2, "%02X",	ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status[index]);
-	}
-	sprintf(buf2, "%s",	ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
-
-	// 因為無法得知實際的長度,所以只能用搜尋的方式
-	if(strstr(buf2, "Accepted") != 0)
-		return true;
-	else
-	{
-
-	}
-
-	return false;
-}
-
-void AuthorizingStart()
-{
-	ShmOCPP16Data->SpMsg.bits.AuthorizeReq = YES;
-}
-
-void ClearAuthorizedFlag()
-{
-	ShmOCPP16Data->SpMsg.bits.AuthorizeReq = NO;
-	ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
-}
-
-bool isAuthorizedComplete()
-{
-	if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == NO)
-		return false;
-
-	return true;
-}
-
-bool IsAuthorizingMode()
-{
-	if(ShmOCPP16Data->SpMsg.bits.AuthorizeReq == NO)
-		return false;
-
-	return true;
-}
-
-byte GetCardNumber()
-{
-	byte card_number[16];
-
-	if (strlen((char *)ShmSysConfigAndInfo->SysConfig.UserId) == 0)
-	{
-		if(getRequestCardSN(rfidFd, 0, card_number))
-		{
-			//Get Card Number
-			byte len = card_number[0];
-			char buf2[32] = "";
-
-			memcpy(buf2, (card_number + 1), len);
-			memset(ShmSysConfigAndInfo->SysConfig.UserId, 0x0, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
-			for (byte index = 0; index < len; index++)
-			{
-				sprintf((char *)ShmSysConfigAndInfo->SysConfig.UserId + (index * 2), "%02X", buf2[index]);
-			}
-
-			printf("card number = %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
-			return PASS;
-		}
-	}
-
-	return FAIL;
-}
-
-//===============================================
-// 掃描插槍狀況
-//===============================================
-void ClearDetectPluginFlag()
-{
-	ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
-}
-
-void DetectPluginStart()
-{
-	ShmSysConfigAndInfo->SysInfo.WaitForPlugit = YES;
-}
-
-bool isDetectPlugin()
-{
-	if(ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES)
-		return YES;
-
-	return NO;
-}
-
-//===============================================
-// EmergencyStop and Charging Stop
-//===============================================
-void ChargingTerminalProcess(byte gunIndex)
-{
-	setChargerMode(gunIndex, MODE_TERMINATING);
-}
-
-void StopChargingProcessByString(byte level, byte gun_index, char *string)
-{
-	if (strlen((char *)ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index]) == 0 ||
-		level > ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level)
-	{
-		memcpy(&ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index][0], string, 7);
-		ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level = level;
-	}
-}
-
-void ReleaseChargingProcessByString(byte gun_index, char *code)
-{
-	memcpy(&ShmSysConfigAndInfo->SysStopChargingAlarmCode.StopCode[gun_index][0], "", 7);
-	ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level = 0;
-}
-
-// 各小板的停止充電處理函式
-void EmcOccureByString(byte index, char *code)
-{
-	bool isStopCharger = false;
-	if (strncmp(code, "012251", 6) == 0 || strncmp(code, "012252", 6) == 0 ||
-			strncmp(code, "012237", 6) == 0 || strncmp(code, "012238", 6) == 0)
-	{
-		isStopCharger = true;
-	}
-
-	if (isStopCharger)
-	{
-		for (byte gun = 0; gun < _gunCount; gun++)
-		{
-			if ((chargingInfo[gun]->SystemStatus > S_IDLE && chargingInfo[gun]->SystemStatus < S_TERMINATING) ||
-					(chargingInfo[gun]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[gun]->SystemStatus <= S_CCS_PRECHARGE_ST1))
-			{
-				ChargingTerminalProcess(gun);
-			}
-
-			StopChargingProcessByString(2, gun, code);
-		}
-	}
-	else
-	{
-		if ((chargingInfo[index]->SystemStatus > S_IDLE && chargingInfo[index]->SystemStatus < S_TERMINATING) ||
-				(chargingInfo[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[index]->SystemStatus <= S_CCS_PRECHARGE_ST1))
-		{
-			ChargingTerminalProcess(index);
-		}
-
-		StopChargingProcessByString(2, index, code);
-	}
-}
-
-void ReleaseEmsOccureByString(byte index, char *code)
-{
-	bool isReleaseCharger = false;
-	bool isTrigger = false;
-
-	if (strncmp(code, "012251", 6) == 0 && ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == YES)
-	{
-		isTrigger = true;
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = NO;
-		isReleaseCharger = true;
-	}
-	else if (strncmp(code, "012252", 6) == 0 && ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen == YES)
-	{
-		isTrigger = true;
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen = NO;
-		isReleaseCharger = true;
-	}
-	else if (strncmp(code, "012237", 6) == 0 && ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SpdTrip == YES)
-	{
-		isTrigger = true;
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SpdTrip = NO;
-		isReleaseCharger = true;
-	}
-	else if (strncmp(code, "012238", 6) == 0 && ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip == YES)
-	{
-		isTrigger = true;
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip = NO;
-		isReleaseCharger = true;
-	}
-	else if (strncmp(code, "023730", 6) == 0 && ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop == YES)
-	{
-		isTrigger = true;
-		ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = NO;
-	}
-
-	if (isTrigger)
-	{
-		if (isReleaseCharger)
-		{
-			for (byte gun = 0; gun < _gunCount; gun++)
-			{
-				ReleaseChargingProcessByString(gun, code);
-			}
-		}
-		else
-		{
-			ReleaseChargingProcessByString(index, code);
-		}
-	}
-}
-
-//===============================================
-// 確認硬體 (按鈕) 狀態
-//===============================================
-bool leftBtnPush = false;
-bool rightBtnPush = false;
-
-void ChkPrimaryStatus()
-{
-	if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL)
-	{
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = YES;
-		EmcOccureByString(0, "012251");
-	}
-	else
-		ReleaseEmsOccureByString(0, "012251");
-
-	if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == ABNORMAL)
-	{
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip = YES;
-		EmcOccureByString(0, "012238");
-	}
-	else
-		ReleaseEmsOccureByString(0, "012238");
-
-	if (ShmPrimaryMcuData->InputDet.bits.SpdDetec == ABNORMAL)
-	{
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SpdTrip = YES;
-		EmcOccureByString(0, "012237");
-	}
-	else
-		ReleaseEmsOccureByString(0, "012237");
-
-	if (ShmPrimaryMcuData->InputDet.bits.DoorOpen == ABNORMAL)
-	{
-		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen = YES;
-		EmcOccureByString(0, "012252");
-	}
-	else
-		ReleaseEmsOccureByString(0, "012252");
-
-	if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS && !leftBtnPush)
-	{
-		if(!leftBtnPush)
-		{
-			printf("left btn down............................... \n");
-			ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
-			switch(chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
-			{
-				case S_IDLE:
-				{
-					ShmSysConfigAndInfo->SysInfo.WaitForPlugit = 0x01;
-				}
-				break;
-				case S_CHARGING:
-				{
-					// 停止充電
-					printf("To Stop = %d --------- \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-					chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = 9;
-					//ChargingTerminalProcess(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-				}
-					break;
-				case S_COMPLETE:
-				{
-					// 回 IDLE
-					printf("Back to IDLE = %d --------- \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-					chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = 1;
-				}
-					break;
-			}
-		}
-
-		leftBtnPush = true;
-		// 左邊的選槍按鈕,只有在雙槍都在充電時候才有用 : 30KW 以下該按鈕無作用
-	}
-	else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE)
-	{
-		if(leftBtnPush)
-			printf("left btn up............................... \n");
-		leftBtnPush = false;
-	}
-
-	if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS && !rightBtnPush)
-	{
-		if(!rightBtnPush)
-		{
-			printf("right btn down............................... \n");
-			if (_gunCount > 1)
-			{
-				ShmSysConfigAndInfo->SysInfo.CurGunSelected = 1;
-				switch(chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
-				{
-					case S_IDLE:
-					{
-						//ShmSysConfigAndInfo->SysInfo.WaitForPlugit = 0x01;
-					}
-					break;
-					case S_CHARGING:
-					{
-						// 停止充電
-						printf("To Stop = %d --------- \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-						//chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = 9;
-						//ChargingTerminalProcess(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-					}
-						break;
-					case S_COMPLETE:
-					{
-						// 回 IDLE
-						printf("Back to IDLE = %d --------- \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-						//chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = 1;
-					}
-						break;
-				}
-			}
-		}
-
-		rightBtnPush = true;
-		// 右邊的按鈕,只作用在當前頁面,當前頁面如果在可以回 Home 與 停止充電的狀態為可用
-//		switch(chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
-//		{
-//			case S_IDLE: {}break;
-//			case S_AUTHORIZING: {}break;
-//			case S_PREPARING_FOR_EV: {}break;
-//			case S_PREPARING_FOR_EVSE: {}break;
-//			case S_CCS_PRECHARGE_ST0: {}break;
-//			case S_CCS_PRECHARGE_ST1: {}break;
-//			case S_CHARGING:
-//			{
-//				// 停止充電
-//				printf("Stop --------------------------------------------------- \n");
-//				//ChargingTerminalProcess(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-//			}
-//				break;
-//			case S_COMPLETE:
-//			{
-//				//setChargerMode(ShmSysConfigAndInfo->SysInfo.CurGunSelected, MODE_IDLE);
-//			}
-//				break;
-//		}
-	}
-	else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE)
-	{
-		if(rightBtnPush)
-			printf("right btn up............................... \n");
-		rightBtnPush = false;
-	}
-}
-
-//===============================================
-// 確認各小板偵測的錯誤狀況
-//===============================================
-void CheckErrorOccurStatus(byte index)
-{
-	// 小板
-	if (chargingInfo[index]->Type == _Type_Chademo)
-	{
-		if (ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop == YES)
-			EmcOccureByString(index, "023730");
-		else if (ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == YES)
-			EmcOccureByString(index, "011012");
-		else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoGfdTrip == YES)
-			EmcOccureByString(index, "012234");
-	}
-	else if (chargingInfo[index]->Type == _Type_CCS)
-	{
-		if (ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault == YES)
-			EmcOccureByString(index, "011014");
-		else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsGfdTrip == YES)
-			EmcOccureByString(index, "012235");
-	}
-}
-
-//===============================================
-// 確認 GPIO 狀態
-//===============================================
-int gpio_get_value(unsigned int gpio, unsigned int *value)
-{
-    int fd;
-    char buf[MAX_BUF];
-    char ch;
-
-    snprintf(buf, sizeof(buf), SYSFS_GPIO_DIR "/gpio%d/value", gpio);
-
-    fd = open(buf, O_RDONLY);
-    if (fd < 0) {
-        perror("gpio/get-value");
-        return fd;
-    }
-
-    read(fd, &ch, 1);
-
-    if (ch != '0') {
-        *value = 1;
-    } else {
-        *value = 0;
-    }
-
-    close(fd);
-    return 0;
-}
-
-void CheckGunTypeFromHw()
-{
-	int pinIn[4] = { 22, 23, 44, 45 };
-	unsigned int gpioValue = 0;
-
-	for (int i = 0; i < ARRAY_SIZE(pinIn); i++) {
-		gpio_get_value(pinIn[i], &gpioValue);
-		{
-			switch (pinIn[i])
-			{
-			case 22:
-				bd1_1_status = gpioValue;
-				break;
-			case 23:
-				bd1_2_status = gpioValue;
-				break;
-			case 44:
-				bd0_1_status = gpioValue;
-				break;
-			case 45:
-				bd0_2_status = gpioValue;
-				break;
-			}
-		}
-	}
-}
-
-void CheckGpioInStatus()
-{
-	int pinIn[2] = { 27, 47 };
-	unsigned int gpioValue = 0;
-
-	for (int i = 0; i < ARRAY_SIZE(pinIn); i++)
-	{
-		gpio_get_value(pinIn[i], &gpioValue);
-		if (gpioValue == 0x01)
-		{
-			switch(pinIn[i])
-			{
-				// 小板緊急停止
-				case 47:
-				{
-					for(int i = 0; i < _gunCount; i++)
-					{
-						if (chargingInfo[i]->slotsIndex == 1)
-						{
-							if (chargingInfo[i]->Type == _Type_Chademo)
-								EmcOccureByString(i, "023730");
-							else if (chargingInfo[i]->Type == _Type_CCS)
-								EmcOccureByString(i, "013627");
-							break;
-						}
-					}
-				}
-					break;
-				case 27:
-				{
-					for(int i = 0; i < _gunCount; i++)
-					{
-						if (chargingInfo[i]->slotsIndex == 3)
-						{
-							if (chargingInfo[i]->Type == _Type_Chademo)
-								EmcOccureByString(i, "023730");
-							else if (chargingInfo[i]->Type == _Type_CCS)
-								EmcOccureByString(i, "013627");
-							break;
-						}
-					}
-				}
-					break;
-			}
-		}
-		else
-		{
-			switch (pinIn[i])
-			{
-				// 小板解除緊急停止
-				case 47:
-				{
-					for(int i = 0; i < _gunCount; i++)
-					{
-						if (chargingInfo[i]->slotsIndex == 1)
-						{
-							if (chargingInfo[i]->Type == _Type_Chademo)
-								ReleaseEmsOccureByString(i, "023730");
-							else if (chargingInfo[i]->Type == _Type_CCS)
-								ReleaseEmsOccureByString(i, "013627");
-							break;
-						}
-					}
-				}
-					break;
-				case 27:
-				{
-					for (int i = 0; i < _gunCount; i++)
-					{
-						if (chargingInfo[i]->slotsIndex == 3)
-						{
-							if (chargingInfo[i]->Type == _Type_Chademo)
-								ReleaseEmsOccureByString(i, "023730");
-							else if (chargingInfo[i]->Type == _Type_CCS)
-								ReleaseEmsOccureByString(i, "013627");
-							break;
-						}
-					}
-				}
-				break;
-			}
-		}
-	}
-}
-
-//===============================================
-// Main process
-//===============================================
-// 檢查 Byte 中某個 Bit 的值
-// _byte : 欲改變的 byte
-// _bit : 該 byte 的第幾個 bit
-unsigned char DetectBitValue(unsigned char _byte, unsigned char _bit)
-{
-	return ( _byte & mask_table[_bit] ) != 0x00;
-}
-
-// 設定 Byte 中某個 Bit的值
-// _byte : 欲改變的 byte
-// _bit : 該 byte 的第幾個 bit
-// value : 修改的值為 0 or 1
-void SetBitValue(unsigned char *_byte, unsigned char _bit, unsigned char value)
-{
-	if(value == 1)
-		*_byte |= (1 << _bit);
-	else if (value == 0)
-		*_byte ^= (1 << _bit);
-}
-
-void UserScanFunction()
-{
-	bool idleReq = false;
-	unsigned char stopReq = 255;
-
-	// 當前非驗證的狀態
-	if(!IsAuthorizingMode())
-	{
-		// 先判斷現在是否可以提供刷卡
-		// 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
-		// 2. 停止充電
-		for (byte i = 0; i < _gunCount; i++)
-		{
-			// 二擇一
-			if (chargingInfo[i]->SystemStatus == S_CHARGING)
-			{
-				stopReq = i;
-			}
-			else if (chargingInfo[i]->SystemStatus == S_IDLE)
-			{
-				idleReq = true;
-			}
-		}
-
-		// 有閒置的槍號,即可接受刷卡
-		if (idleReq || stopReq < _gunCount)
-		{
-			// 取卡號,假設 : 刷卡過了
-			if (strlen((char *)ShmSysConfigAndInfo->SysConfig.UserId) > 0)
-			{
-				if (stopReq < _gunCount)
-				{
-					char value[32];
-
-					memcpy(value, (unsigned char *)chargingInfo[stopReq]->CardNumber, ARRAY_SIZE(chargingInfo[stopReq]->CardNumber));
-					if (strcmp((char *)ShmSysConfigAndInfo->SysConfig.UserId, value) == EQUAL)
-					{
-						ChargingTerminalProcess(stopReq);
-						strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-						return;
-					}
-				}
-
-				if (idleReq)
-				{
-					// LCM => Authorizing
-					ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_AUTHORIZING;
-					// 進入確認卡號狀態
-					AuthorizingStart();
-					// authorizing timer
-					StartSystemTimeoutDet(Timeout_Authorizing);
-					autoReturnTimeoutFlag = NO;
-				}
-			}
-		}
-	}
-	else
-	{
-		// 確認驗證卡號完成沒
-		if (isAuthorizedComplete() || ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
-		{
-			StopSystemTimeoutDet();
-			// 判斷後台回覆狀態
-			if(canStartCharging() || ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
-			{
-				// LCM => Authorize complete
-				ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_AUTHORIZ_COMP;
-				// 通過認證,開始確認當前要進入充電的槍號
-				DetectPluginStart();
-			}
-			else
-			{
-				// LCM => Authorize fail
-				ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_AUTHORIZ_FAIL;
-			}
-			ClearAuthorizedFlag();
-		}
-	}
-}
-
-unsigned char isModeChange(unsigned char gun_index)
-{
-	unsigned char result = NO;
-
-	if(chargingInfo[gun_index]->SystemStatus != chargingInfo[gun_index]->PreviousSystemStatus)
-	{
-		result = YES;
-		chargingInfo[gun_index]->PreviousSystemStatus = chargingInfo[gun_index]->SystemStatus;
-	}
-
-	return result;
-}
-
-void ScannerCardProcess()
-{
-	if (!isDetectPlugin() && !isCardScan && ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level == 0)
-	{
-		isCardScan = true;
-		// 處理刷卡及驗證卡號的動作
-		UserScanFunction();
-	}
-
-	if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_AUTHORIZ_FAIL)
-	{
-		StartSystemTimeoutDet(Timeout_VerifyFail);
-		isCardScan = false;
-	}
-	else if(ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_AUTHORIZ_COMP)
-	{
-		StartSystemTimeoutDet(Timeout_VerifyComp);
-	}
-	else if(ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG)
-	{
-		StartSystemTimeoutDet(Timeout_WaitPlug);
-	}
-	else
-		isCardScan = false;
-}
-
-void AddGunInfoByConnector(byte typeValue, byte slots)
-{
-	switch (typeValue)
-	{
-		case '0': // none
-			break;
-		case '1': // IEC 62196-2 Type 1/SAE J1772 Plug
-			break;
-		case '2': // IEC 62196-2 Type 1/SAE J1772 Socket
-			break;
-		case '3': // IEC 62196-2 Type 2 Plug
-			break;
-		case '4': // IEC 62196-2 Type 2 Socket
-			break;
-		case '5': // GB/T AC Plug
-			break;
-		case '6': // GB/T AC Socket
-			break;
-		case 'J': // CHAdeMO
-		{
-			if (CHAdeMO_QUANTITY > _chademoIndex)
-			{
-				chargingInfo[_gunIndex] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[_chademoIndex];
-
-				chargingInfo[_gunIndex]->Index = _gunIndex;
-				chargingInfo[_gunIndex]->slotsIndex = slots;
-				chargingInfo[_gunIndex]->SystemStatus = S_BOOTING;
-				chargingInfo[_gunIndex]->Type = _Type_Chademo;
-				chargingInfo[_gunIndex]->type_index = _chademoIndex;
-				_chademoIndex++;
-				_gunIndex++;
-			}
-		}
-			break;
-		case 'U': // CCS1 combo
-			break;
-		case 'E': // CCS2 combo
-		{
-			if (CCS_QUANTITY > _ccsIndex)
-			{
-				chargingInfo[_gunIndex] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[_ccsIndex];
-
-				chargingInfo[_gunIndex]->Index =	_gunIndex;
-				chargingInfo[_gunIndex]->slotsIndex = slots;
-				chargingInfo[_gunIndex]->SystemStatus = S_BOOTING;
-				chargingInfo[_gunIndex]->Type = _Type_CCS;
-				chargingInfo[_gunIndex]->type_index = _ccsIndex;
-				// 現階段預設為走 DIN70121
-				ShmCcsData->CommProtocol = 0x01;
-				_ccsIndex++;
-				_gunIndex++;
-			}
-		}
-			break;
-		case 'G': // GBT DC
-			break;
-		case 'D': // GBT DC x 2
-			break;
-	}
-}
-
-bool CheckConnectorTypeStatus()
-{
-	bool result = true;
-
-	printf("bd0_1_status = %d, bd0_2_status = %d, bd1_1_status = %d, bd1_2_status = %d \n",
-			bd0_1_status, bd0_2_status, bd1_1_status, bd1_2_status);
-	if (strlen((char *) ShmSysConfigAndInfo->SysConfig.ModelName) >= 9)
-	{
-		byte slots = 1;
-		for (byte typeIndex = 7; typeIndex <= 9; typeIndex++)
-		{
-			AddGunInfoByConnector(ShmSysConfigAndInfo->SysConfig.ModelName[typeIndex], slots);
-			slots++;
-		}
-
-		_gunCount = _gunIndex;
-		printf("_gunCount = %d \n", _gunCount);
-		if (_gunCount == 0)
-			result = false;
-
-		// 偵測槍屬於哪個 slot : 可知道插在板上的Slot 0 或 1 是 Chademo 還是 CCS
-		for (byte gunIndex = 0; gunIndex < _gunCount; gunIndex++)
-		{
-			if (bd0_1_status == 0 && bd0_2_status == 1)
-			{
-				// 與硬體相同 type : Chademo
-				if (chargingInfo[gunIndex]->Type == _Type_Chademo)
-				{
-					chargingInfo[gunIndex]->Evboard_id = 0x01;
-				}
-			}
-			else if (bd0_1_status == 1 && bd0_2_status == 0)
-			{
-				// 與硬體相同 type : CCS
-				if (chargingInfo[gunIndex]->Type == _Type_CCS)
-				{
-					chargingInfo[gunIndex]->Evboard_id = 0x01;
-				}
-			}
-
-			if (bd1_1_status == 0 && bd1_2_status == 1)
-			{
-				// 與硬體相同 type : Chademo
-				if (chargingInfo[gunIndex]->Type == _Type_Chademo)
-				{
-					chargingInfo[gunIndex]->Evboard_id = 0x02;
-				}
-
-				if (_gunCount == 1)
-					chargingInfo[gunIndex]->Evboard_id = 0x01;
-			}
-			else if (bd1_1_status == 1 && bd1_2_status == 0)
-			{
-				// 與硬體相同 type : CCS
-				if (chargingInfo[gunIndex]->Type == _Type_CCS)
-				{
-					chargingInfo[gunIndex]->Evboard_id = 0x02;
-				}
-
-				if (_gunCount == 1)
-					chargingInfo[gunIndex]->Evboard_id = 0x01;
-			}
-
-			printf("index = %d, Type = %d, Evboard_id = %d \n", gunIndex, chargingInfo[gunIndex]->Type, chargingInfo[gunIndex]->Evboard_id);
-			if (chargingInfo[gunIndex]->Evboard_id == 0x00)
-				result = false;
-		}
-	}
-	else
-	{
-		// Module Name 不正確 - 告警
-		result = false;
-	}
-
-	return result;
-}
-
-void KillTask()
-{
-	ChangeLcmByIndex(_LCM_FIX);
-	system("killall Module_EventLogging");
-	system("killall Module_PrimaryComm");
-	system("killall Module_EvComm");
-	system("killall Module_LcmControl");
-	system("killall Module_InternalComm");
-	system("killall Module_PsuComm");
-}
-
-char CheckUpdateProcess()
-{
-	DIR *d;
-	struct dirent *dir;
-	d = opendir("/mnt/");
-
-	if (d)
-	{
-		long int MaxLen=48*1024*1024, ImageLen = 0;
-		while ((dir = readdir(d)) != NULL)
-		{
-			char *new_str;
-			new_str = malloc(strlen("/mnt/")+strlen(dir->d_name)+1);
-			new_str[0] = '\0';
-			strcat(new_str, "/mnt/");
-			strcat(new_str, dir->d_name);
-			int fd = open(new_str, O_RDONLY);
-			if (fd < 0)
-			{
-				return FAIL;
-			}
-
-			unsigned char *ptr = malloc(MaxLen); //-48 is take out the header
-			memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
-			//get the image length
-			ImageLen = read(fd, ptr, MaxLen);
-
-			if (ImageLen > 20)
-			{
-				unsigned int Type = (((unsigned int)ptr[16])<<24 | ((unsigned int)ptr[17])<<16 | ((unsigned int)ptr[18])<<8 | ((unsigned int)ptr[19]));
-			    printf("Typed...%x \r\n", Type);
-
-			    switch (Type)
-			    {
-			    	case 0x10000001:
-			    	case 0x10000002:
-			    	case 0x10000003:
-			    	case 0x10000004:
-			    	case 0x10000005:
-			    	case 0x10000006:
-			    	{
-			    		// CSU_PRIMARY_CONTROLLER : 0x10000006
-			    		int fd = InitComPort(0x04);
-
-			    		if (Upgrade_UART(fd, Type, 0x04, new_str, ShmSysConfigAndInfo->SysConfig.ModelName) == PASS)
-			    			return PASS;
-			    		else
-			    			return FAIL;
-
-			    		close(fd);
-			    	}
-			    	break;
-			    	case 0x1000000B:
-			    	{
-			    		// CHAdeMO_BOARD : 0x1000000B
-			    		for(byte index = 0; index < _gunCount; index++)
-			    		{
-			    			if (chargingInfo[index]->Type == _Type_Chademo)
-			    			{
-			    				int CanFd = InitCanBus();
-			    				if (CanFd > 0)
-			    				{
-			    					if (Upgrade_CAN(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, ShmSysConfigAndInfo->SysConfig.ModelName) == PASS)
-			    					{
-			    						printf("Upgrad OK. \n");
-			    						return PASS;
-			    					}
-			    					else
-			    					{
-			    						printf("Upgrad Fail. \n");
-			    						return FAIL;
-			    					}
-			    				}
-			    				else
-			    				{
-			    					printf("Upgrad FD fail. \n");
-			    					return FAIL;
-			    				}
-			    			}
-			    		}
-			    		break;
-			    	}
-			    }
-			}
-			free(new_str);
-			free(ptr);
-		}
-	}
-	free(dir);
-	closedir(d);
-	return FAIL;
-}
-
-void CreateRfidFork()
-{
-	pid_t rfidRecPid;
-
-	rfidRecPid = fork();
-	if (rfidRecPid == 0)
-	{
-		while(true)
-		{
-			// 刷卡判斷
-			GetCardNumber();
-			usleep(100000);
-		}
-	}
-}
-
-void StartSystemTimeoutDet(unsigned char flag)
-{
-	if (ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag != flag)
-	{
-		gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
-	}
-	ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = flag;
-}
-
-void StopSystemTimeoutDet()
-{
-	ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
-}
-
-void StartGunInfoTimeoutDet(unsigned char gunIndex, unsigned char flag)
-{
-	if (gunIndex < _gunCount)
-	{
-		if (chargingInfo[gunIndex]->TimeoutFlag != flag)
-		{
-			gettimeofday(&chargingInfo[gunIndex]->TimeoutTimer, NULL);
-		}
-		chargingInfo[gunIndex]->TimeoutFlag = flag;
-	}
-}
-
-void StopGunInfoTimeoutDet(unsigned char gunIndex)
-{
-	if (gunIndex < _gunCount)
-	{
-		chargingInfo[gunIndex]->TimeoutFlag = Timeout_None;
-	}
-}
-
-void CreateTimeoutFork()
-{
-	pid_t timeoutPid;
-
-	timeoutPid = fork();
-	if (timeoutPid == 0)
-	{
-		while(true)
-		{
-			// 系統
-			switch(ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag)
-			{
-				case Timeout_SelftestChk:
-					if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) >= 60000000)
-					{
-						_SelfTestTimeout();
-						StopSystemTimeoutDet();
-					}
-					break;
-				case Timeout_Authorizing:
-					if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) >= 60000000)
-					{
-						_AuthorizedTimeout();
-						StopSystemTimeoutDet();
-					}
-					break;
-				case Timeout_VerifyFail:
-					if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) >= 3000000)
-					{
-						_AutoReturnTimeout();
-						StopSystemTimeoutDet();
-					}
-					break;
-				case Timeout_VerifyComp:
-					if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) >= 3000000)
-					{
-						_AutoReturnTimeout();
-						StopSystemTimeoutDet();
-					}
-					break;
-				case Timeout_WaitPlug:
-					if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) >= 40000000)
-					{
-						_DetectPlugInTimeout();
-						StopSystemTimeoutDet();
-					}
-					break;
-			}
-			// 各槍
-			for (byte gun_index = 0; gun_index < _gunCount; gun_index++)
-			{
-				switch(chargingInfo[gun_index]->TimeoutFlag)
-				{
-					case Timeout_Preparing:
-						if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 30000000)
-						{
-							_PrepareTimeout(gun_index);
-							StopGunInfoTimeoutDet(gun_index);
-						}
-						break;
-					case Timeout_EvChargingDet:
-						if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 120000000)
-						{
-							_DetectEvChargingEnableTimeout(gun_index);
-							StopGunInfoTimeoutDet(gun_index);
-						}
-						break;
-					case Timeout_EvseChargingDet:
-						if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 60000000)
-						{
-							_DetectEvseChargingEnableTimeout(gun_index);
-							StopGunInfoTimeoutDet(gun_index);
-						}
-						break;
-					case Timeout_WaitforCompleteDet:
-						if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 10000000)
-						{
-							_CompleteTimeout(gun_index);
-							StopGunInfoTimeoutDet(gun_index);
-						}
-						break;
-					case Timeout_ForCcsPrechargeDet:
-						if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 60000000)
-						{
-							_CcsPrechargeTimeout(gun_index);
-							StopGunInfoTimeoutDet(gun_index);
-						}
-						break;
-				}
-			}
-			usleep(100000);
-		}
-	}
-}
-
-int main(void)
-{
-	InitGPIO();
-	InitEthernet();
-	sleep(1);
-	system("/sbin/ifconfig eth0 192.168.1.10 netmask 255.255.255.0 down");
-	sleep(1);
-	system("/sbin/ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up");
-//	//echo 1 > /sys/class/gpio/gpio110/value
-//
-//	return 0;
-
-	if(CreateShareMemory() == 0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR_1("CreatShareMemory NG \n");
-		#endif
-		if(ShmStatusCodeData!=NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
-		}
-		return 0;
-		sleep(5);
-		system("reboot -f");
-		sleep(5);
-		system("reboot -f");
-	}
-
-	while(1)
-	{
-		printf("TelcomApn = %s \n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn);
-		printf("TeleConfigData TelcomIpAddress = %s \n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
-		sleep(1);
-	}
-
-//	while(1)
-//		{
-//			printf("sys id = %s \n", ShmSysConfigAndInfo->SysConfig.SystemId);
-//			printf("sys date = %s \n", ShmSysConfigAndInfo->SysConfig.SystemDateTime);
-//			printf("Ac Phase Count = %d \n", ShmSysConfigAndInfo->SysConfig.AcPhaseCount);
-//			printf("Factory Config = %d \n", ShmSysConfigAndInfo->SysInfo.FactoryConfiguration);
-//			printf("Author mode = %d \n", ShmSysConfigAndInfo->SysConfig.AuthorisationMode);
-//			printf("Default lang = %d \n", ShmSysConfigAndInfo->SysConfig.DefaultLanguage);
-//			printf("Rfid CardNum Endian = %d \n", ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian);
-//
-//			printf("MaxChargingEnergy = %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy);
-//			printf("MaxChargingPower = %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingPower);
-//			printf("MaxChargingCurrent = %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
-//			printf("MaxChargingDuration = %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingDuration);
-//			printf("PhaseLossPolicy = %d \n", ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy);
-//			printf("CcsAuthentication = %d \n", ShmSysConfigAndInfo->SysConfig.AuthorisationMode);
-//			printf("AcCcsChargingModel = %d \n", ShmSysConfigAndInfo->SysConfig.DefaultLanguage);
-//
-//			printf("FtpServer = %s \n", ShmSysConfigAndInfo->SysConfig.FtpServer);
-//			printf("Eth0DhcpClient = %d \n", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient);
-//			printf("Eth0IpAddress = %d \n", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient);
-//			printf("Eth0SubmaskAddress = %d \n", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient);
-//			printf("Eth0GatewayAddress = %d \n", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient);
-//			printf("Eth1DhcpClient = %d \n", ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient);
-//			printf("Eth1IpAddress = %d \n", ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient);
-//			printf("Eth1SubmaskAddress = %d \n", ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient);
-//			printf("Eth1GatewayAddress = %d \n", ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient);
-//			printf("WifiMode = %d \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
-//			printf("WifiSsid = %s \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid);
-//			printf("WifiPassword = %s \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword);
-//			printf("WifiDhcpServer = %d \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer);
-//			printf("WifiDhcpClient = %d \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient);
-//			printf("WifiIpAddress = %s \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress);
-//			printf("WifiSubmaskAddress = %s \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress);
-//			printf("WifiGatewayAddress = %s \n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress);
-//			printf("TelcomApn = %d \n", ShmSysConfigAndInfo->SysConfig.DefaultLanguage);
-//			printf("TelcomChapPapId = %s \n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId);
-//			printf("TelcomChapPapPwd = %s \n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd);
-//			printf("TelcomIpAddress = %s \n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
-//
-//			printf("BackendConnTimeout = %d \n", ShmSysConfigAndInfo->SysConfig.BackendConnTimeout);
-//			printf("OfflinePolicy = %d \n", ShmSysConfigAndInfo->SysConfig.OfflinePolicy);
-//			printf("OfflineMaxChargeEnergy = %d \n", ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy);
-//			printf("OfflineMaxChargeDuration = %d \n", ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration);
-//			printf("OcppServerURL = %s \n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
-//			printf("ChargeBoxId = %s \n", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
-//
-//			sleep(3);
-//		}
-
-	printf("\n");
-	printf("CheckGunTypeFromHw....... \n");
-	CheckGunTypeFromHw();
-	char *moduleName = "DSYE601J0ET2PH";
-	memcpy(&ShmSysConfigAndInfo->SysConfig.ModelName, moduleName, strlen(moduleName));
-
-	if (!CheckConnectorTypeStatus())
-	{
-		// Module Name 與硬體對應不正確
-		printf("Module Name & HW info none match. \n");
-		DEBUG_ERROR_1("Module Name & HW info none match. \n");
-		sleep(5);
-		return 0;
-	}
-
-	printf("Module Name & HW info correct. Initialize.......\n");
-	Initialization();
-	printf("Spawn all Task. \n");
-	SpawnTask();
-
-	ChangeLcmByIndex(_LCM_INIT);
-	CreateTimeoutFork();
-	printf("Self test. \n");
-	SelfTestRun();
-	StopSystemTimeoutDet();
-
-	if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq == _STEST_FAIL)
-	{
-		for (byte gun_index = 0; gun_index < _gunCount; gun_index++)
-		{
-			setChargerMode(gun_index, MODE_ALARM);
-		}
-		ChangeLcmByIndex(_LCM_FIX);
-		return FAIL;
-	}
-	else
-	{
-		for (byte gun_index = 0; gun_index < _gunCount; gun_index++)
-		{
-			setChargerMode(gun_index, MODE_IDLE);
-		}
-	}
-	ChangeLcmByIndex(_LCM_IDLE);
-	sleep(1);
-	//***** 須新增的偵測 *****//
-	// 1. Thernal - 控制風扇轉速
-	// 2. ouput fuse - 控制風扇轉速
-
-	CreateRfidFork();
-	// Main loop
-	printf("Main Loop. \n");
-	for (;;)
-	{
-		ChkPrimaryStatus();
-		if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_IDLE)
-		{
-			//printf("ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = %d \n", ShmSysConfigAndInfo->SysInfo.FirmwareUpdate);
-			if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES)
-			{
-				KillTask();
-				return FAIL;
-				if (CheckUpdateProcess() == PASS)
-				{
-					printf("update complete. \n");
-				}
-				else
-				{
-					printf("update fail. \n");
-				}
-				ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = NO;
-				sleep(5);
-				system("reboot -f");
-			}
-		}
-
-		// 讀卡邏輯
-		ScannerCardProcess();
-
-		for (byte gun_index = 0; gun_index < _gunCount; gun_index++)
-		{
-			CheckGpioInStatus();
-			CheckErrorOccurStatus(gun_index);
-
-			switch(chargingInfo[gun_index]->SystemStatus)
-			{
-				case S_IDLE:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_IDLE================================== %x \n", gun_index);
-						chargingInfo[gun_index]->RemainChargingDuration = 0;
-						chargingInfo[gun_index]->PresentChargedEnergy = 0;
-					}
-
-					if (ShmSysConfigAndInfo->SysStopChargingAlarmCode.Level == 2)
-					{
-						ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_FIX;
-						ClearDetectPluginFlag();
-					}
-					else
-					{
-						// 判斷是否有啟用檢查插槍
-						if(isDetectPlugin())
-						{
-							// 卡號驗證成功後,等待充電槍插入充電車
-							if (chargingInfo[gun_index]->ConnectorPlugIn == YES)
-							{
-								ShmSysConfigAndInfo->SysInfo.CurGunSelected = gun_index;
-								strcpy((char *)chargingInfo[gun_index]->CardNumber, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
-								// 當前操作的槍號,進入 Preparing
-								setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-								ClearDetectPluginFlag();
-								ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-							}
-							else if (!isCardScan)
-							{
-								// LCM => Waiting for plugging
-								ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
-							}
-						}
-						else
-						{
-							if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-								ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
-						}
-					}
-				}
-					break;
-				case S_REASSIGN_CHECK:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_REASSIGN_CHECK================================== %x \n", gun_index);
-						StopSystemTimeoutDet();
-					}
-
-					bool isRessign = false;
-					if (_gunCount > 1)
-					{
-						for (byte index = 0; index < _gunCount; index++)
-						{
-							// 有其他槍已經分配好 psu 模塊
-							if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != index &&
-									chargingInfo[index]->SystemStatus >= S_PREPARNING)
-							{
-								printf("=============Smart Charging============= Step 1 \n");
-								ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_PREPARE;
-								isRessign = true;
-								break;
-							}
-						}
-					}
-
-					if (isRessign)
-						setChargerMode(gun_index, MODE_REASSIGN);
-					else
-						setChargerMode(gun_index, MODE_PRECHARGE);
-				}
-					break;
-				case S_REASSIGN:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_REASSIGN================================== %x \n", gun_index);
-					}
-
-					// 重新分配,此階段主要是讓已經在充電或者準備進入充電前的緩衝
-					// 此狀態下~ 控制權在於 PSU 及 EV小板 Process
-					if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_NONE ||
-							ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_COMP)
-						setChargerMode(gun_index, MODE_PRECHARGE);
-					else if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_RELAY &&
-						ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus == NO)
-					{
-						printf("=============Smart Charging : _REASSIGNED_COMP============= Step 6 \n");
-						ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_COMP;
-					}
-
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
-				}
-					break;
-				case S_PREPARNING:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_PREPARNING================================== %x \n", gun_index);
-						ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
-						StopGunInfoTimeoutDet(gun_index);
-						StartGunInfoTimeoutDet(gun_index, Timeout_Preparing);
-					}
-
-					if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-						ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
-
-					// Precharge 三個流程 : 1 Precharge, 2 Preparing for ev, 3 Preparing for evse
-					// Precharge : AC Contactor <Relay board>, Relay k1 k2 <Relay board>, PSU AddressAssignment, PSU GroupAvailablePower
-					// Preparing for ev : 車端通訊流程
-					// Preparing for evse : PSU (output 500V, 2A), GFD Test <Relay board>
-					//ShmSysConfigAndInfo->SysInfo.AcContactorStatus == YES &&
-					if (((ShmPsuData->SystemPresentPsuQuantity > 0 &&
-							ShmPsuData->PsuGroup[gun_index].GroupPresentPsuQuantity > 0 &&
-							ShmPsuData->PsuGroup[gun_index].GroupAvailablePower > 10) &&
-							chargingInfo[gun_index]->AvailableChargingPower > 10))
-					{
-						setChargerMode(gun_index, MODE_PREPARE_FOR_EV);
-					}
-
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
-				}
-					break;
-				case S_PREPARING_FOR_EV: // 等待車端的通訊 (EV 小板),待車端回報後,開始樁端的測試
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_PREPARING_FOR_EV================================== %x \n", gun_index);
-						strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-						StopGunInfoTimeoutDet(gun_index);
-						StartGunInfoTimeoutDet(gun_index, Timeout_EvChargingDet);
-					}
-
-					if (chargingInfo[gun_index]->Type == _Type_Chademo)
-					{
-						// 檢查車端的槍鎖是否為鎖上
-						if (isEvGunLocked_chademo(gun_index) == YES)
-						{
-							setChargerMode(gun_index, MODE_PREPARE_FOR_EVSE);
-						}
-					}
-					else if (chargingInfo[gun_index]->Type == _Type_CCS)
-					{
-						// 檢查車端的 charging enable 是否為 1
-						if (isEvGunLocked_ccs(gun_index) == YES)
-						{
-							setChargerMode(gun_index, MODE_PREPARE_FOR_EVSE);
-						}
-					}
-
-					if (isEvBoardStopChargeFlag(gun_index) == YES)
-					{
-						// 板端要求停止
-						ChargingTerminalProcess(gun_index);
-					}
-
-					// LCM => Pre-charging
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
-				}
-					break;
-				case S_PREPARING_FOR_EVSE: // 等待 RB 通訊及測試,並將狀態回報, CSU 確認 Pass 後,開始進入充電
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_PREPARING_FOR_EVSE================================== %x \n", gun_index);
-						StopGunInfoTimeoutDet(gun_index);
-						StartGunInfoTimeoutDet(gun_index, Timeout_EvseChargingDet);
-					}
-
-					if (chargingInfo[gun_index]->Type == _Type_Chademo)
-					{
-						// 檢查樁端的 GFD 結果
-						if (isPrechargeStatus_chademo(gun_index) > 5 && isPrechargeStatus_chademo(gun_index) < 8)
-						{
-							// 當前操作的槍號,進入 Charging
-							setChargerMode(gun_index, MODE_CHARGING);
-						}
-					}
-					else if (chargingInfo[gun_index]->Type == _Type_CCS)
-					{
-						// 檢查樁端的 GFD 結果
-						if (chargingInfo[gun_index]->GroundFaultStatus == GFD_PASS)
-						{
-							setChargerMode(gun_index, MODE_CCS_PRECHARGE_STEP0);
-						}
-					}
-
-					if (isEvBoardStopChargeFlag(gun_index) == YES)
-					{
-						// 板端要求停止
-						ChargingTerminalProcess(gun_index);
-					}
-
-					// LCM => Pre-charging
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
-				}
-					break;
-				case S_CHARGING: // 剛進入充電狀態,等待 EV 小板要求的輸出電流後開始輸出
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("S_CHARGING================================== %x \n", gun_index);
-						StopGunInfoTimeoutDet(gun_index);
-						ftime(&startChargingTime[gun_index]);
-					}
-
-					ftime(&endChargingTime[gun_index]);
-					chargingInfo[gun_index]->RemainChargingDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index]);
-
-					if (isEvBoardStopChargeFlag(gun_index) == YES)
-					{
-						// 板端要求停止
-						ChargingTerminalProcess(gun_index);
-					}
-
-					// LCM => Charging
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_CHARGING;
-				}
-					break;
-				case S_TERMINATING:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf ("terminating......................... %x \n", gun_index);
-						StopGunInfoTimeoutDet(gun_index);
-					}
-
-					if (chargingInfo[gun_index]->Type == _Type_Chademo)
-					{
-						// 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
-						if (isEvStopCharging_chademo(gun_index) == YES)
-						{
-							setChargerMode(gun_index, MODE_COMPLETE);
-						}
-					}
-					else if (chargingInfo[gun_index]->Type == _Type_CCS)
-					{
-						// 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
-						if (isEvStopCharging_ccs(gun_index) == YES)
-						{
-							setChargerMode(gun_index, MODE_COMPLETE);
-						}
-					}
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_COMPLETE;
-				}
-					break;
-				case S_COMPLETE:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf ("complete......................... %x \n", gun_index);
-						ftime(&endChargingTime[gun_index]);
-						if (chargingInfo[gun_index]->RemainChargingDuration != 0)
-							chargingInfo[gun_index]->RemainChargingDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index]);
-
-						strcpy((char *)chargingInfo[gun_index]->CardNumber, "");
-						strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-						StopGunInfoTimeoutDet(gun_index);
-						// 測試智能分配,暫時先不要自動回 Idle
-						//StartGunInfoTimeoutDet(gun_index, Timeout_WaitforCompleteDet);
-					}
-
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
-						ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_COMPLETE;
-				}
-					break;
-				case S_CCS_PRECHARGE_ST0:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("CCS Precharge Processing 1....................%x \n", gun_index);
-						StopGunInfoTimeoutDet(gun_index);
-						StartGunInfoTimeoutDet(gun_index, Timeout_ForCcsPrechargeDet);
-					}
-
-					if (isEvBoardStopChargeFlag(gun_index) == YES)
-					{
-						// 板端要求停止
-						ChargingTerminalProcess(gun_index);
-					}
-
-					// 等待 EV 小板 (CCS) 通知可以開始 Precharge
-					// 切換 D+ Relay to Precharge Relay
-					if (isPrechargeStatus_ccs(gun_index) == 39 || isPrechargeStatus_ccs(gun_index) == 40)
-					{
-						if (chargingInfo[gun_index]->RelayKPK2Status == YES && chargingInfo[gun_index]->PrechargeStatus != PRECHARGE_READY)
-						//if (chargingInfo[gun_index]->PrechargeStatus != PRECHARGE_PRERELAY_PASS)
-						{
-							printf("Send precharge ready 1..........%x, status = %d \n", gun_index, isPrechargeStatus_ccs(gun_index));
-							chargingInfo[gun_index]->PrechargeStatus = PRECHARGE_READY;
-						}
-					}
-					else if (isPrechargeStatus_ccs(gun_index) == 45 || isPrechargeStatus_ccs(gun_index) == 46)
-					{
-						setChargerMode(gun_index, MODE_CCS_PRECHARGE_STEP1);
-					}
-
-					break;
-				}
-				case S_CCS_PRECHARGE_ST1:
-				{
-					if (isModeChange(gun_index))
-					{
-						printf("CCS Precharge Processing 2....................%x \n", gun_index);
-					}
-
-					if (isEvBoardStopChargeFlag(gun_index) == YES)
-					{
-						// 板端要求停止
-						ChargingTerminalProcess(gun_index);
-					}
-
-					// 等待小板通知進入充電
-					// 切換 D+ Relay to Precharge Relay
-					if (chargingInfo[gun_index]->RelayK1K2Status == YES)
-					{
-						chargingInfo[gun_index]->PrechargeStatus = PRECHARGE_READY;
-						setChargerMode(gun_index, MODE_CHARGING);
-					}
-					break;
-				}
-			}
-		}
-
-		if (ShmSysConfigAndInfo->SysInfo.SystemPage != _LCM_NONE)
-			ChangeLcmByIndex(ShmSysConfigAndInfo->SysInfo.SystemPage);
-		else
-			ChangeLcmByIndex(ShmSysConfigAndInfo->SysInfo.ConnectorPage);
-
-		usleep(whileLoopTime);
-	}
-
-	return FAIL;
-}

+ 0 - 5
EVSE/Projects/DS60-120/Apps/timeout.c

@@ -1,5 +0,0 @@
-#include "timeout.h"
-
-//===============================================
-// Initial Callback function
-//===============================================

+ 0 - 52
EVSE/Projects/DS60-120/Apps/timeout.h

@@ -1,52 +0,0 @@
-#ifndef TIMEOUT_H_
-#define TIMEOUT_H_
-
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<linux/can.h>
-#include 	<linux/can/raw.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>
-#include    <stdlib.h>
-#include    <unistd.h>
-#include    <fcntl.h>
-#include    <termios.h>
-#include    <errno.h>
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-
-enum Timeout_flag
-{
-	Timeout_None =					0,
-	Timeout_SelftestChk = 			1,
-	Timeout_Authorizing = 			2,
-	Timeout_VerifyFail = 			3,
-	Timeout_VerifyComp = 			4,
-	Timeout_WaitPlug = 				5,
-
-	Timeout_Preparing = 			6,
-	Timeout_EvChargingDet = 		7,
-	Timeout_EvseChargingDet = 		8,
-	Timeout_WaitforCompleteDet = 	9,
-
-	Timeout_ForCcsPrechargeDet = 	10,
-};
-
-#endif /* TIMEOUT_H_ */

+ 297 - 297
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_System.map

@@ -34652,302 +34652,302 @@ c0a00000 R __start_rodata
 c0a00000 A __start_rodata_section_aligned
 c0a00000 R _etext
 c0a00010 R linux_proc_banner
-c0a0006c R linux_banner
-c0a00104 r __func__.5825
-c0a00114 r sqrt_oddadjust
-c0a00134 r sqrt_evenadjust
-c0a00154 r __func__.5807
-c0a00164 r cc_map
-c0a00184 r isa_modes
-c0a00194 r processor_modes
-c0a00214 r sigpage_mapping
-c0a00224 r regoffset_table
-c0a002bc r user_arm_view
-c0a002d0 r arm_regsets
-c0a0033c r hwcap_str
-c0a00398 r hwcap2_str
-c0a003b0 r proc_arch
-c0a003f4 R cpuinfo_op
-c0a00404 R sigreturn_codes
-c0a00420 r handler
-c0a00434 r atags_fops
-c0a004ac r pmresrn_table.31150
-c0a004bc r pmresrn_table.31002
-c0a004c8 r scorpion_perf_cache_map
-c0a00570 r scorpion_perf_map
-c0a00598 r krait_perf_cache_map
-c0a00640 r krait_perf_map
-c0a00668 r krait_perf_map_no_branch
-c0a00690 r armv7_a5_perf_cache_map
-c0a00738 r armv7_a5_perf_map
-c0a00760 r armv7_a7_perf_cache_map
-c0a00808 r armv7_a7_perf_map
-c0a00830 r armv7_a8_perf_cache_map
-c0a008d8 r armv7_a8_perf_map
-c0a00900 r armv7_a9_perf_cache_map
-c0a009a8 r armv7_a9_perf_map
-c0a009d0 r armv7_a12_perf_cache_map
-c0a00a78 r armv7_a12_perf_map
-c0a00aa0 r armv7_a15_perf_cache_map
-c0a00b48 r armv7_a15_perf_map
-c0a00b70 r armv7_pmu_probe_table
-c0a00b94 r armv7_pmu_of_device_ids
-c0a01400 r usermode_action
-c0a01418 r alignment_proc_fops
-c0a01490 r subset.21772
-c0a014b0 r subset.21782
-c0a014c0 r __param_str_alignment
-c0a014cc r cpu_arch_name
-c0a014d2 r cpu_elf_name
-c0a014d8 r l2c220_data
-c0a01520 r omap_types
-c0a01534 r __func__.28508
-c0a0154c r __func__.29284
-c0a0156c r __func__.29289
-c0a0158c r am33xx_control_reg_offsets
-c0a0164c r am43xx_control_reg_offsets
-c0a01728 r omap_scrm_dt_match_table
-c0a01ed0 r omap2_ctrl_data
-c0a01ed8 r omap_mux_dbg_signal_fops
-c0a01f50 r omap_mux_dbg_board_fops
-c0a01fc8 r __func__.28699
-c0a01fdc r __func__.28741
-c0a01ff4 r __func__.28758
-c0a0200c r __func__.28788
-c0a02020 r __func__.29075
-c0a02034 r __func__.29089
-c0a02048 r __func__.29126
-c0a02058 r __func__.29002
-c0a02070 r __func__.29015
-c0a0208c r __func__.29102
-c0a020a0 r __func__.30036
-c0a020c0 r __func__.30084
-c0a020d4 r __func__.30078
-c0a020e4 r __func__.36712
-c0a020f8 r omap_pm_ops
-c0a02120 r reg_map
-c0a021f4 r __func__.31257
-c0a02210 r __func__.27253
-c0a02228 r __func__.27271
-c0a02240 r __func__.28011
-c0a02250 r name
-c0a0225c r __func__.27252
-c0a02270 r __func__.36709
-c0a02280 r modck.36708
-c0a02288 r __func__.37246
-c0a022a4 r __func__.28074
-c0a022bc r __func__.28070
-c0a022d8 r __func__.28103
-c0a022ec r __func__.28109
-c0a02300 r __func__.28161
-c0a02318 r __func__.28135
-c0a02338 r __func__.25577
-c0a0234c r __func__.23975
-c0a0236c r __func__.23985
-c0a02388 r __func__.30938
-c0a02398 r debug_fops
-c0a02410 r pm_dbg_option_fops
-c0a02488 r pwrdm_suspend_fops
-c0a02500 r pwrdm_state_names
-c0a02510 r __func__.30154
-c0a02528 r __func__.30166
-c0a02548 r __func__.30177
-c0a0256c r __func__.30189
-c0a02588 r __func__.30203
-c0a025a4 r __func__.30215
-c0a025c4 r __func__.30227
-c0a025dc r __func__.30239
-c0a025f4 r __func__.30248
-c0a02610 r __func__.30257
-c0a0262c r __func__.19941
-c0a02640 r __func__.19953
-c0a0265c r __func__.19965
-c0a02678 r __func__.19977
-c0a02690 r __func__.19988
-c0a026a8 r __func__.28041
-c0a026bc r __func__.28049
-c0a026cc r __func__.28057
-c0a026dc r __func__.28062
-c0a026f8 r __func__.28068
-c0a02714 r __func__.28076
-c0a02730 r __func__.28081
-c0a02748 r __func__.14518
-c0a0275c r __func__.14345
-c0a02770 r __func__.14379
-c0a02788 r __func__.14532
-c0a027a0 r __func__.14512
-c0a027b4 r __func__.27364
-c0a027c4 r __func__.27389
-c0a027e0 r __func__.27402
-c0a027f0 r __func__.27409
-c0a02800 r __func__.34357
-c0a02818 r __func__.34364
-c0a02838 r __func__.27872
-c0a0284c r __func__.29301
-c0a0285c r __func__.36945
-c0a02870 r __func__.36957
-c0a02880 r __func__.36800
-c0a02894 r __func__.26969
-c0a028ac r __func__.26938
-c0a028c4 r __func__.26928
-c0a028d8 r omap_timer_match
-c0a02ef8 r __func__.27014
-c0a02f0c r __func__.26797
-c0a02f24 r __func__.26943
-c0a02f40 r __func__.26966
-c0a02f5c r __func__.26977
-c0a02f78 r CSWTCH.92
-c0a02f84 r __func__.26836
-c0a02fa0 r __func__.26648
-c0a02fbc r __func__.26712
-c0a02fdc r omap3plus_pdata
-c0a02ff0 r execdomains_proc_fops
-c0a03068 r tnts
-c0a03098 r __param_str_crash_kexec_post_notifiers
-c0a030b4 r __param_str_panic_on_warn
-c0a030c4 r __param_str_pause_on_oops
-c0a030d4 r __param_str_panic
-c0a030dc R cpu_all_bits
-c0a030e0 R cpu_bit_bitmap
-c0a03164 R softirq_to_name
-c0a0318c r resource_op
-c0a0319c r proc_ioports_operations
-c0a03214 r proc_iomem_operations
-c0a0328c r proc_wspace_sep
-c0a03298 r cap_last_cap
-c0a0329c r __func__.47089
-c0a032b8 R __cap_empty_set
-c0a032c0 r __func__.40750
-c0a032d8 r offsets.39360
-c0a032e4 r wq_sysfs_group
-c0a032f8 r __param_str_debug_force_rr_cpu
-c0a03318 r __param_str_power_efficient
-c0a03334 r __param_str_disable_numa
-c0a0334c r module_uevent_ops
-c0a03358 r module_sysfs_ops
-c0a03360 R param_ops_string
-c0a03370 R param_array_ops
-c0a03380 R param_ops_bint
-c0a03390 R param_ops_invbool
-c0a033a0 R param_ops_bool_enable_only
-c0a033b0 R param_ops_bool
-c0a033c0 R param_ops_charp
-c0a033d0 R param_ops_ullong
-c0a033e0 R param_ops_ulong
-c0a033f0 R param_ops_long
-c0a03400 R param_ops_uint
-c0a03410 R param_ops_int
-c0a03420 R param_ops_ushort
-c0a03430 R param_ops_short
-c0a03440 R param_ops_byte
-c0a03450 r param.26429
-c0a03454 r reboot_cmd
-c0a03464 r __func__.5705
-c0a03478 R sched_prio_to_weight
-c0a03518 R sched_prio_to_wmult
-c0a035b8 r stat_nam
-c0a035c8 R min_cfs_quota_period
-c0a035d0 R max_cfs_quota_period
-c0a035d8 R idle_sched_class
-c0a03620 R fair_sched_class
-c0a03668 R rt_sched_class
-c0a036b0 R dl_sched_class
-c0a036f8 R stop_sched_class
-c0a03740 r schedstat_sops
-c0a03750 r proc_schedstat_operations
-c0a037c8 r sched_feat_fops
-c0a03840 r sched_feat_names
-c0a03880 r sched_debug_sops
-c0a03890 r sched_debug_fops
-c0a03908 r sched_tunable_scaling_names
-c0a03914 r pm_qos_array
-c0a03928 r pm_qos_power_fops
-c0a039a0 r pm_qos_debug_fops
-c0a03a18 r CSWTCH.162
-c0a03a24 r __func__.31252
-c0a03a40 r __func__.31395
-c0a03a60 r suspend_stats_operations
-c0a03ad8 r CSWTCH.48
-c0a03af8 r pm_tests
-c0a03b10 r __param_str_pm_test_delay
-c0a03b28 r trunc_msg
-c0a03b34 r recursion_msg.36570
-c0a03b54 r __param_str_always_kmsg_dump
-c0a03b6c r __param_str_console_suspend
-c0a03b84 r __param_str_time
-c0a03b90 r __param_str_ignore_loglevel
-c0a03ba8 R kmsg_fops
-c0a03c20 r __param_str_irqfixup
-c0a03c34 r __param_str_noirqdebug
-c0a03c48 r __func__.26206
-c0a03c5c R irq_domain_simple_ops
-c0a03c84 r irq_spurious_proc_fops
-c0a03cfc r msi_domain_ops
-c0a03d24 r __param_str_rcu_cpu_stall_timeout
-c0a03d44 r __param_str_rcu_cpu_stall_suppress
-c0a03d64 r __param_str_rcu_normal_after_boot
-c0a03d84 r __param_str_rcu_normal
-c0a03d98 r __param_str_rcu_expedited
-c0a03db0 r gp_ops
-c0a03dd4 r CSWTCH.367
-c0a03de0 r gp_state_names
-c0a03dfc r __param_str_jiffies_till_sched_qs
-c0a03e1c r __param_str_rcu_kick_kthreads
-c0a03e38 r __param_str_jiffies_till_next_fqs
-c0a03e58 r __param_str_jiffies_till_first_fqs
-c0a03e78 r __param_str_qlowmark
-c0a03e8c r __param_str_qhimark
-c0a03e9c r __param_str_blimit
-c0a03eac r __param_str_kthread_prio
-c0a03ec4 r __param_str_rcu_fanout_leaf
-c0a03edc r __param_str_rcu_fanout_exact
-c0a03ef8 r __param_str_dump_tree
-c0a03f0c r hrtimer_clock_to_base_table
-c0a03f74 r offsets
-c0a03f80 r timer_list_sops
-c0a03f90 r timer_list_fops
-c0a04008 r __mon_yday
-c0a0403c r posix_clock_file_operations
-c0a040b4 r alarmtimer_pm_ops
-c0a04110 r __param_str_irqtime
-c0a04118 r tk_debug_sleep_time_fops
-c0a04190 r modules_op
-c0a041a0 r proc_modules_operations
-c0a04218 r arr.33985
-c0a04254 r __func__.35164
-c0a04264 r vermagic
-c0a042a4 r masks.34837
-c0a042cc r modinfo_attrs
-c0a042f0 r __param_str_module_blacklist
-c0a04304 r __param_str_nomodule
-c0a04310 r __param_str_sig_enforce
-c0a04324 r kallsyms_op
-c0a04334 r kallsyms_operations
-c0a043ac r __func__.53625
-c0a043c0 r cgroup_subsys
-c0a043e0 r cgroup_subsys_enabled_key
-c0a04400 r cgroup_subsys_on_dfl_key
-c0a04420 r cgroup_subsys_name
-c0a04440 r proc_cgroupstats_operations
-c0a044b8 R cgroupns_operations
-c0a044d4 R utsns_operations
-c0a044f0 R pidns_operations
-c0a0450c r kernel_config_data
-c0a0bb88 r ikconfig_file_ops
-c0a0bc00 r mode1_syscalls
-c0a0bc14 r jumptable.45554
-c0a0c014 r __func__.45734
-c0a0c024 R bpf_tail_call_proto
-c0a0c044 r __func__.50754
-c0a0c058 r perf_mmap_vmops
-c0a0c084 r perf_fops
-c0a0c0fc r if_tokens
-c0a0c13c r pmu_dev_group
-c0a0c150 r __func__.24217
-c0a0c16c r __func__.24230
-c0a0c184 r __func__.24138
-c0a0c198 r __func__.24193
-c0a0c1ac r __func__.24205
+c0a00068 R linux_banner
+c0a000fc r __func__.5825
+c0a0010c r sqrt_oddadjust
+c0a0012c r sqrt_evenadjust
+c0a0014c r __func__.5807
+c0a0015c r cc_map
+c0a0017c r isa_modes
+c0a0018c r processor_modes
+c0a0020c r sigpage_mapping
+c0a0021c r regoffset_table
+c0a002b4 r user_arm_view
+c0a002c8 r arm_regsets
+c0a00334 r hwcap_str
+c0a00390 r hwcap2_str
+c0a003a8 r proc_arch
+c0a003ec R cpuinfo_op
+c0a003fc R sigreturn_codes
+c0a00418 r handler
+c0a0042c r atags_fops
+c0a004a4 r pmresrn_table.31150
+c0a004b4 r pmresrn_table.31002
+c0a004c0 r scorpion_perf_cache_map
+c0a00568 r scorpion_perf_map
+c0a00590 r krait_perf_cache_map
+c0a00638 r krait_perf_map
+c0a00660 r krait_perf_map_no_branch
+c0a00688 r armv7_a5_perf_cache_map
+c0a00730 r armv7_a5_perf_map
+c0a00758 r armv7_a7_perf_cache_map
+c0a00800 r armv7_a7_perf_map
+c0a00828 r armv7_a8_perf_cache_map
+c0a008d0 r armv7_a8_perf_map
+c0a008f8 r armv7_a9_perf_cache_map
+c0a009a0 r armv7_a9_perf_map
+c0a009c8 r armv7_a12_perf_cache_map
+c0a00a70 r armv7_a12_perf_map
+c0a00a98 r armv7_a15_perf_cache_map
+c0a00b40 r armv7_a15_perf_map
+c0a00b68 r armv7_pmu_probe_table
+c0a00b8c r armv7_pmu_of_device_ids
+c0a013f8 r usermode_action
+c0a01410 r alignment_proc_fops
+c0a01488 r subset.21772
+c0a014a8 r subset.21782
+c0a014b8 r __param_str_alignment
+c0a014c4 r cpu_arch_name
+c0a014ca r cpu_elf_name
+c0a014d0 r l2c220_data
+c0a01518 r omap_types
+c0a0152c r __func__.28508
+c0a01544 r __func__.29284
+c0a01564 r __func__.29289
+c0a01584 r am33xx_control_reg_offsets
+c0a01644 r am43xx_control_reg_offsets
+c0a01720 r omap_scrm_dt_match_table
+c0a01ec8 r omap2_ctrl_data
+c0a01ed0 r omap_mux_dbg_signal_fops
+c0a01f48 r omap_mux_dbg_board_fops
+c0a01fc0 r __func__.28699
+c0a01fd4 r __func__.28741
+c0a01fec r __func__.28758
+c0a02004 r __func__.28788
+c0a02018 r __func__.29075
+c0a0202c r __func__.29089
+c0a02040 r __func__.29126
+c0a02050 r __func__.29002
+c0a02068 r __func__.29015
+c0a02084 r __func__.29102
+c0a02098 r __func__.30036
+c0a020b8 r __func__.30084
+c0a020cc r __func__.30078
+c0a020dc r __func__.36712
+c0a020f0 r omap_pm_ops
+c0a02118 r reg_map
+c0a021ec r __func__.31257
+c0a02208 r __func__.27253
+c0a02220 r __func__.27271
+c0a02238 r __func__.28011
+c0a02248 r name
+c0a02254 r __func__.27252
+c0a02268 r __func__.36709
+c0a02278 r modck.36708
+c0a02280 r __func__.37246
+c0a0229c r __func__.28074
+c0a022b4 r __func__.28070
+c0a022d0 r __func__.28103
+c0a022e4 r __func__.28109
+c0a022f8 r __func__.28161
+c0a02310 r __func__.28135
+c0a02330 r __func__.25577
+c0a02344 r __func__.23975
+c0a02364 r __func__.23985
+c0a02380 r __func__.30938
+c0a02390 r debug_fops
+c0a02408 r pm_dbg_option_fops
+c0a02480 r pwrdm_suspend_fops
+c0a024f8 r pwrdm_state_names
+c0a02508 r __func__.30154
+c0a02520 r __func__.30166
+c0a02540 r __func__.30177
+c0a02564 r __func__.30189
+c0a02580 r __func__.30203
+c0a0259c r __func__.30215
+c0a025bc r __func__.30227
+c0a025d4 r __func__.30239
+c0a025ec r __func__.30248
+c0a02608 r __func__.30257
+c0a02624 r __func__.19941
+c0a02638 r __func__.19953
+c0a02654 r __func__.19965
+c0a02670 r __func__.19977
+c0a02688 r __func__.19988
+c0a026a0 r __func__.28041
+c0a026b4 r __func__.28049
+c0a026c4 r __func__.28057
+c0a026d4 r __func__.28062
+c0a026f0 r __func__.28068
+c0a0270c r __func__.28076
+c0a02728 r __func__.28081
+c0a02740 r __func__.14518
+c0a02754 r __func__.14345
+c0a02768 r __func__.14379
+c0a02780 r __func__.14532
+c0a02798 r __func__.14512
+c0a027ac r __func__.27364
+c0a027bc r __func__.27389
+c0a027d8 r __func__.27402
+c0a027e8 r __func__.27409
+c0a027f8 r __func__.34357
+c0a02810 r __func__.34364
+c0a02830 r __func__.27872
+c0a02844 r __func__.29301
+c0a02854 r __func__.36945
+c0a02868 r __func__.36957
+c0a02878 r __func__.36800
+c0a0288c r __func__.26969
+c0a028a4 r __func__.26938
+c0a028bc r __func__.26928
+c0a028d0 r omap_timer_match
+c0a02ef0 r __func__.27014
+c0a02f04 r __func__.26797
+c0a02f1c r __func__.26943
+c0a02f38 r __func__.26966
+c0a02f54 r __func__.26977
+c0a02f70 r CSWTCH.92
+c0a02f7c r __func__.26836
+c0a02f98 r __func__.26648
+c0a02fb4 r __func__.26712
+c0a02fd4 r omap3plus_pdata
+c0a02fe8 r execdomains_proc_fops
+c0a03060 r tnts
+c0a03090 r __param_str_crash_kexec_post_notifiers
+c0a030ac r __param_str_panic_on_warn
+c0a030bc r __param_str_pause_on_oops
+c0a030cc r __param_str_panic
+c0a030d4 R cpu_all_bits
+c0a030d8 R cpu_bit_bitmap
+c0a0315c R softirq_to_name
+c0a03184 r resource_op
+c0a03194 r proc_ioports_operations
+c0a0320c r proc_iomem_operations
+c0a03284 r proc_wspace_sep
+c0a03290 r cap_last_cap
+c0a03294 r __func__.47089
+c0a032b0 R __cap_empty_set
+c0a032b8 r __func__.40750
+c0a032d0 r offsets.39360
+c0a032dc r wq_sysfs_group
+c0a032f0 r __param_str_debug_force_rr_cpu
+c0a03310 r __param_str_power_efficient
+c0a0332c r __param_str_disable_numa
+c0a03344 r module_uevent_ops
+c0a03350 r module_sysfs_ops
+c0a03358 R param_ops_string
+c0a03368 R param_array_ops
+c0a03378 R param_ops_bint
+c0a03388 R param_ops_invbool
+c0a03398 R param_ops_bool_enable_only
+c0a033a8 R param_ops_bool
+c0a033b8 R param_ops_charp
+c0a033c8 R param_ops_ullong
+c0a033d8 R param_ops_ulong
+c0a033e8 R param_ops_long
+c0a033f8 R param_ops_uint
+c0a03408 R param_ops_int
+c0a03418 R param_ops_ushort
+c0a03428 R param_ops_short
+c0a03438 R param_ops_byte
+c0a03448 r param.26429
+c0a0344c r reboot_cmd
+c0a0345c r __func__.5705
+c0a03470 R sched_prio_to_weight
+c0a03510 R sched_prio_to_wmult
+c0a035b0 r stat_nam
+c0a035c0 R min_cfs_quota_period
+c0a035c8 R max_cfs_quota_period
+c0a035d0 R idle_sched_class
+c0a03618 R fair_sched_class
+c0a03660 R rt_sched_class
+c0a036a8 R dl_sched_class
+c0a036f0 R stop_sched_class
+c0a03738 r schedstat_sops
+c0a03748 r proc_schedstat_operations
+c0a037c0 r sched_feat_fops
+c0a03838 r sched_feat_names
+c0a03878 r sched_debug_sops
+c0a03888 r sched_debug_fops
+c0a03900 r sched_tunable_scaling_names
+c0a0390c r pm_qos_array
+c0a03920 r pm_qos_power_fops
+c0a03998 r pm_qos_debug_fops
+c0a03a10 r CSWTCH.162
+c0a03a1c r __func__.31252
+c0a03a38 r __func__.31395
+c0a03a58 r suspend_stats_operations
+c0a03ad0 r CSWTCH.48
+c0a03af0 r pm_tests
+c0a03b08 r __param_str_pm_test_delay
+c0a03b20 r trunc_msg
+c0a03b2c r recursion_msg.36570
+c0a03b4c r __param_str_always_kmsg_dump
+c0a03b64 r __param_str_console_suspend
+c0a03b7c r __param_str_time
+c0a03b88 r __param_str_ignore_loglevel
+c0a03ba0 R kmsg_fops
+c0a03c18 r __param_str_irqfixup
+c0a03c2c r __param_str_noirqdebug
+c0a03c40 r __func__.26206
+c0a03c54 R irq_domain_simple_ops
+c0a03c7c r irq_spurious_proc_fops
+c0a03cf4 r msi_domain_ops
+c0a03d1c r __param_str_rcu_cpu_stall_timeout
+c0a03d3c r __param_str_rcu_cpu_stall_suppress
+c0a03d5c r __param_str_rcu_normal_after_boot
+c0a03d7c r __param_str_rcu_normal
+c0a03d90 r __param_str_rcu_expedited
+c0a03da8 r gp_ops
+c0a03dcc r CSWTCH.367
+c0a03dd8 r gp_state_names
+c0a03df4 r __param_str_jiffies_till_sched_qs
+c0a03e14 r __param_str_rcu_kick_kthreads
+c0a03e30 r __param_str_jiffies_till_next_fqs
+c0a03e50 r __param_str_jiffies_till_first_fqs
+c0a03e70 r __param_str_qlowmark
+c0a03e84 r __param_str_qhimark
+c0a03e94 r __param_str_blimit
+c0a03ea4 r __param_str_kthread_prio
+c0a03ebc r __param_str_rcu_fanout_leaf
+c0a03ed4 r __param_str_rcu_fanout_exact
+c0a03ef0 r __param_str_dump_tree
+c0a03f04 r hrtimer_clock_to_base_table
+c0a03f6c r offsets
+c0a03f78 r timer_list_sops
+c0a03f88 r timer_list_fops
+c0a04000 r __mon_yday
+c0a04034 r posix_clock_file_operations
+c0a040ac r alarmtimer_pm_ops
+c0a04108 r __param_str_irqtime
+c0a04110 r tk_debug_sleep_time_fops
+c0a04188 r modules_op
+c0a04198 r proc_modules_operations
+c0a04210 r arr.33985
+c0a0424c r __func__.35164
+c0a0425c r vermagic
+c0a0429c r masks.34837
+c0a042c4 r modinfo_attrs
+c0a042e8 r __param_str_module_blacklist
+c0a042fc r __param_str_nomodule
+c0a04308 r __param_str_sig_enforce
+c0a0431c r kallsyms_op
+c0a0432c r kallsyms_operations
+c0a043a4 r __func__.53625
+c0a043b8 r cgroup_subsys
+c0a043d8 r cgroup_subsys_enabled_key
+c0a043f8 r cgroup_subsys_on_dfl_key
+c0a04418 r cgroup_subsys_name
+c0a04438 r proc_cgroupstats_operations
+c0a044b0 R cgroupns_operations
+c0a044cc R utsns_operations
+c0a044e8 R pidns_operations
+c0a04504 r kernel_config_data
+c0a0bb80 r ikconfig_file_ops
+c0a0bbf8 r mode1_syscalls
+c0a0bc0c r jumptable.45554
+c0a0c00c r __func__.45734
+c0a0c01c R bpf_tail_call_proto
+c0a0c03c r __func__.50754
+c0a0c050 r perf_mmap_vmops
+c0a0c07c r perf_fops
+c0a0c0f4 r if_tokens
+c0a0c134 r pmu_dev_group
+c0a0c148 r __func__.24217
+c0a0c164 r __func__.24230
+c0a0c17c r __func__.24138
+c0a0c190 r __func__.24193
+c0a0c1a4 r __func__.24205
 c0a0c200 R generic_file_vm_ops
 c0a0c22c r __func__.32733
 c0a0c240 r fallbacks
@@ -70428,7 +70428,7 @@ c0d4b850 T __initramfs_start
 c0d4b850 t __irf_start
 c0d4b850 T __security_initcall_end
 c0d4b850 T __security_initcall_start
-c0d4b8d6 t __irf_end
+c0d4b8d7 t __irf_end
 c0d4b8d8 T __initramfs_size
 c0e00000 D __data_loc
 c0e00000 D __init_end

+ 289 - 289
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_kallsyms1.S

@@ -34660,302 +34660,302 @@ kallsyms_offsets:
 	.long	0x9f8000
 	.long	0x9f8000
 	.long	0x9f8010
-	.long	0x9f806c
-	.long	0x9f8104
-	.long	0x9f8114
-	.long	0x9f8134
-	.long	0x9f8154
-	.long	0x9f8164
-	.long	0x9f8184
-	.long	0x9f8194
-	.long	0x9f8214
-	.long	0x9f8224
-	.long	0x9f82bc
-	.long	0x9f82d0
-	.long	0x9f833c
-	.long	0x9f8398
-	.long	0x9f83b0
-	.long	0x9f83f4
-	.long	0x9f8404
-	.long	0x9f8420
-	.long	0x9f8434
-	.long	0x9f84ac
-	.long	0x9f84bc
-	.long	0x9f84c8
-	.long	0x9f8570
-	.long	0x9f8598
-	.long	0x9f8640
-	.long	0x9f8668
-	.long	0x9f8690
-	.long	0x9f8738
-	.long	0x9f8760
-	.long	0x9f8808
-	.long	0x9f8830
-	.long	0x9f88d8
-	.long	0x9f8900
-	.long	0x9f89a8
-	.long	0x9f89d0
-	.long	0x9f8a78
-	.long	0x9f8aa0
-	.long	0x9f8b48
-	.long	0x9f8b70
-	.long	0x9f8b94
-	.long	0x9f9400
-	.long	0x9f9418
-	.long	0x9f9490
-	.long	0x9f94b0
-	.long	0x9f94c0
-	.long	0x9f94cc
-	.long	0x9f94d2
-	.long	0x9f94d8
-	.long	0x9f9520
-	.long	0x9f9534
-	.long	0x9f954c
-	.long	0x9f956c
-	.long	0x9f958c
-	.long	0x9f964c
-	.long	0x9f9728
+	.long	0x9f8068
+	.long	0x9f80fc
+	.long	0x9f810c
+	.long	0x9f812c
+	.long	0x9f814c
+	.long	0x9f815c
+	.long	0x9f817c
+	.long	0x9f818c
+	.long	0x9f820c
+	.long	0x9f821c
+	.long	0x9f82b4
+	.long	0x9f82c8
+	.long	0x9f8334
+	.long	0x9f8390
+	.long	0x9f83a8
+	.long	0x9f83ec
+	.long	0x9f83fc
+	.long	0x9f8418
+	.long	0x9f842c
+	.long	0x9f84a4
+	.long	0x9f84b4
+	.long	0x9f84c0
+	.long	0x9f8568
+	.long	0x9f8590
+	.long	0x9f8638
+	.long	0x9f8660
+	.long	0x9f8688
+	.long	0x9f8730
+	.long	0x9f8758
+	.long	0x9f8800
+	.long	0x9f8828
+	.long	0x9f88d0
+	.long	0x9f88f8
+	.long	0x9f89a0
+	.long	0x9f89c8
+	.long	0x9f8a70
+	.long	0x9f8a98
+	.long	0x9f8b40
+	.long	0x9f8b68
+	.long	0x9f8b8c
+	.long	0x9f93f8
+	.long	0x9f9410
+	.long	0x9f9488
+	.long	0x9f94a8
+	.long	0x9f94b8
+	.long	0x9f94c4
+	.long	0x9f94ca
+	.long	0x9f94d0
+	.long	0x9f9518
+	.long	0x9f952c
+	.long	0x9f9544
+	.long	0x9f9564
+	.long	0x9f9584
+	.long	0x9f9644
+	.long	0x9f9720
+	.long	0x9f9ec8
 	.long	0x9f9ed0
-	.long	0x9f9ed8
-	.long	0x9f9f50
-	.long	0x9f9fc8
-	.long	0x9f9fdc
-	.long	0x9f9ff4
-	.long	0x9fa00c
-	.long	0x9fa020
-	.long	0x9fa034
-	.long	0x9fa048
-	.long	0x9fa058
-	.long	0x9fa070
-	.long	0x9fa08c
-	.long	0x9fa0a0
-	.long	0x9fa0c0
-	.long	0x9fa0d4
-	.long	0x9fa0e4
-	.long	0x9fa0f8
-	.long	0x9fa120
-	.long	0x9fa1f4
-	.long	0x9fa210
-	.long	0x9fa228
-	.long	0x9fa240
-	.long	0x9fa250
-	.long	0x9fa25c
-	.long	0x9fa270
+	.long	0x9f9f48
+	.long	0x9f9fc0
+	.long	0x9f9fd4
+	.long	0x9f9fec
+	.long	0x9fa004
+	.long	0x9fa018
+	.long	0x9fa02c
+	.long	0x9fa040
+	.long	0x9fa050
+	.long	0x9fa068
+	.long	0x9fa084
+	.long	0x9fa098
+	.long	0x9fa0b8
+	.long	0x9fa0cc
+	.long	0x9fa0dc
+	.long	0x9fa0f0
+	.long	0x9fa118
+	.long	0x9fa1ec
+	.long	0x9fa208
+	.long	0x9fa220
+	.long	0x9fa238
+	.long	0x9fa248
+	.long	0x9fa254
+	.long	0x9fa268
+	.long	0x9fa278
 	.long	0x9fa280
-	.long	0x9fa288
-	.long	0x9fa2a4
-	.long	0x9fa2bc
-	.long	0x9fa2d8
-	.long	0x9fa2ec
-	.long	0x9fa300
-	.long	0x9fa318
-	.long	0x9fa338
-	.long	0x9fa34c
-	.long	0x9fa36c
-	.long	0x9fa388
-	.long	0x9fa398
-	.long	0x9fa410
-	.long	0x9fa488
-	.long	0x9fa500
-	.long	0x9fa510
-	.long	0x9fa528
-	.long	0x9fa548
-	.long	0x9fa56c
-	.long	0x9fa588
-	.long	0x9fa5a4
-	.long	0x9fa5c4
-	.long	0x9fa5dc
-	.long	0x9fa5f4
-	.long	0x9fa610
-	.long	0x9fa62c
-	.long	0x9fa640
-	.long	0x9fa65c
-	.long	0x9fa678
-	.long	0x9fa690
-	.long	0x9fa6a8
-	.long	0x9fa6bc
-	.long	0x9fa6cc
-	.long	0x9fa6dc
-	.long	0x9fa6f8
-	.long	0x9fa714
-	.long	0x9fa730
-	.long	0x9fa748
-	.long	0x9fa75c
-	.long	0x9fa770
-	.long	0x9fa788
-	.long	0x9fa7a0
-	.long	0x9fa7b4
-	.long	0x9fa7c4
-	.long	0x9fa7e0
-	.long	0x9fa7f0
-	.long	0x9fa800
-	.long	0x9fa818
-	.long	0x9fa838
-	.long	0x9fa84c
-	.long	0x9fa85c
-	.long	0x9fa870
-	.long	0x9fa880
-	.long	0x9fa894
-	.long	0x9fa8ac
-	.long	0x9fa8c4
-	.long	0x9fa8d8
-	.long	0x9faef8
-	.long	0x9faf0c
-	.long	0x9faf24
-	.long	0x9faf40
-	.long	0x9faf5c
-	.long	0x9faf78
-	.long	0x9faf84
-	.long	0x9fafa0
-	.long	0x9fafbc
-	.long	0x9fafdc
-	.long	0x9faff0
-	.long	0x9fb068
-	.long	0x9fb098
-	.long	0x9fb0b4
-	.long	0x9fb0c4
+	.long	0x9fa29c
+	.long	0x9fa2b4
+	.long	0x9fa2d0
+	.long	0x9fa2e4
+	.long	0x9fa2f8
+	.long	0x9fa310
+	.long	0x9fa330
+	.long	0x9fa344
+	.long	0x9fa364
+	.long	0x9fa380
+	.long	0x9fa390
+	.long	0x9fa408
+	.long	0x9fa480
+	.long	0x9fa4f8
+	.long	0x9fa508
+	.long	0x9fa520
+	.long	0x9fa540
+	.long	0x9fa564
+	.long	0x9fa580
+	.long	0x9fa59c
+	.long	0x9fa5bc
+	.long	0x9fa5d4
+	.long	0x9fa5ec
+	.long	0x9fa608
+	.long	0x9fa624
+	.long	0x9fa638
+	.long	0x9fa654
+	.long	0x9fa670
+	.long	0x9fa688
+	.long	0x9fa6a0
+	.long	0x9fa6b4
+	.long	0x9fa6c4
+	.long	0x9fa6d4
+	.long	0x9fa6f0
+	.long	0x9fa70c
+	.long	0x9fa728
+	.long	0x9fa740
+	.long	0x9fa754
+	.long	0x9fa768
+	.long	0x9fa780
+	.long	0x9fa798
+	.long	0x9fa7ac
+	.long	0x9fa7bc
+	.long	0x9fa7d8
+	.long	0x9fa7e8
+	.long	0x9fa7f8
+	.long	0x9fa810
+	.long	0x9fa830
+	.long	0x9fa844
+	.long	0x9fa854
+	.long	0x9fa868
+	.long	0x9fa878
+	.long	0x9fa88c
+	.long	0x9fa8a4
+	.long	0x9fa8bc
+	.long	0x9fa8d0
+	.long	0x9faef0
+	.long	0x9faf04
+	.long	0x9faf1c
+	.long	0x9faf38
+	.long	0x9faf54
+	.long	0x9faf70
+	.long	0x9faf7c
+	.long	0x9faf98
+	.long	0x9fafb4
+	.long	0x9fafd4
+	.long	0x9fafe8
+	.long	0x9fb060
+	.long	0x9fb090
+	.long	0x9fb0ac
+	.long	0x9fb0bc
+	.long	0x9fb0cc
 	.long	0x9fb0d4
-	.long	0x9fb0dc
-	.long	0x9fb0e0
-	.long	0x9fb164
-	.long	0x9fb18c
-	.long	0x9fb19c
-	.long	0x9fb214
-	.long	0x9fb28c
-	.long	0x9fb298
-	.long	0x9fb29c
+	.long	0x9fb0d8
+	.long	0x9fb15c
+	.long	0x9fb184
+	.long	0x9fb194
+	.long	0x9fb20c
+	.long	0x9fb284
+	.long	0x9fb290
+	.long	0x9fb294
+	.long	0x9fb2b0
 	.long	0x9fb2b8
-	.long	0x9fb2c0
-	.long	0x9fb2d8
-	.long	0x9fb2e4
-	.long	0x9fb2f8
-	.long	0x9fb318
-	.long	0x9fb334
-	.long	0x9fb34c
+	.long	0x9fb2d0
+	.long	0x9fb2dc
+	.long	0x9fb2f0
+	.long	0x9fb310
+	.long	0x9fb32c
+	.long	0x9fb344
+	.long	0x9fb350
 	.long	0x9fb358
-	.long	0x9fb360
-	.long	0x9fb370
-	.long	0x9fb380
-	.long	0x9fb390
-	.long	0x9fb3a0
-	.long	0x9fb3b0
-	.long	0x9fb3c0
-	.long	0x9fb3d0
-	.long	0x9fb3e0
-	.long	0x9fb3f0
-	.long	0x9fb400
-	.long	0x9fb410
-	.long	0x9fb420
-	.long	0x9fb430
-	.long	0x9fb440
-	.long	0x9fb450
-	.long	0x9fb454
-	.long	0x9fb464
-	.long	0x9fb478
-	.long	0x9fb518
-	.long	0x9fb5b8
+	.long	0x9fb368
+	.long	0x9fb378
+	.long	0x9fb388
+	.long	0x9fb398
+	.long	0x9fb3a8
+	.long	0x9fb3b8
+	.long	0x9fb3c8
+	.long	0x9fb3d8
+	.long	0x9fb3e8
+	.long	0x9fb3f8
+	.long	0x9fb408
+	.long	0x9fb418
+	.long	0x9fb428
+	.long	0x9fb438
+	.long	0x9fb448
+	.long	0x9fb44c
+	.long	0x9fb45c
+	.long	0x9fb470
+	.long	0x9fb510
+	.long	0x9fb5b0
+	.long	0x9fb5c0
 	.long	0x9fb5c8
 	.long	0x9fb5d0
-	.long	0x9fb5d8
-	.long	0x9fb620
-	.long	0x9fb668
-	.long	0x9fb6b0
-	.long	0x9fb6f8
-	.long	0x9fb740
-	.long	0x9fb750
-	.long	0x9fb7c8
-	.long	0x9fb840
-	.long	0x9fb880
-	.long	0x9fb890
-	.long	0x9fb908
-	.long	0x9fb914
-	.long	0x9fb928
-	.long	0x9fb9a0
-	.long	0x9fba18
-	.long	0x9fba24
-	.long	0x9fba40
-	.long	0x9fba60
-	.long	0x9fbad8
-	.long	0x9fbaf8
-	.long	0x9fbb10
-	.long	0x9fbb28
-	.long	0x9fbb34
-	.long	0x9fbb54
-	.long	0x9fbb6c
-	.long	0x9fbb84
-	.long	0x9fbb90
-	.long	0x9fbba8
-	.long	0x9fbc20
-	.long	0x9fbc34
-	.long	0x9fbc48
-	.long	0x9fbc5c
-	.long	0x9fbc84
-	.long	0x9fbcfc
-	.long	0x9fbd24
-	.long	0x9fbd44
-	.long	0x9fbd64
-	.long	0x9fbd84
-	.long	0x9fbd98
-	.long	0x9fbdb0
-	.long	0x9fbdd4
-	.long	0x9fbde0
-	.long	0x9fbdfc
-	.long	0x9fbe1c
-	.long	0x9fbe38
-	.long	0x9fbe58
-	.long	0x9fbe78
-	.long	0x9fbe8c
-	.long	0x9fbe9c
-	.long	0x9fbeac
-	.long	0x9fbec4
-	.long	0x9fbedc
-	.long	0x9fbef8
-	.long	0x9fbf0c
-	.long	0x9fbf74
-	.long	0x9fbf80
-	.long	0x9fbf90
-	.long	0x9fc008
-	.long	0x9fc03c
-	.long	0x9fc0b4
+	.long	0x9fb618
+	.long	0x9fb660
+	.long	0x9fb6a8
+	.long	0x9fb6f0
+	.long	0x9fb738
+	.long	0x9fb748
+	.long	0x9fb7c0
+	.long	0x9fb838
+	.long	0x9fb878
+	.long	0x9fb888
+	.long	0x9fb900
+	.long	0x9fb90c
+	.long	0x9fb920
+	.long	0x9fb998
+	.long	0x9fba10
+	.long	0x9fba1c
+	.long	0x9fba38
+	.long	0x9fba58
+	.long	0x9fbad0
+	.long	0x9fbaf0
+	.long	0x9fbb08
+	.long	0x9fbb20
+	.long	0x9fbb2c
+	.long	0x9fbb4c
+	.long	0x9fbb64
+	.long	0x9fbb7c
+	.long	0x9fbb88
+	.long	0x9fbba0
+	.long	0x9fbc18
+	.long	0x9fbc2c
+	.long	0x9fbc40
+	.long	0x9fbc54
+	.long	0x9fbc7c
+	.long	0x9fbcf4
+	.long	0x9fbd1c
+	.long	0x9fbd3c
+	.long	0x9fbd5c
+	.long	0x9fbd7c
+	.long	0x9fbd90
+	.long	0x9fbda8
+	.long	0x9fbdcc
+	.long	0x9fbdd8
+	.long	0x9fbdf4
+	.long	0x9fbe14
+	.long	0x9fbe30
+	.long	0x9fbe50
+	.long	0x9fbe70
+	.long	0x9fbe84
+	.long	0x9fbe94
+	.long	0x9fbea4
+	.long	0x9fbebc
+	.long	0x9fbed4
+	.long	0x9fbef0
+	.long	0x9fbf04
+	.long	0x9fbf6c
+	.long	0x9fbf78
+	.long	0x9fbf88
+	.long	0x9fc000
+	.long	0x9fc034
+	.long	0x9fc0ac
+	.long	0x9fc108
 	.long	0x9fc110
-	.long	0x9fc118
-	.long	0x9fc190
-	.long	0x9fc1a0
-	.long	0x9fc218
-	.long	0x9fc254
-	.long	0x9fc264
-	.long	0x9fc2a4
-	.long	0x9fc2cc
-	.long	0x9fc2f0
-	.long	0x9fc304
-	.long	0x9fc310
-	.long	0x9fc324
-	.long	0x9fc334
-	.long	0x9fc3ac
-	.long	0x9fc3c0
-	.long	0x9fc3e0
-	.long	0x9fc400
-	.long	0x9fc420
-	.long	0x9fc440
-	.long	0x9fc4b8
-	.long	0x9fc4d4
-	.long	0x9fc4f0
-	.long	0x9fc50c
-	.long	0xa03b88
-	.long	0xa03c00
-	.long	0xa03c14
-	.long	0xa04014
-	.long	0xa04024
-	.long	0xa04044
-	.long	0xa04058
-	.long	0xa04084
-	.long	0xa040fc
-	.long	0xa0413c
-	.long	0xa04150
-	.long	0xa0416c
-	.long	0xa04184
-	.long	0xa04198
-	.long	0xa041ac
+	.long	0x9fc188
+	.long	0x9fc198
+	.long	0x9fc210
+	.long	0x9fc24c
+	.long	0x9fc25c
+	.long	0x9fc29c
+	.long	0x9fc2c4
+	.long	0x9fc2e8
+	.long	0x9fc2fc
+	.long	0x9fc308
+	.long	0x9fc31c
+	.long	0x9fc32c
+	.long	0x9fc3a4
+	.long	0x9fc3b8
+	.long	0x9fc3d8
+	.long	0x9fc3f8
+	.long	0x9fc418
+	.long	0x9fc438
+	.long	0x9fc4b0
+	.long	0x9fc4cc
+	.long	0x9fc4e8
+	.long	0x9fc504
+	.long	0xa03b80
+	.long	0xa03bf8
+	.long	0xa03c0c
+	.long	0xa0400c
+	.long	0xa0401c
+	.long	0xa0403c
+	.long	0xa04050
+	.long	0xa0407c
+	.long	0xa040f4
+	.long	0xa04134
+	.long	0xa04148
+	.long	0xa04164
+	.long	0xa0417c
+	.long	0xa04190
+	.long	0xa041a4
 	.long	0xa04200
 	.long	0xa0422c
 	.long	0xa04240
@@ -70429,7 +70429,7 @@ kallsyms_offsets:
 	.long	0xc43850
 	.long	0xc43850
 	.long	0xc43850
-	.long	0xc438d6
+	.long	0xc438d7
 	.long	0xc438d8
 	.long	0xcf8000
 	.long	0xcf8000

+ 289 - 289
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_kallsyms2.S

@@ -34660,302 +34660,302 @@ kallsyms_offsets:
 	.long	0x9f8000
 	.long	0x9f8000
 	.long	0x9f8010
-	.long	0x9f806c
-	.long	0x9f8104
-	.long	0x9f8114
-	.long	0x9f8134
-	.long	0x9f8154
-	.long	0x9f8164
-	.long	0x9f8184
-	.long	0x9f8194
-	.long	0x9f8214
-	.long	0x9f8224
-	.long	0x9f82bc
-	.long	0x9f82d0
-	.long	0x9f833c
-	.long	0x9f8398
-	.long	0x9f83b0
-	.long	0x9f83f4
-	.long	0x9f8404
-	.long	0x9f8420
-	.long	0x9f8434
-	.long	0x9f84ac
-	.long	0x9f84bc
-	.long	0x9f84c8
-	.long	0x9f8570
-	.long	0x9f8598
-	.long	0x9f8640
-	.long	0x9f8668
-	.long	0x9f8690
-	.long	0x9f8738
-	.long	0x9f8760
-	.long	0x9f8808
-	.long	0x9f8830
-	.long	0x9f88d8
-	.long	0x9f8900
-	.long	0x9f89a8
-	.long	0x9f89d0
-	.long	0x9f8a78
-	.long	0x9f8aa0
-	.long	0x9f8b48
-	.long	0x9f8b70
-	.long	0x9f8b94
-	.long	0x9f9400
-	.long	0x9f9418
-	.long	0x9f9490
-	.long	0x9f94b0
-	.long	0x9f94c0
-	.long	0x9f94cc
-	.long	0x9f94d2
-	.long	0x9f94d8
-	.long	0x9f9520
-	.long	0x9f9534
-	.long	0x9f954c
-	.long	0x9f956c
-	.long	0x9f958c
-	.long	0x9f964c
-	.long	0x9f9728
+	.long	0x9f8068
+	.long	0x9f80fc
+	.long	0x9f810c
+	.long	0x9f812c
+	.long	0x9f814c
+	.long	0x9f815c
+	.long	0x9f817c
+	.long	0x9f818c
+	.long	0x9f820c
+	.long	0x9f821c
+	.long	0x9f82b4
+	.long	0x9f82c8
+	.long	0x9f8334
+	.long	0x9f8390
+	.long	0x9f83a8
+	.long	0x9f83ec
+	.long	0x9f83fc
+	.long	0x9f8418
+	.long	0x9f842c
+	.long	0x9f84a4
+	.long	0x9f84b4
+	.long	0x9f84c0
+	.long	0x9f8568
+	.long	0x9f8590
+	.long	0x9f8638
+	.long	0x9f8660
+	.long	0x9f8688
+	.long	0x9f8730
+	.long	0x9f8758
+	.long	0x9f8800
+	.long	0x9f8828
+	.long	0x9f88d0
+	.long	0x9f88f8
+	.long	0x9f89a0
+	.long	0x9f89c8
+	.long	0x9f8a70
+	.long	0x9f8a98
+	.long	0x9f8b40
+	.long	0x9f8b68
+	.long	0x9f8b8c
+	.long	0x9f93f8
+	.long	0x9f9410
+	.long	0x9f9488
+	.long	0x9f94a8
+	.long	0x9f94b8
+	.long	0x9f94c4
+	.long	0x9f94ca
+	.long	0x9f94d0
+	.long	0x9f9518
+	.long	0x9f952c
+	.long	0x9f9544
+	.long	0x9f9564
+	.long	0x9f9584
+	.long	0x9f9644
+	.long	0x9f9720
+	.long	0x9f9ec8
 	.long	0x9f9ed0
-	.long	0x9f9ed8
-	.long	0x9f9f50
-	.long	0x9f9fc8
-	.long	0x9f9fdc
-	.long	0x9f9ff4
-	.long	0x9fa00c
-	.long	0x9fa020
-	.long	0x9fa034
-	.long	0x9fa048
-	.long	0x9fa058
-	.long	0x9fa070
-	.long	0x9fa08c
-	.long	0x9fa0a0
-	.long	0x9fa0c0
-	.long	0x9fa0d4
-	.long	0x9fa0e4
-	.long	0x9fa0f8
-	.long	0x9fa120
-	.long	0x9fa1f4
-	.long	0x9fa210
-	.long	0x9fa228
-	.long	0x9fa240
-	.long	0x9fa250
-	.long	0x9fa25c
-	.long	0x9fa270
+	.long	0x9f9f48
+	.long	0x9f9fc0
+	.long	0x9f9fd4
+	.long	0x9f9fec
+	.long	0x9fa004
+	.long	0x9fa018
+	.long	0x9fa02c
+	.long	0x9fa040
+	.long	0x9fa050
+	.long	0x9fa068
+	.long	0x9fa084
+	.long	0x9fa098
+	.long	0x9fa0b8
+	.long	0x9fa0cc
+	.long	0x9fa0dc
+	.long	0x9fa0f0
+	.long	0x9fa118
+	.long	0x9fa1ec
+	.long	0x9fa208
+	.long	0x9fa220
+	.long	0x9fa238
+	.long	0x9fa248
+	.long	0x9fa254
+	.long	0x9fa268
+	.long	0x9fa278
 	.long	0x9fa280
-	.long	0x9fa288
-	.long	0x9fa2a4
-	.long	0x9fa2bc
-	.long	0x9fa2d8
-	.long	0x9fa2ec
-	.long	0x9fa300
-	.long	0x9fa318
-	.long	0x9fa338
-	.long	0x9fa34c
-	.long	0x9fa36c
-	.long	0x9fa388
-	.long	0x9fa398
-	.long	0x9fa410
-	.long	0x9fa488
-	.long	0x9fa500
-	.long	0x9fa510
-	.long	0x9fa528
-	.long	0x9fa548
-	.long	0x9fa56c
-	.long	0x9fa588
-	.long	0x9fa5a4
-	.long	0x9fa5c4
-	.long	0x9fa5dc
-	.long	0x9fa5f4
-	.long	0x9fa610
-	.long	0x9fa62c
-	.long	0x9fa640
-	.long	0x9fa65c
-	.long	0x9fa678
-	.long	0x9fa690
-	.long	0x9fa6a8
-	.long	0x9fa6bc
-	.long	0x9fa6cc
-	.long	0x9fa6dc
-	.long	0x9fa6f8
-	.long	0x9fa714
-	.long	0x9fa730
-	.long	0x9fa748
-	.long	0x9fa75c
-	.long	0x9fa770
-	.long	0x9fa788
-	.long	0x9fa7a0
-	.long	0x9fa7b4
-	.long	0x9fa7c4
-	.long	0x9fa7e0
-	.long	0x9fa7f0
-	.long	0x9fa800
-	.long	0x9fa818
-	.long	0x9fa838
-	.long	0x9fa84c
-	.long	0x9fa85c
-	.long	0x9fa870
-	.long	0x9fa880
-	.long	0x9fa894
-	.long	0x9fa8ac
-	.long	0x9fa8c4
-	.long	0x9fa8d8
-	.long	0x9faef8
-	.long	0x9faf0c
-	.long	0x9faf24
-	.long	0x9faf40
-	.long	0x9faf5c
-	.long	0x9faf78
-	.long	0x9faf84
-	.long	0x9fafa0
-	.long	0x9fafbc
-	.long	0x9fafdc
-	.long	0x9faff0
-	.long	0x9fb068
-	.long	0x9fb098
-	.long	0x9fb0b4
-	.long	0x9fb0c4
+	.long	0x9fa29c
+	.long	0x9fa2b4
+	.long	0x9fa2d0
+	.long	0x9fa2e4
+	.long	0x9fa2f8
+	.long	0x9fa310
+	.long	0x9fa330
+	.long	0x9fa344
+	.long	0x9fa364
+	.long	0x9fa380
+	.long	0x9fa390
+	.long	0x9fa408
+	.long	0x9fa480
+	.long	0x9fa4f8
+	.long	0x9fa508
+	.long	0x9fa520
+	.long	0x9fa540
+	.long	0x9fa564
+	.long	0x9fa580
+	.long	0x9fa59c
+	.long	0x9fa5bc
+	.long	0x9fa5d4
+	.long	0x9fa5ec
+	.long	0x9fa608
+	.long	0x9fa624
+	.long	0x9fa638
+	.long	0x9fa654
+	.long	0x9fa670
+	.long	0x9fa688
+	.long	0x9fa6a0
+	.long	0x9fa6b4
+	.long	0x9fa6c4
+	.long	0x9fa6d4
+	.long	0x9fa6f0
+	.long	0x9fa70c
+	.long	0x9fa728
+	.long	0x9fa740
+	.long	0x9fa754
+	.long	0x9fa768
+	.long	0x9fa780
+	.long	0x9fa798
+	.long	0x9fa7ac
+	.long	0x9fa7bc
+	.long	0x9fa7d8
+	.long	0x9fa7e8
+	.long	0x9fa7f8
+	.long	0x9fa810
+	.long	0x9fa830
+	.long	0x9fa844
+	.long	0x9fa854
+	.long	0x9fa868
+	.long	0x9fa878
+	.long	0x9fa88c
+	.long	0x9fa8a4
+	.long	0x9fa8bc
+	.long	0x9fa8d0
+	.long	0x9faef0
+	.long	0x9faf04
+	.long	0x9faf1c
+	.long	0x9faf38
+	.long	0x9faf54
+	.long	0x9faf70
+	.long	0x9faf7c
+	.long	0x9faf98
+	.long	0x9fafb4
+	.long	0x9fafd4
+	.long	0x9fafe8
+	.long	0x9fb060
+	.long	0x9fb090
+	.long	0x9fb0ac
+	.long	0x9fb0bc
+	.long	0x9fb0cc
 	.long	0x9fb0d4
-	.long	0x9fb0dc
-	.long	0x9fb0e0
-	.long	0x9fb164
-	.long	0x9fb18c
-	.long	0x9fb19c
-	.long	0x9fb214
-	.long	0x9fb28c
-	.long	0x9fb298
-	.long	0x9fb29c
+	.long	0x9fb0d8
+	.long	0x9fb15c
+	.long	0x9fb184
+	.long	0x9fb194
+	.long	0x9fb20c
+	.long	0x9fb284
+	.long	0x9fb290
+	.long	0x9fb294
+	.long	0x9fb2b0
 	.long	0x9fb2b8
-	.long	0x9fb2c0
-	.long	0x9fb2d8
-	.long	0x9fb2e4
-	.long	0x9fb2f8
-	.long	0x9fb318
-	.long	0x9fb334
-	.long	0x9fb34c
+	.long	0x9fb2d0
+	.long	0x9fb2dc
+	.long	0x9fb2f0
+	.long	0x9fb310
+	.long	0x9fb32c
+	.long	0x9fb344
+	.long	0x9fb350
 	.long	0x9fb358
-	.long	0x9fb360
-	.long	0x9fb370
-	.long	0x9fb380
-	.long	0x9fb390
-	.long	0x9fb3a0
-	.long	0x9fb3b0
-	.long	0x9fb3c0
-	.long	0x9fb3d0
-	.long	0x9fb3e0
-	.long	0x9fb3f0
-	.long	0x9fb400
-	.long	0x9fb410
-	.long	0x9fb420
-	.long	0x9fb430
-	.long	0x9fb440
-	.long	0x9fb450
-	.long	0x9fb454
-	.long	0x9fb464
-	.long	0x9fb478
-	.long	0x9fb518
-	.long	0x9fb5b8
+	.long	0x9fb368
+	.long	0x9fb378
+	.long	0x9fb388
+	.long	0x9fb398
+	.long	0x9fb3a8
+	.long	0x9fb3b8
+	.long	0x9fb3c8
+	.long	0x9fb3d8
+	.long	0x9fb3e8
+	.long	0x9fb3f8
+	.long	0x9fb408
+	.long	0x9fb418
+	.long	0x9fb428
+	.long	0x9fb438
+	.long	0x9fb448
+	.long	0x9fb44c
+	.long	0x9fb45c
+	.long	0x9fb470
+	.long	0x9fb510
+	.long	0x9fb5b0
+	.long	0x9fb5c0
 	.long	0x9fb5c8
 	.long	0x9fb5d0
-	.long	0x9fb5d8
-	.long	0x9fb620
-	.long	0x9fb668
-	.long	0x9fb6b0
-	.long	0x9fb6f8
-	.long	0x9fb740
-	.long	0x9fb750
-	.long	0x9fb7c8
-	.long	0x9fb840
-	.long	0x9fb880
-	.long	0x9fb890
-	.long	0x9fb908
-	.long	0x9fb914
-	.long	0x9fb928
-	.long	0x9fb9a0
-	.long	0x9fba18
-	.long	0x9fba24
-	.long	0x9fba40
-	.long	0x9fba60
-	.long	0x9fbad8
-	.long	0x9fbaf8
-	.long	0x9fbb10
-	.long	0x9fbb28
-	.long	0x9fbb34
-	.long	0x9fbb54
-	.long	0x9fbb6c
-	.long	0x9fbb84
-	.long	0x9fbb90
-	.long	0x9fbba8
-	.long	0x9fbc20
-	.long	0x9fbc34
-	.long	0x9fbc48
-	.long	0x9fbc5c
-	.long	0x9fbc84
-	.long	0x9fbcfc
-	.long	0x9fbd24
-	.long	0x9fbd44
-	.long	0x9fbd64
-	.long	0x9fbd84
-	.long	0x9fbd98
-	.long	0x9fbdb0
-	.long	0x9fbdd4
-	.long	0x9fbde0
-	.long	0x9fbdfc
-	.long	0x9fbe1c
-	.long	0x9fbe38
-	.long	0x9fbe58
-	.long	0x9fbe78
-	.long	0x9fbe8c
-	.long	0x9fbe9c
-	.long	0x9fbeac
-	.long	0x9fbec4
-	.long	0x9fbedc
-	.long	0x9fbef8
-	.long	0x9fbf0c
-	.long	0x9fbf74
-	.long	0x9fbf80
-	.long	0x9fbf90
-	.long	0x9fc008
-	.long	0x9fc03c
-	.long	0x9fc0b4
+	.long	0x9fb618
+	.long	0x9fb660
+	.long	0x9fb6a8
+	.long	0x9fb6f0
+	.long	0x9fb738
+	.long	0x9fb748
+	.long	0x9fb7c0
+	.long	0x9fb838
+	.long	0x9fb878
+	.long	0x9fb888
+	.long	0x9fb900
+	.long	0x9fb90c
+	.long	0x9fb920
+	.long	0x9fb998
+	.long	0x9fba10
+	.long	0x9fba1c
+	.long	0x9fba38
+	.long	0x9fba58
+	.long	0x9fbad0
+	.long	0x9fbaf0
+	.long	0x9fbb08
+	.long	0x9fbb20
+	.long	0x9fbb2c
+	.long	0x9fbb4c
+	.long	0x9fbb64
+	.long	0x9fbb7c
+	.long	0x9fbb88
+	.long	0x9fbba0
+	.long	0x9fbc18
+	.long	0x9fbc2c
+	.long	0x9fbc40
+	.long	0x9fbc54
+	.long	0x9fbc7c
+	.long	0x9fbcf4
+	.long	0x9fbd1c
+	.long	0x9fbd3c
+	.long	0x9fbd5c
+	.long	0x9fbd7c
+	.long	0x9fbd90
+	.long	0x9fbda8
+	.long	0x9fbdcc
+	.long	0x9fbdd8
+	.long	0x9fbdf4
+	.long	0x9fbe14
+	.long	0x9fbe30
+	.long	0x9fbe50
+	.long	0x9fbe70
+	.long	0x9fbe84
+	.long	0x9fbe94
+	.long	0x9fbea4
+	.long	0x9fbebc
+	.long	0x9fbed4
+	.long	0x9fbef0
+	.long	0x9fbf04
+	.long	0x9fbf6c
+	.long	0x9fbf78
+	.long	0x9fbf88
+	.long	0x9fc000
+	.long	0x9fc034
+	.long	0x9fc0ac
+	.long	0x9fc108
 	.long	0x9fc110
-	.long	0x9fc118
-	.long	0x9fc190
-	.long	0x9fc1a0
-	.long	0x9fc218
-	.long	0x9fc254
-	.long	0x9fc264
-	.long	0x9fc2a4
-	.long	0x9fc2cc
-	.long	0x9fc2f0
-	.long	0x9fc304
-	.long	0x9fc310
-	.long	0x9fc324
-	.long	0x9fc334
-	.long	0x9fc3ac
-	.long	0x9fc3c0
-	.long	0x9fc3e0
-	.long	0x9fc400
-	.long	0x9fc420
-	.long	0x9fc440
-	.long	0x9fc4b8
-	.long	0x9fc4d4
-	.long	0x9fc4f0
-	.long	0x9fc50c
-	.long	0xa03b88
-	.long	0xa03c00
-	.long	0xa03c14
-	.long	0xa04014
-	.long	0xa04024
-	.long	0xa04044
-	.long	0xa04058
-	.long	0xa04084
-	.long	0xa040fc
-	.long	0xa0413c
-	.long	0xa04150
-	.long	0xa0416c
-	.long	0xa04184
-	.long	0xa04198
-	.long	0xa041ac
+	.long	0x9fc188
+	.long	0x9fc198
+	.long	0x9fc210
+	.long	0x9fc24c
+	.long	0x9fc25c
+	.long	0x9fc29c
+	.long	0x9fc2c4
+	.long	0x9fc2e8
+	.long	0x9fc2fc
+	.long	0x9fc308
+	.long	0x9fc31c
+	.long	0x9fc32c
+	.long	0x9fc3a4
+	.long	0x9fc3b8
+	.long	0x9fc3d8
+	.long	0x9fc3f8
+	.long	0x9fc418
+	.long	0x9fc438
+	.long	0x9fc4b0
+	.long	0x9fc4cc
+	.long	0x9fc4e8
+	.long	0x9fc504
+	.long	0xa03b80
+	.long	0xa03bf8
+	.long	0xa03c0c
+	.long	0xa0400c
+	.long	0xa0401c
+	.long	0xa0403c
+	.long	0xa04050
+	.long	0xa0407c
+	.long	0xa040f4
+	.long	0xa04134
+	.long	0xa04148
+	.long	0xa04164
+	.long	0xa0417c
+	.long	0xa04190
+	.long	0xa041a4
 	.long	0xa04200
 	.long	0xa0422c
 	.long	0xa04240
@@ -70429,7 +70429,7 @@ kallsyms_offsets:
 	.long	0xd43850
 	.long	0xd43850
 	.long	0xd43850
-	.long	0xd438d6
+	.long	0xd438d7
 	.long	0xd438d8
 	.long	0xdf8000
 	.long	0xdf8000

BIN
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_vmlinux1


BIN
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_vmlinux2


+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version

@@ -1 +1 @@
-342
+343

+ 98 - 19
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp

@@ -1198,22 +1198,35 @@
 
 
 
+   0x020 (((1 << 5) | (1 << 3)) | 7)
+   0x024 (((1 << 5) | (1 << 3)) | 7)
+   0x028 (((1 << 5) | (1 << 3)) | 7)
+   0x02C (((1 << 5) | (1 << 3)) | 7)
    0x144 (((1 << 5) | (1 << 3)) | 7)
    0x1B0 (((1 << 3)) | 7)
    0x1B4 (((1 << 5) | (1 << 3)) | 7)
 
 
-   0x08C (((1 << 3)) | 7)
-   0x0A0 (((1 << 3)) | 7)
-   0x0A4 (((1 << 3)) | 7)
-   0x0A8 (((1 << 3)) | 7)
-   0x0AC (((1 << 3)) | 7)
-   0x0B0 (((1 << 3)) | 7)
-   0x0B4 (((1 << 3)) | 7)
+   0x030 (((1 << 5) | (1 << 3)) | 7)
+   0x034 (((1 << 5) | (1 << 3)) | 7)
+   0x038 (((1 << 5) | (1 << 3)) | 7)
+   0x03C (((1 << 5) | (1 << 3)) | 7)
+
+
+   0x0EC (((1 << 3)) | 7)
+   0x0E4 (((1 << 3)) | 7)
    0x0E8 (((1 << 5) | (1 << 3)) | 7)
-   0x0E0 (((1 << 3)) | 7)
+   0x0E0 (((1 << 5) | (1 << 3)) | 7)
+
 
+   0x194 (((1 << 5) | (1 << 3)) | 7)
+   0x1A0 (((1 << 5) | (1 << 3)) | 7)
+   0x19C (((1 << 5) | (1 << 3)) | 7)
+   0x190 (((1 << 3)) | 7)
+   0x1A4 (((1 << 3)) | 7)
+   0x198 (((1 << 3)) | 7)
    0x1A8 (((1 << 3)) | 7)
+
   >;
  };
 
@@ -1258,7 +1271,14 @@
    0x164 (0 | 1)
   >;
  };
-# 136 "arch/arm/boot/dts/am335x-evm.dts"
+
+ uart5_pins: pinmux_uart5_pins {
+  pinctrl-single,pins = <
+   0x0C0 (0 | 4)
+   0x0C4 (((1 << 5) | (1 << 4)) | 4)
+  >;
+ };
+
  clkout2_pin: pinmux_clkout2_pin {
   pinctrl-single,pins = <
    0x1b4 (0 | 3)
@@ -1309,12 +1329,12 @@
   pinctrl-single,pins = <
 
 
-
-
+   0x108 (((1 << 5) | (1 << 4)) | 0)
+   0x10C(((1 << 5) | (1 << 4)) | 0)
    0x110 (((1 << 5) | (1 << 4)) | 0)
-   0x118 (((1 << 5) | (1 << 4)) | 0)
    0x12c (((1 << 5) | (1 << 4)) | 0)
    0x130 (((1 << 5) | (1 << 4)) | 0)
+   0x118 (((1 << 5) | (1 << 4)) | 0)
    0x134 (((1 << 5) | (1 << 4)) | 0)
    0x138 (((1 << 5) | (1 << 4)) | 0)
    0x13c (((1 << 5) | (1 << 4)) | 0)
@@ -1325,6 +1345,23 @@
    0x124 (0 | 0)
    0x128 (0 | 0)
 
+
+   ((((0x878)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x888)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 2)
+
+   ((((0x858)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x85c)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x844)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x860)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x864)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x868)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x86c)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
+   ((((0x840)) & 0xffff) - (0x0800)) (0 | 1)
+   ((((0x848)) & 0xffff) - (0x0800)) (0 | 1)
+   ((((0x84c)) & 0xffff) - (0x0800)) (0 | 1)
+   ((((0x850)) & 0xffff) - (0x0800)) (0 | 1)
+   ((((0x854)) & 0xffff) - (0x0800)) (0 | 1)
+
   >;
  };
 
@@ -1344,6 +1381,23 @@
    0x13c (((1 << 5)) | 7)
    0x140 (((1 << 5)) | 7)
 
+
+   ((((0x888)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x840)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x844)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x848)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x84c)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x850)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x854)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x858)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x85c)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x860)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x864)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x868)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+   ((((0x86c)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+
+   ((((0x878)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
+
   >;
  };
 
@@ -1382,7 +1436,14 @@
    0x17C (((1 << 5)) | 2)
   >;
  };
-# 280 "arch/arm/boot/dts/am335x-evm.dts"
+
+ dcan1_pins_default: dcan1_pins_default {
+  pinctrl-single,pins = <
+   0x168 (((1 << 4)) | 2)
+   0x16C (((1 << 5)) | 2)
+  >;
+ };
+# 327 "arch/arm/boot/dts/am335x-evm.dts"
 };
 
 
@@ -1414,7 +1475,14 @@
 
  status = "okay";
 };
-# 319 "arch/arm/boot/dts/am335x-evm.dts"
+
+&uart5 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart5_pins>;
+
+ status = "okay";
+};
+
 &i2c0 {
  pinctrl-names = "default";
  pinctrl-0 = <&i2c0_pins>;
@@ -1443,7 +1511,6 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
-
 };
 
 &usb {
@@ -1478,7 +1545,7 @@
 &elm {
  status = "okay";
 };
-# 403 "arch/arm/boot/dts/am335x-evm.dts"
+# 449 "arch/arm/boot/dts/am335x-evm.dts"
 &gpmc {
  status = "okay";
  pinctrl-names = "default", "sleep";
@@ -1664,7 +1731,7 @@
   };
  };
 };
-# 509 "arch/arm/boot/dts/am335x-evm.dts" 2
+# 555 "arch/arm/boot/dts/am335x-evm.dts" 2
 
 &tps {
  vcc1-supply = <&vbat>;
@@ -1747,6 +1814,7 @@
  pinctrl-names = "default", "sleep";
  pinctrl-0 = <&cpsw_default>;
  pinctrl-1 = <&cpsw_sleep>;
+ dual_emac = <1>;
  status = "okay";
 };
 
@@ -1755,15 +1823,20 @@
  pinctrl-0 = <&davinci_mdio_default>;
  pinctrl-1 = <&davinci_mdio_sleep>;
  status = "okay";
-
 };
 
 &cpsw_emac0 {
  phy_id = <&davinci_mdio>, <1>;
   phy-mode = "mii";
+  dual_emac_res_vlan = <1>;
+};
 
+&cpsw_emac1 {
+ phy_id = <&davinci_mdio>, <2>;
+  phy-mode = "mii";
+  dual_emac_res_vlan = <2>;
 };
-# 615 "arch/arm/boot/dts/am335x-evm.dts"
+
 &tscadc {
  status = "okay";
 
@@ -1810,3 +1883,9 @@
  pinctrl-names = "default";
  pinctrl-0 = <&dcan0_pins_default>;
 };
+
+&dcan1 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&dcan1_pins_default>;
+};

+ 80 - 36
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts

@@ -64,23 +64,36 @@
 		pinctrl-single,pins = <
 		
 			/** Offset: 0x800 */
-			/** GPIO 0 */ 
+			/** GPIO 0 */   
+			0x020 (PIN_INPUT | MUX_MODE7)			/* GPMC_AD8			=> 	GPIO0_22 */	/*ID BD1_1*/
+			0x024 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD9			=>	GPIO0_23 */	/*ID BD1_2*/
+			0x028 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD10		=>	GPIO0_26 */	/*IO BD1_1*/
+			0x02C (PIN_INPUT | MUX_MODE7)    		/* GPMC_AD11		=>	GPIO0_27 */	/*IO BD1_2*/
 			0x144 (PIN_INPUT | MUX_MODE7)    			/* RMII1_REF_CLK		=>	GPIO0_29 */	/*USB 0 OCP detection*/
 			0x1B0 (PIN_OUTPUT | MUX_MODE7)			/*XDMA_EVENT_INTR0	=>	GPIO0_19 */	/*AM_RFID_RST*/
 			0x1B4 (PIN_INPUT | MUX_MODE7)			/*XDMA_EVENT_INTR1	=>	GPIO0_20 */	/*AM_RFID_ICC*/
-			/** GPIO 1 */			
+			
+			/** GPIO 1 */
+			0x030 (PIN_INPUT | MUX_MODE7)			/* GPMC_AD12	=> 	GPIO1_12 */	/*ID BD2_1*/
+			0x034 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD13	=>	GPIO1_13 */	/*ID BD2_2*/
+			0x038 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD14	=>	GPIO1_14 */	/*IO BD2_1*/
+			0x03C (PIN_INPUT | MUX_MODE7)    		/* GPMC_AD15	=>	GPIO1_15 */	/*IO BD2_2*/
+			
 			/** GPIO 2 */
-			0x08C (PIN_OUTPUT | MUX_MODE7)			/*GPMC_CLK	=>	GPIO2_1*/	/*Speaker*/
-			0x0A0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA0	=>	GPIO2_6*/	/*Panel LED control-BB_LEDR1*/
-			0x0A4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA1	=>	GPIO2_7*/	/*Panel LED control-BB_LEDG1*/
-			0x0A8 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA2	=>	GPIO2_8*/	/*Panel LED control-BB_LEDB1*/
-			0x0AC (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA3	=>	GPIO2_9*/	/*Panel LED control-BB_LEDR2*/
-			0x0B0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA4	=>	GPIO2_10*/	/*Panel LED control-BB_LEDG2*/
-			0x0B4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA5	=>	GPIO2_11*/	/*Panel LED control-BB_LEDB2*/
-			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK	=>	GPIO2_24*/	/*communication board proximity*/
-			0x0E0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_VSYNC	=>	GPIO2_22*/	/*Breath LED*/
+			0x0EC (PIN_OUTPUT | MUX_MODE7)			/*LCD_AC_BIAS_EN	=>	GPIO2_25*/	/*RS-485 for module DE control*/
+			0x0E4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_HSYNC		=>	GPIO2_23*/	/*RS-485 for module RE control*/
+			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK		=>	GPIO2_24*/	/*CCS communication board 1 proximity*/
+			0x0E0 (PIN_INPUT | MUX_MODE7)			/*LCD_VSYNC		=>	GPIO2_22*/	/*CCS communication board 2 proximity*/
+			
 			/** GPIO 3 */
-			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
+			0x194 (PIN_INPUT | MUX_MODE7)			/*MCASP0_FSX		=>	GPIO3_15*/	/*Emergency Stop button detect*/
+			0x1A0 (PIN_INPUT | MUX_MODE7)			/*MCASP0_ACLKR	=>	GPIO3_18*/	/*USB1 OCP detect*/
+			0x19C (PIN_INPUT | MUX_MODE7)			/*MCASP0_AHCLKR	=>	GPIO3_17*/	/*Emergency IO for AM3352 and STM32F407*/
+			0x190 (PIN_OUTPUT | MUX_MODE7)			/*MCASP0_ACLKX	=>	GPIO3_14*/	/*Ethernet PHY reset*/
+			0x1A4 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_FSR		=>	GPIO3_19 */	/*SMR Enable control_1*/
+			0x198 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR0	=>	GPIO3_16 */	/*CSU board function OK indicator.*/
+			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*SMR Enable control_2*/
+			
 		>;
 	};
 	
@@ -125,14 +138,14 @@
 			0x164 (PIN_OUTPUT_PULLDOWN | MUX_MODE1)	/* ECAP0_IN_PWM0_OUT		=>	uart3_txd */
 		>;
 	};
-#if 0
+
 	uart5_pins: pinmux_uart5_pins {
 		pinctrl-single,pins = <
-			0x0C0 (PIN_INPUT_PULLUP | MUX_MODE4)		/* LCD_DATA8	=>	UART5_RXD*/
-			0x0C4 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)	/* LCD_DATA9	=>	UART5_TXD*/
+			0x0C0 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)		/* LCD_DATA8	=>	DUART5_TX*/
+			0x0C4 (PIN_INPUT_PULLUP | MUX_MODE4)			/* LCD_DATA9	=>	UART5_RX*/
 		>;
 	};
-#endif	
+	
 	clkout2_pin: pinmux_clkout2_pin {
 		pinctrl-single,pins = <
 			0x1b4 (PIN_OUTPUT_PULLDOWN | MUX_MODE3)	/* xdma_event_intr1.clkout2 */
@@ -183,12 +196,12 @@
 		pinctrl-single,pins = <					
 		
 			/* Slave 1 */
-			//0x108 (PIN_INPUT_PULLDOWN | MUX_MODE0)		/* MII1_COL.gmii1_col */
-			//0x10C(PIN_INPUT_PULLDOWN | MUX_MODE0)		/* MII1_CRS.MII1_CRS */
+			0x108 (PIN_INPUT_PULLUP | MUX_MODE0)		/* MII1_COL.gmii1_col */
+			0x10C(PIN_INPUT_PULLUP | MUX_MODE0)		/* MII1_CRS.MII1_CRS */
 			0x110 (PIN_INPUT_PULLUP | MUX_MODE0)		/* MII1_RX_ER.gmii1_rxerr */
-			0x118 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxdv.mii1_rxdv */
 			0x12c (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_txclk.mii1_txclk */
 			0x130 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxclk.mii1_rxclk */
+			0x118 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxdv.mii1_rxdv */
 			0x134 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxd3.rgmii1_rd3 */
 			0x138 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxd2.rgmii1_rd2 */
 			0x13c (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxd1.rgmii1_rd1 */
@@ -197,7 +210,24 @@
 			0x11c (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd3.rgmii1_td3 */
 			0x120 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd2.rgmii1_td2 */
 			0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd1.rgmii1_td1 */
-			0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd0.rgmii1_td0 */      
+			0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd0.rgmii1_td0 */      	
+			
+			/* Slave 2 */
+			AM33XX_IOPAD(0x878, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_ben1.mii2_col */
+			AM33XX_IOPAD(0x888, PIN_INPUT_PULLUP | MUX_MODE2)					/* GPMC_CSn3.rmii2_crs_dv*/								
+			/*AM33XX_IOPAD(0x874, PIN_INPUT_PULLUP | MUX_MODE1)*/					/* gpmc_wpn.mii2_rxerr */
+			AM33XX_IOPAD(0x858, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a6.mii2_txclk */
+			AM33XX_IOPAD(0x85c, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a7.mii2_rxclk */
+			AM33XX_IOPAD(0x844, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a1.mii2_rxdv */
+			AM33XX_IOPAD(0x860, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a8.mii2_rxd3 */
+			AM33XX_IOPAD(0x864, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a9.mii2_rxd2 */
+			AM33XX_IOPAD(0x868, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a10.mii2_rxd1 */
+			AM33XX_IOPAD(0x86c, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a11.mii2_rxd0 */
+			AM33XX_IOPAD(0x840, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a0.mii2_txen */
+			AM33XX_IOPAD(0x848, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a2.mii2_txd3 */
+			AM33XX_IOPAD(0x84c, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a3.mii2_txd2 */
+			AM33XX_IOPAD(0x850, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a4.mii2_txd1 */
+			AM33XX_IOPAD(0x854, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a5.mii2_txd0 */
 
 		>;
 	};
@@ -218,6 +248,23 @@
 			0x13c (PIN_INPUT_PULLDOWN | MUX_MODE7)
 			0x140 (PIN_INPUT_PULLDOWN | MUX_MODE7)		
 			
+			/* Slave 2 */
+			AM33XX_IOPAD(0x888, PIN_INPUT_PULLDOWN | MUX_MODE7)					/* GPMC_CSn3.rmii2_crs_dv*/	
+			AM33XX_IOPAD(0x840, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a0.mii2_txen */
+			AM33XX_IOPAD(0x844, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a1.mii2_rxdv */
+			AM33XX_IOPAD(0x848, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a2.mii2_txd3 */
+			AM33XX_IOPAD(0x84c, PIN_INPUT_PULLDOWN | MUX_MODE7)			/* gpmc_a3.mii2_txd2 */
+			AM33XX_IOPAD(0x850, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a4.mii2_txd1 */
+			AM33XX_IOPAD(0x854, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a5.mii2_txd0 */
+			AM33XX_IOPAD(0x858, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a6.mii2_txclk */
+			AM33XX_IOPAD(0x85c, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a7.mii2_rxclk */
+			AM33XX_IOPAD(0x860, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a8.mii2_rxd3 */
+			AM33XX_IOPAD(0x864, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a9.mii2_rxd2 */
+			AM33XX_IOPAD(0x868, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a10.mii2_rxd1 */
+			AM33XX_IOPAD(0x86c, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a11.mii2_rxd0 */
+			/*AM33XX_IOPAD(0x874, PIN_INPUT_PULLDOWN | MUX_MODE7)*/	/* gpmc_wpn.mii2_rxerr */
+			AM33XX_IOPAD(0x878, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ben1.mii2_col */
+			
 		>;
 	};
 
@@ -256,14 +303,14 @@
 			0x17C (PIN_INPUT_PULLDOWN | MUX_MODE2)		/* uart1_rtsn	=>	d_can0_rx */
 		>;
 	};
-#if 0	
+	
 	dcan1_pins_default: dcan1_pins_default {
 		pinctrl-single,pins = <
 			0x168 (PIN_OUTPUT_PULLUP | MUX_MODE2)		/* UART0_CTSn		=>	d_can1_tx */
 			0x16C (PIN_INPUT_PULLDOWN | MUX_MODE2)	/* UART0_RTSn		=>	d_can1_rx */
 		>;
 	};
-
+#if 0
 	ehrpwm1_pins: ehrpwm1_pins {
 		pinctrl-single,pins = <			
 			0x0C8 (PIN_OUTPUT | MUX_MODE2) /* LCD_DATA10.eHRPWM1A */
@@ -308,14 +355,14 @@
 
 	status = "okay";
 };
-#if 0
+
 &uart5 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart5_pins>;
 
 	status = "okay";
 };
-#endif
+
 &i2c0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c0_pins>;
@@ -326,11 +373,11 @@
 	tps: tps@2d {
 		reg = <0x2d>;
 	};
-
+	
 /*	rtc0: rtc@51 {
-		compatible = "nxp,pcf85063";
-		reg = <0x51>;
-	};*/
+                compatible = "nxp,pcf85063";
+                reg = <0x51>;
+        };*/	
 };
 #if 1
 &i2c1 {
@@ -344,7 +391,6 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
-
 };
 #endif
 &usb {
@@ -588,6 +634,7 @@
 	pinctrl-names = "default", "sleep";
 	pinctrl-0 = <&cpsw_default>;
 	pinctrl-1 = <&cpsw_sleep>;
+	dual_emac = <1>;
 	status = "okay";
 };
 
@@ -596,21 +643,19 @@
 	pinctrl-0 = <&davinci_mdio_default>;
 	pinctrl-1 = <&davinci_mdio_sleep>;
 	status = "okay";
-	//reset-gpios = <&gpio3 14 GPIO_ACTIVE_LOW>;
 };
 
 &cpsw_emac0 {
 	phy_id = <&davinci_mdio>, <1>;
  	phy-mode = "mii";
-
+ 	dual_emac_res_vlan = <1>;
 };
-#if 0
+
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <2>;
  	phy-mode = "mii";
-
+ 	dual_emac_res_vlan = <2>;
 };
-#endif
 
 &tscadc {
 	status = "okay";
@@ -658,10 +703,9 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&dcan0_pins_default>;
 };
-#if 0
+
 &dcan1 {
 	status = "okay";	
 	pinctrl-names = "default";
 	pinctrl-0 = <&dcan1_pins_default>;
 };
-#endif

+ 6 - 13
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/lib/.gen_crc32table.cmd

@@ -5,23 +5,18 @@ source_lib/gen_crc32table := lib/gen_crc32table.c
 deps_lib/gen_crc32table := \
   /usr/include/stdc-predef.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
@@ -33,11 +28,9 @@ deps_lib/gen_crc32table := \
     $(wildcard include/config/crc32/bit.h) \
     $(wildcard include/config/64bit.h) \
   /usr/include/inttypes.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \
   /usr/include/stdint.h \
   /usr/include/x86_64-linux-gnu/bits/wchar.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h \
 
 lib/gen_crc32table: $(deps_lib/gen_crc32table)
 

+ 13 - 31
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/.conmakehash.cmd

@@ -5,23 +5,18 @@ source_scripts/conmakehash := scripts/conmakehash.c
 deps_scripts/conmakehash := \
   /usr/include/stdc-predef.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
@@ -29,42 +24,29 @@ deps_scripts/conmakehash := \
   /usr/include/stdlib.h \
   /usr/include/x86_64-linux-gnu/bits/waitflags.h \
   /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
-  /usr/include/x86_64-linux-gnu/sys/types.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
   /usr/include/endian.h \
   /usr/include/x86_64-linux-gnu/bits/endian.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
-  /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
+  /usr/include/x86_64-linux-gnu/sys/types.h \
+  /usr/include/time.h \
   /usr/include/x86_64-linux-gnu/sys/select.h \
   /usr/include/x86_64-linux-gnu/bits/select.h \
-  /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
+  /usr/include/x86_64-linux-gnu/bits/sigset.h \
+  /usr/include/x86_64-linux-gnu/bits/time.h \
   /usr/include/x86_64-linux-gnu/bits/select2.h \
   /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
-  /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
   /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
-  /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
-  /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
   /usr/include/alloca.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib.h \
   /usr/include/sysexits.h \
   /usr/include/string.h \
-  /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
-  /usr/include/strings.h \
-  /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \
-  /usr/include/x86_64-linux-gnu/bits/string_fortified.h \
+  /usr/include/xlocale.h \
+  /usr/include/x86_64-linux-gnu/bits/string.h \
+  /usr/include/x86_64-linux-gnu/bits/string2.h \
+  /usr/include/x86_64-linux-gnu/bits/string3.h \
   /usr/include/ctype.h \
 
 scripts/conmakehash: $(deps_scripts/conmakehash)

+ 15 - 33
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/.kallsyms.cmd

@@ -6,23 +6,18 @@ deps_scripts/kallsyms := \
     $(wildcard include/config/page/offset.h) \
   /usr/include/stdc-predef.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
@@ -30,44 +25,31 @@ deps_scripts/kallsyms := \
   /usr/include/stdlib.h \
   /usr/include/x86_64-linux-gnu/bits/waitflags.h \
   /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
-  /usr/include/x86_64-linux-gnu/sys/types.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
   /usr/include/endian.h \
   /usr/include/x86_64-linux-gnu/bits/endian.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
-  /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
+  /usr/include/x86_64-linux-gnu/sys/types.h \
+  /usr/include/time.h \
   /usr/include/x86_64-linux-gnu/sys/select.h \
   /usr/include/x86_64-linux-gnu/bits/select.h \
-  /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
+  /usr/include/x86_64-linux-gnu/bits/sigset.h \
+  /usr/include/x86_64-linux-gnu/bits/time.h \
   /usr/include/x86_64-linux-gnu/bits/select2.h \
   /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
-  /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
   /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
-  /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
-  /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
   /usr/include/alloca.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib.h \
   /usr/include/string.h \
-  /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
-  /usr/include/strings.h \
-  /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \
-  /usr/include/x86_64-linux-gnu/bits/string_fortified.h \
+  /usr/include/xlocale.h \
+  /usr/include/x86_64-linux-gnu/bits/string.h \
+  /usr/include/x86_64-linux-gnu/bits/string2.h \
+  /usr/include/x86_64-linux-gnu/bits/string3.h \
   /usr/include/ctype.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \
   /usr/include/limits.h \
   /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
   /usr/include/x86_64-linux-gnu/bits/local_lim.h \

+ 13 - 36
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/.sortextable.cmd

@@ -8,49 +8,33 @@ deps_scripts/sortextable := \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
+  /usr/include/time.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/endian.h \
   /usr/include/x86_64-linux-gnu/bits/endian.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
-  /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
   /usr/include/x86_64-linux-gnu/sys/select.h \
   /usr/include/x86_64-linux-gnu/bits/select.h \
-  /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
+  /usr/include/x86_64-linux-gnu/bits/sigset.h \
+  /usr/include/x86_64-linux-gnu/bits/time.h \
   /usr/include/x86_64-linux-gnu/bits/select2.h \
   /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
-  /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
   /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
-  /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
-  /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
   /usr/include/x86_64-linux-gnu/sys/mman.h \
   /usr/include/x86_64-linux-gnu/bits/mman.h \
   /usr/include/x86_64-linux-gnu/bits/mman-linux.h \
-  /usr/include/x86_64-linux-gnu/bits/mman-shared.h \
   /usr/include/x86_64-linux-gnu/sys/stat.h \
   /usr/include/x86_64-linux-gnu/bits/stat.h \
   /usr/include/getopt.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_core.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_ext.h \
   /usr/include/elf.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \
   /usr/include/stdint.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/x86_64-linux-gnu/bits/wchar.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h \
   /usr/include/x86_64-linux-gnu/bits/auxv.h \
   /usr/include/fcntl.h \
   /usr/include/x86_64-linux-gnu/bits/fcntl.h \
@@ -60,13 +44,10 @@ deps_scripts/sortextable := \
   /usr/include/x86_64-linux-gnu/bits/setjmp.h \
   /usr/include/x86_64-linux-gnu/bits/setjmp2.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
@@ -74,23 +55,19 @@ deps_scripts/sortextable := \
   /usr/include/stdlib.h \
   /usr/include/x86_64-linux-gnu/bits/waitflags.h \
   /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
   /usr/include/alloca.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib.h \
   /usr/include/string.h \
-  /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
-  /usr/include/strings.h \
-  /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \
-  /usr/include/x86_64-linux-gnu/bits/string_fortified.h \
+  /usr/include/xlocale.h \
+  /usr/include/x86_64-linux-gnu/bits/string.h \
+  /usr/include/x86_64-linux-gnu/bits/string2.h \
+  /usr/include/x86_64-linux-gnu/bits/string3.h \
   /usr/include/unistd.h \
   /usr/include/x86_64-linux-gnu/bits/posix_opt.h \
   /usr/include/x86_64-linux-gnu/bits/environments.h \
   /usr/include/x86_64-linux-gnu/bits/confname.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \
   /usr/include/x86_64-linux-gnu/bits/unistd.h \
   tools/include/tools/be_byteshift.h \
   tools/include/tools/le_byteshift.h \

+ 5 - 10
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/basic/.bin2c.cmd

@@ -5,23 +5,18 @@ source_scripts/basic/bin2c := scripts/basic/bin2c.c
 deps_scripts/basic/bin2c := \
   /usr/include/stdc-predef.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \

+ 20 - 38
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/basic/.fixdep.cmd

@@ -12,81 +12,61 @@ deps_scripts/basic/fixdep := \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
+  /usr/include/time.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/endian.h \
   /usr/include/x86_64-linux-gnu/bits/endian.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
-  /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
   /usr/include/x86_64-linux-gnu/sys/select.h \
   /usr/include/x86_64-linux-gnu/bits/select.h \
-  /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
+  /usr/include/x86_64-linux-gnu/bits/sigset.h \
+  /usr/include/x86_64-linux-gnu/bits/time.h \
   /usr/include/x86_64-linux-gnu/bits/select2.h \
   /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
-  /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
   /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
-  /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
-  /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
   /usr/include/x86_64-linux-gnu/sys/stat.h \
   /usr/include/x86_64-linux-gnu/bits/stat.h \
   /usr/include/x86_64-linux-gnu/sys/mman.h \
   /usr/include/x86_64-linux-gnu/bits/mman.h \
   /usr/include/x86_64-linux-gnu/bits/mman-linux.h \
-  /usr/include/x86_64-linux-gnu/bits/mman-shared.h \
   /usr/include/unistd.h \
   /usr/include/x86_64-linux-gnu/bits/posix_opt.h \
   /usr/include/x86_64-linux-gnu/bits/environments.h \
   /usr/include/x86_64-linux-gnu/bits/confname.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_core.h \
+  /usr/include/getopt.h \
   /usr/include/x86_64-linux-gnu/bits/unistd.h \
   /usr/include/fcntl.h \
   /usr/include/x86_64-linux-gnu/bits/fcntl.h \
   /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \
   /usr/include/x86_64-linux-gnu/bits/fcntl2.h \
   /usr/include/string.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
-  /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
-  /usr/include/strings.h \
-  /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \
-  /usr/include/x86_64-linux-gnu/bits/string_fortified.h \
+  /usr/include/xlocale.h \
+  /usr/include/x86_64-linux-gnu/bits/string.h \
+  /usr/include/x86_64-linux-gnu/bits/string2.h \
   /usr/include/stdlib.h \
+  /usr/include/x86_64-linux-gnu/bits/string3.h \
   /usr/include/x86_64-linux-gnu/bits/waitflags.h \
   /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
   /usr/include/alloca.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
   /usr/include/x86_64-linux-gnu/bits/stdio2.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \
   /usr/include/limits.h \
   /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
   /usr/include/x86_64-linux-gnu/bits/local_lim.h \
@@ -95,9 +75,12 @@ deps_scripts/basic/fixdep := \
   /usr/include/ctype.h \
   /usr/include/arpa/inet.h \
   /usr/include/netinet/in.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \
+  /usr/include/stdint.h \
+  /usr/include/x86_64-linux-gnu/bits/wchar.h \
   /usr/include/x86_64-linux-gnu/sys/socket.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \
+  /usr/include/x86_64-linux-gnu/sys/uio.h \
+  /usr/include/x86_64-linux-gnu/bits/uio.h \
   /usr/include/x86_64-linux-gnu/bits/socket.h \
   /usr/include/x86_64-linux-gnu/bits/socket_type.h \
   /usr/include/x86_64-linux-gnu/bits/sockaddr.h \
@@ -105,7 +88,6 @@ deps_scripts/basic/fixdep := \
   /usr/include/asm-generic/socket.h \
   /usr/include/x86_64-linux-gnu/asm/sockios.h \
   /usr/include/asm-generic/sockios.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_osockaddr.h \
   /usr/include/x86_64-linux-gnu/bits/socket2.h \
   /usr/include/x86_64-linux-gnu/bits/in.h \
 

+ 14 - 33
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/scripts/mod/.mk_elfconfig.cmd

@@ -5,23 +5,18 @@ source_scripts/mod/mk_elfconfig := scripts/mod/mk_elfconfig.c
 deps_scripts/mod/mk_elfconfig := \
   /usr/include/stdc-predef.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
@@ -29,46 +24,32 @@ deps_scripts/mod/mk_elfconfig := \
   /usr/include/stdlib.h \
   /usr/include/x86_64-linux-gnu/bits/waitflags.h \
   /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
-  /usr/include/x86_64-linux-gnu/sys/types.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
   /usr/include/endian.h \
   /usr/include/x86_64-linux-gnu/bits/endian.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
-  /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
+  /usr/include/x86_64-linux-gnu/sys/types.h \
+  /usr/include/time.h \
   /usr/include/x86_64-linux-gnu/sys/select.h \
   /usr/include/x86_64-linux-gnu/bits/select.h \
-  /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
+  /usr/include/x86_64-linux-gnu/bits/sigset.h \
+  /usr/include/x86_64-linux-gnu/bits/time.h \
   /usr/include/x86_64-linux-gnu/bits/select2.h \
   /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
-  /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
   /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
-  /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
-  /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
   /usr/include/alloca.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib.h \
   /usr/include/string.h \
-  /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
-  /usr/include/strings.h \
-  /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \
-  /usr/include/x86_64-linux-gnu/bits/string_fortified.h \
+  /usr/include/xlocale.h \
+  /usr/include/x86_64-linux-gnu/bits/string.h \
+  /usr/include/x86_64-linux-gnu/bits/string2.h \
+  /usr/include/x86_64-linux-gnu/bits/string3.h \
   /usr/include/elf.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \
   /usr/include/stdint.h \
   /usr/include/x86_64-linux-gnu/bits/wchar.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h \
   /usr/include/x86_64-linux-gnu/bits/auxv.h \
 
 scripts/mod/mk_elfconfig: $(deps_scripts/mod/mk_elfconfig)

+ 16 - 39
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/usr/.gen_init_cpio.cmd

@@ -5,23 +5,18 @@ source_usr/gen_init_cpio := usr/gen_init_cpio.c
 deps_usr/gen_init_cpio := \
   /usr/include/stdc-predef.h \
   /usr/include/stdio.h \
-  /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
   /usr/include/features.h \
   /usr/include/x86_64-linux-gnu/sys/cdefs.h \
   /usr/include/x86_64-linux-gnu/bits/wordsize.h \
-  /usr/include/x86_64-linux-gnu/bits/long-double.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs.h \
   /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
   /usr/include/x86_64-linux-gnu/bits/types.h \
   /usr/include/x86_64-linux-gnu/bits/typesizes.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
-  /usr/include/x86_64-linux-gnu/bits/libio.h \
-  /usr/include/x86_64-linux-gnu/bits/_G_config.h \
-    $(wildcard include/config/h.h) \
-  /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
+  /usr/include/libio.h \
+  /usr/include/_G_config.h \
+  /usr/include/wchar.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
   /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
   /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
   /usr/include/x86_64-linux-gnu/bits/stdio.h \
@@ -29,31 +24,19 @@ deps_usr/gen_init_cpio := \
   /usr/include/stdlib.h \
   /usr/include/x86_64-linux-gnu/bits/waitflags.h \
   /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn.h \
-  /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
-  /usr/include/x86_64-linux-gnu/sys/types.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
-  /usr/include/x86_64-linux-gnu/bits/stdint-intn.h \
   /usr/include/endian.h \
   /usr/include/x86_64-linux-gnu/bits/endian.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap.h \
   /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
-  /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
+  /usr/include/x86_64-linux-gnu/sys/types.h \
+  /usr/include/time.h \
   /usr/include/x86_64-linux-gnu/sys/select.h \
   /usr/include/x86_64-linux-gnu/bits/select.h \
-  /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
+  /usr/include/x86_64-linux-gnu/bits/sigset.h \
+  /usr/include/x86_64-linux-gnu/bits/time.h \
   /usr/include/x86_64-linux-gnu/bits/select2.h \
   /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
-  /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
   /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
-  /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
-  /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
   /usr/include/alloca.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
   /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
@@ -61,22 +44,16 @@ deps_usr/gen_init_cpio := \
   /usr/include/x86_64-linux-gnu/sys/stat.h \
   /usr/include/x86_64-linux-gnu/bits/stat.h \
   /usr/include/string.h \
-  /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
-  /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
-  /usr/include/strings.h \
-  /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \
-  /usr/include/x86_64-linux-gnu/bits/string_fortified.h \
+  /usr/include/xlocale.h \
+  /usr/include/x86_64-linux-gnu/bits/string.h \
+  /usr/include/x86_64-linux-gnu/bits/string2.h \
+  /usr/include/x86_64-linux-gnu/bits/string3.h \
   /usr/include/unistd.h \
   /usr/include/x86_64-linux-gnu/bits/posix_opt.h \
   /usr/include/x86_64-linux-gnu/bits/environments.h \
   /usr/include/x86_64-linux-gnu/bits/confname.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \
-  /usr/include/x86_64-linux-gnu/bits/getopt_core.h \
+  /usr/include/getopt.h \
   /usr/include/x86_64-linux-gnu/bits/unistd.h \
-  /usr/include/time.h \
-  /usr/include/x86_64-linux-gnu/bits/time.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \
-  /usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \
   /usr/include/fcntl.h \
   /usr/include/x86_64-linux-gnu/bits/fcntl.h \
   /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \
@@ -88,8 +65,8 @@ deps_usr/gen_init_cpio := \
   /usr/include/asm-generic/errno.h \
   /usr/include/asm-generic/errno-base.h \
   /usr/include/ctype.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \
-  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \
+  /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \
   /usr/include/limits.h \
   /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
   /usr/include/x86_64-linux-gnu/bits/local_lim.h \