浏览代码

[Improve][AW_CCS][main]

2020.09.25 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/SystemLogMessage.c debug print out follow define.h ConsloePrintLog.
2. EVSE/Projects/define.h disable ConsloePrintLog define.
3. EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c CP duty config move to high priority and disable polling BLE info.
4. EVSE/Projects/AW-CCS/Apps/CCS/define_ccs.h SLAC_FIRST_RESPONSE_METHOD change to SET_5_PWM_ONCE_GET_PERMISSION_IN_AUTHORIZATIONRES.
5. EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.c add SyncAcShreaMemory().
6. EVSE/Projects/AW-CCS/Apps/main.h add enum EVSE_NOTIFICATION.
7. EVSE/Projects/AW-CCS/Apps/main.c TIMEOUT_SPEC_BS_HLC_HANDSHAKE change to 30 secs.
8. EVSE/Projects/AW-CCS/Apps/main.c improve BS & HLC logic.

Image version: D0.36.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 4 年之前
父节点
当前提交
bdb028394c

+ 2 - 4
EVSE/Modularization/ocppfiles/SystemLogMessage.c

@@ -1,7 +1,5 @@
 #include "Module_OcppBackend.h"
 
-#define Debug
-
 int StoreLogMsg(const char *fmt, ...)
 {
 	char Buf[65536+256];
@@ -26,7 +24,7 @@ int StoreLogMsg(const char *fmt, ...)
 	//execl("sh", "sh", "-c", Buf, NULL);//system((const char*)Buf);
 	system((const char*)Buf);
 
-#ifdef Debug
+#ifdef ConsloePrintLog
 	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
 #endif
 
@@ -57,7 +55,7 @@ int StoreOcppMsg(const char *fmt, ...)
 	//execl("sh", "sh", "-c", Buf, NULL);//system((const char*)Buf);
 	system((const char*)Buf);
 
-#ifdef Debug
+#ifdef ConsloePrintLog
 	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
 #endif
 	return rc;

+ 139 - 45
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.c

@@ -1655,7 +1655,7 @@ void CP_Detection()
 
         //ftime(&EndTime);
         //DEBUG_PRINTF_EVCOMM_DETAIL("duration:%.02lf\n", DiffTimeb(StartTime, EndTime));
-        usleep(100000);
+        usleep(1000);
     }//while
 }
 
@@ -1724,7 +1724,7 @@ void PP_Detection()
         sleep(5);
         printf("V_pp = %.02f\n", TotalTmpVolt);
         #endif
-        usleep(100000);
+        usleep(1000);
     }//while
 }
 
@@ -2031,7 +2031,7 @@ void Error_Monitor()
             Update_V2G_Flow_Status(Other_Fault);
             End_Process();
         }
-        usleep(100000);
+        usleep(1000);
     }//while
 }
 
@@ -2401,10 +2401,13 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
     struct MmeHeader *MmePacket;
     static unsigned char counter;
     unsigned char state = 0;
-    unsigned char *EvMac_in;
-    unsigned char *RunID_in;
+    unsigned char tmpBuf[2048]={0};
     int Rtn = 0;
+#if(NEW_SLAC_ARCHITECTURE_SWITCH == ENABLE)
     int idx = 0;
+    unsigned char *EvMac_in;
+    unsigned char *RunID_in;
+#endif
 
     MmePacket = (struct MmeHeader *)Buffer;
     state = Check_V2G_Flow_Status();
