Browse Source

2020-08-31 / Alston Lin

Actions
1. Add filter function to infypwrLib
2. Add flag for recording the remotestart charging method
Files
1. As follow commit history
Alston 4 years ago
parent
commit
330f4bb612
2 changed files with 52 additions and 1 deletions
  1. 51 1
      EVSE/Modularization/Infypwr_PsuCommObj.c
  2. 1 0
      EVSE/Projects/define.h

+ 51 - 1
EVSE/Modularization/Infypwr_PsuCommObj.c

@@ -7,12 +7,19 @@
 
 #include "Infypwr_PsuCommObj.h"
 
+#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
+#define NO		0
+#define YES		1
+
 #define DEBUG_LIB						1
 
 void PRINTF_LIB_FUNC(char *string, ...);
 float IEEE_754_to_float(const byte raw[4]);
 void IEEE_754_to_bytes(float target, byte *bytes2);
 
+// ³]³Æ¸¹ 0x09 »P 0x0C ¦ü¥G¬O¼Ò¶ô
+unsigned int filter[3] = { 0x87570000, 0x8E9B0000, 0x829B0000 };
+
 //================================================
 // Private function
 //================================================
@@ -147,6 +154,7 @@ int InitCanBus()
 	struct timeval			tv;
 	struct ifreq 			ifr0;
 	struct sockaddr_can		addr0;
+	//struct can_filter 		rfilter[2];
 
 	system("/sbin/ip link set can1 down");
 	system("/sbin/ip link set can1 type can bitrate 500000 restart-ms 100");
@@ -176,6 +184,18 @@ int InitCanBus()
 		PRINTF_LIB_FUNC("Set SO_SNDBUF NG");
 		#endif
 	}
+	nbytes=40960;
+//	rfilter[0].can_id = 0x0757F803 | CAN_EFF_FLAG;
+//	rfilter[0].can_mask = (CAN_EFF_FLAG | CAN_RTR_FLAG | CAN_EFF_MASK);
+//	rfilter[1].can_id = 0x0757F80B | CAN_EFF_FLAG;
+//	rfilter[1].can_mask = (CAN_EFF_FLAG | CAN_RTR_FLAG | CAN_EFF_MASK);
+//
+//	if (setsockopt(s0, CAN_INV_FILTER, CAN_RAW_FILTER_MAX, &rfilter, sizeof(rfilter)) < 0)
+//	{
+//		#ifdef SystemLogMessage
+//		printf("*********************************Set SOL_CAN_RAW NG");
+//		#endif
+//	}
 
    	strcpy(ifr0.ifr_name, "can1" );
 	ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
@@ -188,6 +208,22 @@ int InitCanBus()
 //================================================
 // Receive Cmd from canbus
 //================================================
+byte isFilterValue(unsigned int value)
+{
+	byte result = NO;
+
+	for(byte i = 0; i < ARRAY_SIZE(filter); i++)
+	{
+		if (value == filter[i])
+		{
+			result = YES;
+			break;
+		}
+	}
+
+	return result;
+}
+
 void ReceiveDataFromCanBus()
 {
 	int nbytes;
@@ -202,6 +238,19 @@ void ReceiveDataFromCanBus()
 
 		if (nbytes > 0)
 		{
+			if (isFilterValue(frame.can_id & 0xFFFF0000) == YES)
+				continue;
+
+//			if (frame.can_id == 0x82caf000 || frame.can_id == 0x82caf001 ||
+//					frame.can_id == 0x82c1f000 || frame.can_id == 0x82c1f001 ||
+//					frame.can_id == 0x82ccf000 || frame.can_id == 0x82ccf001 ||
+//					frame.can_id == 0x9901ff00 || frame.can_id == 0x9902ff00 || frame.can_id == 0x9903ff00 ||
+//					frame.can_id == 0x9901ff01 || frame.can_id == 0x9902ff01 || frame.can_id == 0x9903ff01 ||
+//					frame.can_id == 0x82c7f000 || frame.can_id == 0x82c7f001)
+//			{}
+//			else
+//				printf("can_id = %x \n", frame.can_id);
+
 			frame.can_id = frame.can_id & CAN_EFF_MASK;
 			intCmd = frame.can_id & 0x00FF0000;
 			intCmd |= INFYPWR_GROUP_SHIFT | intCmd;
@@ -399,7 +448,8 @@ void ReceiveDataFromCanBus()
 					break;
 			}
 		}
-		usleep(10000);
+		else
+			usleep(10000);
 	}
 }
 

+ 1 - 0
EVSE/Projects/define.h

@@ -478,6 +478,7 @@ struct ChargingInfoData
 	char 				RemoteStartFlag;
 	unsigned char 		MaxChargingToAverPassFlag;
 	unsigned char		EVCCID[18];						//the MAC address of the EVCC in Hex
+	unsigned char 		isRemoteStart;
 };
 
 struct SysInfoData