Procházet zdrojové kódy

2020-11-09 / Alston Lin
Actions
1. Fix the error that occurred 012249 problem

Files
1. As follow commit history

Alston před 4 roky
rodič
revize
1ee503ef92

binární
EVSE/Projects/DS60-120/Apps/Module_EvComm


+ 2 - 1
EVSE/Projects/DS60-120/Apps/Module_EvComm.c

@@ -2866,7 +2866,8 @@ void CANReceiver()
 							if (_chargingData[targetGun]->EvBatteryStartSoc <= 0)
 								_chargingData[targetGun]->EvBatteryStartSoc = frame.data[1];
 
-							_chargingData[targetGun]->EvBatterySoc = frame.data[1];
+							if (frame.data[1] > _chargingData[targetGun]->EvBatterySoc)
+								_chargingData[targetGun]->EvBatterySoc = frame.data[1];
 						}
 
 						_chargingData[targetGun]->EvBatterytargetVoltage = (float)((frame.data[3] << 8) + frame.data[2]) / 10;

binární
EVSE/Projects/DS60-120/Apps/Module_PrimaryComm


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

@@ -378,6 +378,12 @@ void SetRtcData()
 	}
 }
 
+void SetModelName()
+{
+	if (Config_Model_Name(Uart1Fd, Addr.IoExtend, ShmSysConfigAndInfo->SysConfig.ModelName) == PASS)
+	{
+	}
+}
 //================================================
 // Main process
 //================================================
@@ -447,6 +453,7 @@ int main(void)
 	}
 
 	SetRtcData();
+	//SetModelName();
 	gettimeofday(&_flash_time, NULL);
 	for(;;)
 	{

binární
EVSE/Projects/DS60-120/Apps/Module_PsuComm


+ 0 - 1
EVSE/Projects/DS60-120/Apps/Module_PsuComm.c

@@ -1187,7 +1187,6 @@ void OutputChargingLogFuncion(byte groupIndex)
 void InitialPsuData()
 {
 	ShmPsuData->SystemPresentPsuQuantity = 0;
-	ShmPsuData->SystemAvailablePower = 0;
 
 	PRINTF_FUNC("InitialPsuData : PSU Group = %d \n", ShmPsuData->GroupCount);
 	for (byte _groupCount = 0; _groupCount < ShmPsuData->GroupCount; _groupCount++)

+ 44 - 1
EVSE/Projects/DS60-120/Apps/PrimaryComm.c

@@ -33,7 +33,7 @@
 #define FAIL				-1
 
 struct Address Addr={0x01,0x02,0x03,0x04,0xFF};
-struct Command Cmd={0x01,0x02,0x0a,0x86,0x87,0xe0,0xe1,0xe2,0xe3};
+struct Command Cmd={0x01,0x02,0x0a,0x83,0x86,0x87,0xe0,0xe1,0xe2,0xe3};
 
 int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx)
 {
@@ -231,6 +231,49 @@ unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *S
 	return result;
 }
 
+unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname)
+{
+	unsigned char result = FAIL;
+	unsigned char tx[21] = {0xaa, 0x00, targetAddr, Cmd.config_Model_Name, 0x0E, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+	unsigned char rx[512];
+	unsigned char chksum = 0x00;
+
+	memcpy(tx + 6, modelname, 14);
+
+	for(int idx = 0; idx<(tx[4] | tx[5]<<8);idx++)
+		chksum ^= tx[6+idx];
+	tx[20] = chksum;
+
+//	for(int i = 0; i < 21; i++)
+//				printf ("tx = %x \n", tx[i]);
+	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+//	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;
+
+		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] == PASS)
+		{
+			result = PASS;
+		}
+	}
+
+	return result;
+}
+
 unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32)
 {
 	unsigned char result = FAIL;

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

@@ -16,6 +16,7 @@ extern struct Command
 	unsigned char query_HW_Ver;		//0x02
 	unsigned char query_Gpio_In;		//0x0a
 
+	unsigned char config_Model_Name;			//0x83
 	unsigned char config_Gpio_Output;	//0x86
 	unsigned char config_Rtc_Data;		//0x87
 
@@ -66,6 +67,7 @@ extern unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr
 
 extern unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf);
 extern unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *Set_Buf);
+unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname);
 // 13 bytes
 // year : 4, month : 2, day : 2, hour : 2, min : 2, sec : 2
 //extern unsigned char Config_RTC();

binární
EVSE/Projects/DS60-120/Apps/ReadCmdline


+ 16 - 0
EVSE/Projects/DS60-120/Apps/ReadCmdline.c

@@ -461,6 +461,18 @@ void GetRelayStatus(char *v1)
 	printf("RelayKPK2Status = %d \n", _chargingData[_index]->RelayKPK2Status);
 }
 
+void GetSOC(char *v1)
+{
+	int _index = atoi(v1);
+	if (!FindChargingInfoData(_index, &_chargingData[0]))
+	{
+		printf("FindChargingInfoData error\n");
+		return;
+	}
+
+	printf("Soc = %d \n", _chargingData[_index]->EvBatterySoc);
+}
+
 void FwUpdateFlagProc()
 {
 	ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = 0x01;
@@ -1285,6 +1297,10 @@ int main(void)
 			}
 			SetChargingInfoCCID(newString[1], newString[2]);
 		}
+		else if (strcmp(newString[0], "soc") == 0)
+		{
+			GetSOC(newString[1]);
+		}
 		else if (strcmp(newString[0], "test") == 0)
 		{
 			if (!FindChargingInfoData(1, &_chargingData[0]))

binární
EVSE/Projects/DS60-120/Apps/main


+ 1 - 1
EVSE/Projects/DS60-120/Apps/main.c

@@ -154,7 +154,7 @@ bool isModelNameMatch = true;
 
 int rfidFd = -1;
 char* rfidPortName = "/dev/ttyS2";
-char* fwVersion = "V1.03.00.0000.00";
+char* fwVersion = "V1.04.00.0000.00";
 
 sqlite3 *localDb;
 bool isDb_ready;

binární
EVSE/Projects/DS60-120/Images/ramdisk.gz