@@ -2646,7 +2649,7 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
 
                 #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == ENABLE)
                 {
-                    DEBUG_PRINTF_EVCOMM_DETAIL("\n\n***** Response MME Packet *****\n");
+                    DEBUG_PRINTF_EVCOMM_DETAIL("***** Response MME Packet *****\n");
                     DEBUG_PRINTF_EVCOMM_DETAIL("SendMmePacket.ODA: %02x:%02x:%02x:%02x:%02x:%02x:\n",
                            SendMmePacket.ODA[0],SendMmePacket.ODA[1],SendMmePacket.ODA[2],SendMmePacket.ODA[3],SendMmePacket.ODA[4],SendMmePacket.ODA[5]);
                     DEBUG_PRINTF_EVCOMM_DETAIL("SendMmePacket.OSA: %02x:%02x:%02x:%02x:%02x:%02x:\n",
@@ -2679,6 +2682,7 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
                 DEBUG_PRINTF_EVCOMM_DETAIL("SendMmePacketSize=%d,Rtn=%d\n",SendMmePacketSize,Rtn);
 
                 ftime(&SeqStartTime);
+                counter = 0;
                 break;
             }
             #else
@@ -2768,7 +2772,7 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
 
             #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == ENABLE)
             {
-                DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_CM_START_ATTEN_CHAR_IND (counter : %d/3 ) ---\n",counter + 1);
+                DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_CM_START_ATTEN_CHAR_IND (counter : %d/3 ) ---\n", counter);
                 DEBUG_PRINTF_EVCOMM_DETAIL("APPLICATION_TYPE: 0x%x\n", MmePacket->MMENTRY[0]);
                 DEBUG_PRINTF_EVCOMM_DETAIL("SECURITY_TYPE: 0x%x\n", MmePacket->MMENTRY[1]);
                 DEBUG_PRINTF_EVCOMM_DETAIL("NUM_SOUNDS: 0x%x\n", MmePacket->MMENTRY[2]);
@@ -2793,7 +2797,7 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
                 if (idx >= 0)
                 {
                     Update_V2G_Flow_Status(CM_START_ATTEN_CHAR_IND);
-
+                    counter++;
                     //[TC_SECC_VTB_AttenuationCharacterization_013]
                     if (MmePacket->MMENTRY[0] != 0) //APPLICATION_TYPE must be 0x00(EV-EVSE Matching)
                     {
@@ -2926,9 +2930,14 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
                 break;
             }
 
-            #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == TRUE)
+            if(V2gFlowStatus == CM_START_ATTEN_CHAR_IND)
             {
-                DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_CM_MNBC_SOUND_IND (counter : %d/%d) ---\n",counter + 1 , MnbcSoundNum);
+            	counter = 0;
+            }
+
+            #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == ENABLE)
+            {
+                DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_CM_MNBC_SOUND_IND (counter : %d/%d) ---\n", counter, SLAC_INFO.array[idx].MnbcSoundNum);
                 DEBUG_PRINTF_EVCOMM_DETAIL("APPLICATION_TYPE: 0x%x\n", MmePacket->MMENTRY[0]);
                 DEBUG_PRINTF_EVCOMM_DETAIL("SECURITY_TYPE: 0x%x\n", MmePacket->MMENTRY[1]);
                 DEBUG_PRINTF_EVCOMM_DETAIL("SenderID: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
@@ -2963,6 +2972,7 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
                 if (idx >= 0)
                 {
                     Update_V2G_Flow_Status(CM_MNBC_SOUND_IND);
+                    counter++;
 
                     //Check for RunID
                     if (SLAC_DB_Check_EvMac_RunID_Matching(&SLAC_INFO, EvMac_in, RunID_in) == TRUE)
@@ -3011,9 +3021,9 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
 				break;
 			}
 
-            #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == TRUE)
+            #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == ENABLE)
             {
-                DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_CM_ATTEN_PROFILE_IND (counter : %d/%d) ---\n", counter, MnbcSoundNum);
+                DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_CM_ATTEN_PROFILE_IND (counter : %d/%d) ---\n", counter, SLAC_INFO.array[idx].MnbcSoundNum);
                 DEBUG_PRINTF_EVCOMM_DETAIL("EV MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
                        MmePacket->MMENTRY[0], MmePacket->MMENTRY[1], MmePacket->MMENTRY[2], MmePacket->MMENTRY[3],
                        MmePacket->MMENTRY[4], MmePacket->MMENTRY[5]);
@@ -3021,13 +3031,13 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
                 //NumGroups: Number of OFDM carrier groups used for the SLAC signal characterization.
                 //AAG[i]: Average Attenuation of Group i (i = 1 ~ 58)
                 DEBUG_PRINTF_EVCOMM_DETAIL("RSVD: 0x%x\n", MmePacket->MMENTRY[7]);
-                DEBUG_PRINTF_EVCOMM_DETAIL("AAG: \n");
 
+                memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                 for(Rtn = 0; Rtn < MmePacket->MMENTRY[6]; Rtn++)
                 {
-                    DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",MmePacket->MMENTRY[8 + Rtn]);
+                	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, MmePacket->MMENTRY[8 + Rtn]);
                 }
-                DEBUG_PRINTF_EVCOMM_DETAIL("\n");
+                DEBUG_PRINTF_EVCOMM_DETAIL("AAG: %s\n", tmpBuf);
             }
             #endif
 
@@ -3112,18 +3122,20 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
                 DEBUG_PRINTF_EVCOMM_DETAIL("RunID: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
                        MmePacket->MMENTRY[8],MmePacket->MMENTRY[9],MmePacket->MMENTRY[10],MmePacket->MMENTRY[11],
                        MmePacket->MMENTRY[12],MmePacket->MMENTRY[13],MmePacket->MMENTRY[14],MmePacket->MMENTRY[15]);
-                DEBUG_PRINTF_EVCOMM_DETAIL("SOURCE_ID: \n");
+
+                memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                 for(Rtn = 0; Rtn < 17; Rtn++)
                 {
-                    DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",MmePacket->MMENTRY[16 + Rtn]);
+                	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, MmePacket->MMENTRY[16 + Rtn]);
                 }
-                DEBUG_PRINTF_EVCOMM_DETAIL("\n");
-                DEBUG_PRINTF_EVCOMM_DETAIL("RESP_ID: \n");
+                DEBUG_PRINTF_EVCOMM_DETAIL("SOURCE_ID: %s\n", tmpBuf);
+                                ;
+                memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                 for(Rtn = 0; Rtn < 17; Rtn++)
                 {
-                    DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",MmePacket->MMENTRY[33 + Rtn]);
+                	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, MmePacket->MMENTRY[33 + Rtn]);
                 }
-                DEBUG_PRINTF_EVCOMM_DETAIL("\n");
+                DEBUG_PRINTF_EVCOMM_DETAIL("RESP_ID: %s\n", tmpBuf);
                 DEBUG_PRINTF_EVCOMM_DETAIL("Result: 0x%x\n", MmePacket->MMENTRY[50]);    //Fixed value of 0x00 indicates a successful SLAC process
             }
             #endif
@@ -3904,14 +3916,16 @@ GLOBAL VARIABLES:
 int SlacComm()
 {
     static unsigned char qca7k_comm_retry = 0;
-    unsigned char *EvMac_in;
-    unsigned char *RunID_in;
     double t_diff = 0;
     int packet_size = 0;
     int count = 0;
     //int idx = 0;
+    unsigned char tmpBuf[2048]={0};
+#if (NEW_SLAC_ARCHITECTURE_SWITCH == ENABLE)
+    unsigned char *EvMac_in;
+    unsigned char *RunID_in;
     int i = 0;
-
+#endif
     if(RawSock >= 0)
     {
         memset(V2gtpMsgRxBuf, 0, V2GTP_MSG_RX_BUFFER_SIZE);
@@ -4327,7 +4341,7 @@ int SlacComm()
                         }
                         SendMmePacketSize += 19;      //the size before MMENTRY
 
-                        #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == TRUE)
+                        #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == ENABLE)
                         {
                             DEBUG_PRINTF_EVCOMM_DETAIL("\n\n***** Send MME Packet *****\n");
                             DEBUG_PRINTF_EVCOMM_DETAIL("SendMmePacket.ODA: %02x:%02x:%02x:%02x:%02x:%02x:\n",
@@ -4347,25 +4361,29 @@ int SlacComm()
                             DEBUG_PRINTF_EVCOMM_DETAIL("RunID: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
                                    SendMmePacket.MMENTRY[8],SendMmePacket.MMENTRY[9],SendMmePacket.MMENTRY[10],SendMmePacket.MMENTRY[11],
                                    SendMmePacket.MMENTRY[12],SendMmePacket.MMENTRY[13],SendMmePacket.MMENTRY[14],SendMmePacket.MMENTRY[15]);
-                            DEBUG_PRINTF_EVCOMM_DETAIL("SOURCE_ID: \n");
+
+                            memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                             for(count=0; count<17; count++)
                             {
-                                DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",SendMmePacket.MMENTRY[16+count]);
+                            	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, SendMmePacket.MMENTRY[16+count]);
                             }
-                            DEBUG_PRINTF_EVCOMM_DETAIL("\n");
-                            DEBUG_PRINTF_EVCOMM_DETAIL("RESP_ID: \n");
+                            DEBUG_PRINTF_EVCOMM_DETAIL("SOURCE_ID: %s\n", tmpBuf);
+
+                            memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                             for(count=0; count<17; count++)
                             {
-                                DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",SendMmePacket.MMENTRY[33+count]);
+                            	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, SendMmePacket.MMENTRY[33+count]);
                             }
-                            DEBUG_PRINTF_EVCOMM_DETAIL("\n");
+                            DEBUG_PRINTF_EVCOMM_DETAIL("RESP_ID: %s\n", tmpBuf);
+
                             DEBUG_PRINTF_EVCOMM_DETAIL("NumSounds: 0x%x\n", SendMmePacket.MMENTRY[50]);
-                            DEBUG_PRINTF_EVCOMM_DETAIL("ATTEN_PROFILE: \n");
+
+                            memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                             for(count=0; count<AagGroupsNum; count++)
                             {
-                                DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",SendMmePacket.MMENTRY[51+count]);
+                            	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, SendMmePacket.MMENTRY[51+count]);
                             }
-                            DEBUG_PRINTF_EVCOMM_DETAIL("\n");
+                            DEBUG_PRINTF_EVCOMM_DETAIL("ATTEN_PROFILE: %s\n", tmpBuf);
                         }
                         #endif
 
@@ -4471,7 +4489,7 @@ int SlacComm()
                     }
                     SendMmePacketSize += 19;      //the size before MMENTRY
 
-                    #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == TRUE)
+                    #if (DEBUG_PRINTF_EVCOMM_DETAIL_SHOW == ENABLE)
                     {
                         DEBUG_PRINTF_EVCOMM_DETAIL("\n\n***** Send MME Packet *****\n");
                         DEBUG_PRINTF_EVCOMM_DETAIL("SendMmePacket.ODA: %02x:%02x:%02x:%02x:%02x:%02x:\n",
@@ -4491,25 +4509,29 @@ int SlacComm()
                         DEBUG_PRINTF_EVCOMM_DETAIL("RunID: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
                                SendMmePacket.MMENTRY[8],SendMmePacket.MMENTRY[9],SendMmePacket.MMENTRY[10],SendMmePacket.MMENTRY[11],
                                SendMmePacket.MMENTRY[12],SendMmePacket.MMENTRY[13],SendMmePacket.MMENTRY[14],SendMmePacket.MMENTRY[15]);
-                        DEBUG_PRINTF_EVCOMM_DETAIL("SOURCE_ID: \n");
+
+                        memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                         for(count=0; count<17; count++)
                         {
-                            DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",SendMmePacket.MMENTRY[16+count]);
+                        	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, SendMmePacket.MMENTRY[16+count]);
                         }
-                        DEBUG_PRINTF_EVCOMM_DETAIL("\n");
-                        DEBUG_PRINTF_EVCOMM_DETAIL("RESP_ID: \n");
+                        DEBUG_PRINTF_EVCOMM_DETAIL("SOURCE_ID: %s\n", tmpBuf);
+
+                        memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));;
                         for(count=0; count<17; count++)
                         {
-                            DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",SendMmePacket.MMENTRY[33+count]);
+                        	sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, SendMmePacket.MMENTRY[33+count]);
                         }
-                        DEBUG_PRINTF_EVCOMM_DETAIL("\n");
+                        DEBUG_PRINTF_EVCOMM_DETAIL("RESP_ID: %s\n", tmpBuf);
+
                         DEBUG_PRINTF_EVCOMM_DETAIL("NumSounds: 0x%x\n", SendMmePacket.MMENTRY[50]);
-                        DEBUG_PRINTF_EVCOMM_DETAIL("ATTEN_PROFILE: \n");
+
+                        memset(tmpBuf, 0x00, ARRAY_SIZE(tmpBuf));
                         for(count=0; count<AagGroupsNum; count++)
                         {
-                            DEBUG_PRINTF_EVCOMM_DETAIL("%02x, ",SendMmePacket.MMENTRY[51+count]);
+                            sprintf((char*)tmpBuf, "%s%02x,", tmpBuf, SendMmePacket.MMENTRY[51+count]);
                         }
-                        DEBUG_PRINTF_EVCOMM_DETAIL("\n");
+                        DEBUG_PRINTF_EVCOMM_DETAIL("ATTEN_PROFILE: %s\n", tmpBuf);
                     }
                     #endif
 
@@ -16216,6 +16238,76 @@ int Parameters_Init()
     return 0;
 }
 
+/*===========================================================================
+FUNCTION: AC share memory synchronize
+DESCRIPTION:
+PRE-CONDITION:
+INPUT:
+OUTPUT:
+GLOBAL VARIABLES:
+=============================================================================*/
+int SyncAcShreaMemory()
+{
+#if (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE)
+	pid_t pid;
+
+	pid = fork();
+	if(pid == 0)
+	{
+		for(;;)
+		{
+			if(!EVCOMM_SYS_INFO.End_Process_inused)
+			{
+				for(uint8_t gun_index=0;gun_index<1;gun_index++)
+				{
+					//========================================
+					// CSU -> CCS setting
+					//========================================
+					// Permission
+					if(ShmInternalComm->ChargingPermission != ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission)
+					{
+						DEBUG_INFO("AC permission: %d -> %d\n", ShmInternalComm->ChargingPermission, ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission);
+						ShmInternalComm->ChargingPermission_new = ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission;
+						ShmInternalComm->ChargingPermission_pre = ShmInternalComm->ChargingPermission;
+						ShmInternalComm->ChargingPermission = ShmInternalComm->ChargingPermission_new;
+					}
+
+					// CP
+					ShmInternalComm->AC_CpPositiveVoltage = ShmCharger->gun_info[gun_index].acCcsInfo.CpPositiveVoltage;
+					if(ShmInternalComm->AC_CpPresentState != ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentState)
+					{
+						DEBUG_INFO("CP state: %d -> %d\n", ShmInternalComm->AC_CpPresentState, ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentState);
+						ShmInternalComm->AC_CpPresentState = ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentState;
+					}
+
+					//========================================
+					// CCS -> CSU check
+					//========================================
+					// CP check status
+					/*
+					if(ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentPWMDuty)
+					{
+						DEBUG_INFO("acCcsInfo.CpSetPWMDuty: %d -> %d\n", ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty, ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentPWMDuty);
+						ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentPWMDuty;
+					}*/
+
+					// V2G message flow status
+					if(ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus != Check_V2G_Flow_Status())
+					{
+						//DEBUG_INFO("PresentMsgFlowStatus: %d -> %d\n", ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus, Check_V2G_Flow_Status());
+						ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus = Check_V2G_Flow_Status();
+					}
+				}
+			}
+
+
+			usleep(1000);
+		}
+	}
+#endif
+
+	return 0;
+}
 
 /*===========================================================================
 FUNCTION: main
@@ -16302,6 +16394,8 @@ int main(int argc, char *argv[])
     sleep(1); //wait for tcpdump getting ready
     #endif
 
+    SyncAcShreaMemory();
+
     SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Init]DONE");
 
     while(1)
@@ -16393,6 +16487,6 @@ int main(int argc, char *argv[])
                 //null
             }
         }
-        usleep(100000);
+        usleep(1000);
     } //while
 }//main while

+ 0 - 1
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.h

@@ -102,7 +102,6 @@
 /****** Timing and constant values **********/
 /*********** [2015] ISO 15118_3 ***************/
 /**********************************************/
-//#define TT_EVSE_match_MNBC                  600         //unit: 1ms (default: 600ms)
 #define TT_EVSE_match_MNBC                  (600+400)   //unit: 1ms (default: 600ms)
 #define C_EV_match_MNBC                     0x0A
 #define TT_EVSE_SLAC_init                   50          //unit: sec.

+ 1 - 1
EVSE/Projects/AW-CCS/Apps/CCS/SystemLogMessage.h

@@ -3,7 +3,7 @@
 
 /*SystemLog message*/
 #define SystemLogMessage            //for engineer to do analysis
-#define ConsloePrintLog
+//#define ConsloePrintLog
 
 //System Log
 #if SAVE_SYS_LOG_MSG_EVCOMM_SWITCH == ENABLE

+ 1 - 1
EVSE/Projects/AW-CCS/Apps/CCS/define_ccs.h

@@ -91,7 +91,7 @@
 #define NEW_SLAC_ARCHITECTURE_SWITCH                        ENABLE  //defualt: ENABLE
 #define CAN_RAMDOM_MATCHING_ID_MECHANISM                    ENABLE  //defualt: ENABLE
 #define CAN_RX_TIMEOUT_MECHANISM                            DISABLE  //defualt: ENABLE
-#define SLAC_FIRST_RESPONSE_METHOD                          SET_5_PWM_ONCE_RX_CM_SLAC_PARM_REQ
+#define SLAC_FIRST_RESPONSE_METHOD                          SET_5_PWM_ONCE_GET_PERMISSION_IN_AUTHORIZATIONRES
 
 #define TCPDUMP_PACKETS_SNIFFER_SWITCH                      DISABLE //default: DISABLE
 #define CANDUMP_PACKETS_SNIFFER_SWITCH                      DISABLE //default: DISABLE

+ 28 - 27
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -2110,6 +2110,7 @@ int main(void)
 						failCount[gun_index] = FAIL_SPEC_COMM;
 				}
 
+				/*
 				//===============================
 				// Case 5 : Query primary MCU BLE config
 				//===============================
@@ -2146,7 +2147,7 @@ int main(void)
 						failCount[gun_index]++;
 					else
 						failCount[gun_index] = FAIL_SPEC_COMM;
-				}
+				}*/
 
 				//===============================
 				// Case 7 : Config primary MCU reset request
@@ -2177,6 +2178,26 @@ int main(void)
 					}
 				}
 
+				//===============================
+				// Case 8 : Config primary set CP PWN duty
+				//===============================
+				if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == ON)
+				{
+					if(Config_AC_MaxCurrent_And_CpPwmDuty(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty))
+					{
+						failCount[gun_index] = 0;
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = OFF;
+					}
+					else
+					{
+						DEBUG_WARN("MCU-%d set cp pwn duty fail...%d\n", gun_index, failCount[gun_index]);
+						if(failCount[gun_index]<USHRT_MAX)
+							failCount[gun_index]++;
+						else
+							failCount[gun_index] = FAIL_SPEC_COMM;
+					}
+				}
+
 				//==========================================================
 				// High priority polling log print out
 				//==========================================================
@@ -2398,28 +2419,8 @@ int main(void)
 								failCount[gun_index] = FAIL_SPEC_COMM;
 						}
 						break;
+
 					case 9:
-						//===============================
-						// Config primary set CP PWN duty
-						//===============================
-						if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == ON)
-						{
-							if(Config_AC_MaxCurrent_And_CpPwmDuty(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty))
-							{
-								failCount[gun_index] = 0;
-								ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = OFF;
-							}
-							else
-							{
-								DEBUG_WARN("MCU-%d set cp pwn duty fail...%d\n", gun_index, failCount[gun_index]);
-								if(failCount[gun_index]<USHRT_MAX)
-									failCount[gun_index]++;
-								else
-									failCount[gun_index] = FAIL_SPEC_COMM;
-							}
-						}
-						break;
-					case 11:
 						//===============================
 						// Query RTC
 						//===============================
@@ -2479,7 +2480,7 @@ int main(void)
 								failCount[gun_index] = FAIL_SPEC_COMM;
 						}
 						break;
-					case 13:
+					case 11:
 						//===============================
 						// Query primary MCU power consumption
 						//===============================
@@ -2496,7 +2497,7 @@ int main(void)
 								failCount[gun_index] = FAIL_SPEC_COMM;
 						}
 						break;
-					case 15:
+					case 13:
 						//===============================
 						// Upgrade MCU
 						//===============================
@@ -2527,7 +2528,7 @@ int main(void)
 							system((char*)cmd);
 						}
 						break;
-					case 17:
+					case 15:
 						//===============================
 						// Config set breathe led timing
 						//===============================
@@ -2547,7 +2548,7 @@ int main(void)
 							}
 						}
 						break;
-					case 19:
+					case 17:
 						//===============================
 						// Config set led brightness
 						//===============================
@@ -2567,7 +2568,7 @@ int main(void)
 							}
 						}
 						break;
-					case 21:
+					case 19:
 						//===============================
 						// Query firmware version
 						//===============================

+ 30 - 59
EVSE/Projects/AW-CCS/Apps/main.c

@@ -33,9 +33,9 @@
 #define TIMEOUT_SPEC_HANDSHAKING_LED			185000
 #define TIMEOUT_SPEC_LOGPPRINTOUT				30000
 #define TIMEOUT_SPEC_PROFILE_PREPARE			5000
-#define TIMEOUT_SPEC_BS_HLC_HANDSHAKE			2000
+#define TIMEOUT_SPEC_BS_HLC_HANDSHAKE			30000
 #define TIMEOUT_SPEC_EV_READY					30000
-#define TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET		10000
+#define TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET	10000
 #define TIMEOUT_SPEC_CCS_HANDSHAKE				120000
 #define TIMEOUT_SPEC_PWN_CHANGE			5000
 
@@ -1360,7 +1360,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.35.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.36.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -2704,6 +2704,7 @@ int main(void)
 							}
 						}
 						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+						system("/root/Module_CCS &");
 					}
 					
 					if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
@@ -2764,9 +2765,7 @@ int main(void)
 					{
 						ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 						setLedMotion(gun_index,LED_ACTION_AUTHED);
-						ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;	
-
-						system("/root/Module_CCS &");
+						ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;
 					}
 					
 					// If control pilot detect Bx, skip watch dog time out.
@@ -2783,20 +2782,24 @@ int main(void)
 								setLedMotion(gun_index,LED_ACTION_CONNECTED);	
 								DEBUG_INFO("Set Request On.\n");
 								
+								//Let CCS task start to negotiate
+								ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = ON;
+								ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_NONE;
+
 								// Set CCS 5% PWM duty
-								ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_5;
-								ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5_CHECK;	
-								ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+								if(ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty == CCS_PWM_DUTY_5)
+								{
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_5;
+									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5_CHECK;
+									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+								}
 								break;
 							case HANDSHAKE_DUTY_5_CHECK:
-								if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF)
+								if((ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF))
 								{						
 									//2 secs timeout
 									ftime(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CCS;
-									//Let CCS task start to negotiate
-									ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = ON;	
-									ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 0;	
 								}						
 								break;
 							case HANDSHAKE_CCS:
@@ -2804,25 +2807,21 @@ int main(void)
 								if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
 								{
 									ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-									ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
+									ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
 									DEBUG_INFO("BS/HLC 2 secs handshake timeout.\n");
 								}
 								
 								if((ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission == OFF) && (ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != CCS_PWM_DUTY_5))
 								{
 									DEBUG_INFO("Wait CCS give up negotiagting.\n");
-									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STATE_E;
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STATE_F;
 									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;						
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CP_STATE_E;
 									ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_BS;
-								}									
-								
-#ifdef	CCS_SIMULATION_DATA				
-								ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus = 1;						
-#endif	//CCS_SIMULATION_DATA								
+								}
 								
 								//CCS status check
-								if(ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus > 0)
+								if((16 < ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus) && (ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus < 254))
 								{
 									ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_HLC;
 									DEBUG_INFO("Enter HLC Mode charging.\n");
@@ -2830,18 +2829,6 @@ int main(void)
 									ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 								}
 								
-								// Use RFID card to stop handshaking
-								if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index))
-								{
-									DEBUG_INFO("Use RFID card to stop handshaking.\n");
-									setSpeaker(ON,SPEAKER_SHORT);
-									setChargerMode(gun_index, SYS_MODE_IDLE);
-									
-								}
-								else
-								{
-									ShmCharger->gun_info[gun_index].rfidReq = OFF;
-								}							
 								break;	
 							case HANDSHAKE_CP_STATE_E:
 								if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF)
@@ -2873,6 +2860,7 @@ int main(void)
 									}
 									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;						
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_SET_MAX_CURRENT;
+									ftime(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
 								}						
 								break;
 							case HANDSHAKE_SET_MAX_CURRENT:
@@ -2916,6 +2904,7 @@ int main(void)
 								}
 
 								//EV READY CHECK
+								/*
 								if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_EV_READY) && (ShmCharger->gun_info[gun_index].isEvReady2StateE == OFF))
 								{
 									if(ShmCharger->gun_info[gun_index].isDoEvReadyOnce == OFF)
@@ -2978,13 +2967,10 @@ int main(void)
 										default:
 											break;																														
 									}									
-								}
+								}*/
 								
 								break;		
 							case HANDSHAKE_HLC_MODE:	
-#ifdef	CCS_SIMULATION_DATA				
-								ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress = HLC_START_MODE;						
-#endif	//CCS_SIMULATION_DATA	
 								if(ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress == HLC_START_MODE)
 								{
 									setRelay(gun_index,ON);
@@ -3033,11 +3019,8 @@ int main(void)
 										DEBUG_INFO("CCS 120 secs handshake timeout.\n");
 										//Cancel CCS task negotiating
 										ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-										ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
-										ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
-#ifdef	CCS_SIMULATION_DATA				
-										ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = CCS_PWM_DUTY_100;						
-#endif	//CCS_SIMULATION_DATA		
+										ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
+										ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;
 									}
 								}
 								if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty == CCS_PWM_DUTY_100)
@@ -3062,12 +3045,8 @@ int main(void)
 						
 						//Cancel CCS task negotiating
 						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
+						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
 						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
-						
-#ifdef	CCS_SIMULATION_DATA				
-						ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = CCS_PWM_DUTY_100;						
-#endif	//CCS_SIMULATION_DATA
 					}
 
 					// Use RFID card to stop handshaking
@@ -3079,12 +3058,8 @@ int main(void)
 						
 						//Cancel CCS task negotiating
 						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
+						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
 						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
-						
-#ifdef	CCS_SIMULATION_DATA				
-						ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = CCS_PWM_DUTY_100;						
-#endif	//CCS_SIMULATION_DATA
 					}
 					else
 					{
@@ -3101,15 +3076,11 @@ int main(void)
 							
 							//Cancel CCS task negotiating
 							ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
-							ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
+							ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
 							ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
-						
-#ifdef	CCS_SIMULATION_DATA				
-							ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = CCS_PWM_DUTY_100;						
-#endif	//CCS_SIMULATION_DATA
 						}
 					}		
-					
+
 					if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != CCS_PWM_DUTY_5)
 					{
 						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
@@ -3613,7 +3584,7 @@ int main(void)
 								//setChargerMode(gun_index, SYS_MODE_COMPLETE);
 								//Cancel CCS task negotiating
 								ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
-								ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;
+								ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
 								setRelay(gun_index,OFF);
 								ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;
 							}

+ 12 - 5
EVSE/Projects/AW-CCS/Apps/main.h

@@ -187,6 +187,13 @@ enum HLC_MODE
 	HLC_STANDBY_MODE
 };
 
+enum EVSE_NOTIFICATION
+{
+	NOTIFICATION_NONE=0,
+	NOTIFICATION_STOP,
+	NOTIFICATION_RENEGOTIATION
+};
+
 #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)
@@ -569,14 +576,14 @@ typedef struct CCS_INFO
 	float		CpPositiveVoltage;				/*uint: 1V*/
 	float		CpNegativeVoltage;				/*uint: 1V*/
 	uint32_t	CcsHeartBeat;					/*unit: 1*/
-	float 		EVSEPresentCurrent[3];				//unit: 1A
+	float 		EVSEPresentCurrent[3];			//unit: 1A
 	float 		AvailableChargingPower;			//1KW
 	uint8_t		EVSENotification;				/*0: None
-													1: StopCharging
-													2: ReNegotiation*/
-	uint16_t 	ChargingPermission:1;				/*0x00: Not ready yet, stay in idle mode or go into terminating process.
+												  1: StopCharging
+												  2: ReNegotiation*/
+	uint16_t 	ChargingPermission:1;			/*0x00: Not ready yet, stay in idle mode or go into terminating process.
 												  0x01: start charging process*/
-	uint16_t 	ConnectorLockerStatus:1;			/*0x00: released
+	uint16_t 	ConnectorLockerStatus:1;		/*0x00: released
 												  0x01: locked*/	
 												 
 	uint16_t	RcdStatus:1;					/* 0x00 no error

+ 2 - 2
EVSE/Projects/define.h

@@ -128,7 +128,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 
 /*SystemLog message*/
 #define SystemLogMessage			//for debug info save to log file
-#define ConsloePrintLog				//for debug info print to console
+//#define ConsloePrintLog				//for debug info print to console
 
 /**************************************************************************************/
 /*****************************share memory key information*****************************/
@@ -5030,7 +5030,7 @@ struct PublishFirmware_20
 struct PublishFirmwareStatusNotification_20
 {
 	unsigned char status[32];										// Required. This contains the progress status of the publishfirmware installation.
-	unsigned char location[512];									// Optional. Required if status is Published. Can be multiple URI’s, if the Local Controller supports e.g. HTTP, HTTPS, and FTP.
+	unsigned char location[10][512];									// Optional. Required if status is Published. Can be multiple URI’s, if the Local Controller supports e.g. HTTP, HTTPS, and FTP.
 	unsigned int requestId;											// Optional. The request id that was provided in the PublishFirmwareRequest which triggered this action.
 };