Explorar o código

[Improve][Modularization][Module_Payment]

2021.05.18 / Folus Wen

Actions:
1. Beep control by host.

Files:
1. As follow commit history

Image version: D0.04
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen %!s(int64=3) %!d(string=hai) anos
pai
achega
3055cabc7b
Modificáronse 2 ficheiros con 26 adicións e 5 borrados
  1. 25 4
      EVSE/Modularization/Module_Payment.c
  2. 1 1
      EVSE/Modularization/Module_Payment.h

+ 25 - 4
EVSE/Modularization/Module_Payment.c

@@ -6,7 +6,7 @@
  */
 
 #include	"Module_Payment.h"
-unsigned char version[]					= {'D', '0', '.', '0', '3'};
+unsigned char version[]					= {'D', '0', '.', '0', '4'};
 unsigned char BLP_CMD_CARD_DETECT[]		= {0x09, 0, 0x07, 'M','F','1','4','1','2','1', 0x32};				// Enable payment, MIFARE, 15693 card; Detect Payment Card First;  Enable ApplePay VAS
 unsigned char BLP_CMD_USI2[]     		= {0x09, 0, 0x03, 'P', 'C', '0', 0x29};								// Configure protocol to USI2
 unsigned char BLP_CMD_SET_BAUD[] 		= {0x09, 0, 0x03, 'B', 'R', '7', 0x2d};								// Configure module baud rate to 115200
@@ -41,7 +41,7 @@ unsigned char USI_CMD_SET_TIME[]		= {0x01, 0, 0, 0x07, '5', '5', 0x0f, 0x1e, 0x2
 unsigned char USI_CMD_ARM_DISABLE[]		= {0x01, 0, 0, 0x02, 'H', '0', '{'};
 unsigned char USI_CMD_NFC_ACTIVE[]		= {0x01, 0, 0, 0x02, 'N', 0x00, 'M'};								// Enable NFC function
 unsigned char USI_CMD_NFC_POLL[]		= {0x01, 0, 0, 0x05, 'N', ' ', '3', 0x02, 0x01, 'Z'};				// Polling FELICA(NFC Type 3, 414kbps)
-
+unsigned char USI_CMD_BEEP_CONTROL[]	= {0x01, 0, 0, 0x05, 'B', '1', 0x7f, 0x09, 0x09, 0x08};				// Beep on 100ms 1 count
 
 int system_command(int uart, unsigned char* cmd, int cmd_len, unsigned char* rx);
 int USI2_Parse(unsigned char* rx, unsigned char* rx_data);
@@ -394,6 +394,19 @@ int USI2_Parse(unsigned char* rx, unsigned char* rx_data)
 	return result;
 }
 
+/**
+ *
+ * @param onCnt: Buzzer on quantity
+ */
+void buzzer_on(int UartFd, uint8_t onCnt)
+{
+	unsigned char rx_Array[512]={0};
+
+	USI_CMD_BEEP_CONTROL[5] = 0x30 + onCnt;
+	USI_CMD_BEEP_CONTROL[ARRAY_SIZE(USI_CMD_BEEP_CONTROL)-1] = calChksum(USI_CMD_BEEP_CONTROL, ARRAY_SIZE(USI_CMD_BEEP_CONTROL));
+	system_command(UartFd, USI_CMD_BEEP_CONTROL, ARRAY_SIZE(USI_CMD_BEEP_CONTROL), rx_Array);
+}
+
 //==========================================
 // Main loop
 //==========================================
@@ -441,7 +454,7 @@ int main(void)
 	}
 	else
 	{
-		DEBUG_INFO("ttyS3 port open success.\n");
+		DEBUG_INFO("%s port open success.\n", TTY_PORT);
 	}
 
 	//===============================================
@@ -875,6 +888,8 @@ int main(void)
 						memcpy(C9_Result.u_id, &C9_Result.result_data[6], 6);
 						DEBUG_INFO("FELICA, UID: %02X-%02X-%02X-%02X-%02X-%02X\n", C9_Result.u_id[0], C9_Result.u_id[1], C9_Result.u_id[2], C9_Result.u_id[3], C9_Result.u_id[4], C9_Result.u_id[5]);
 
+						buzzer_on(UartFd, 1);
+
 						// Wait card removed
 						do
 						{
@@ -976,7 +991,7 @@ int main(void)
 								do
 								{
 									//DEBUG_INFO("C9 response reading...\n");
-									usleep(2000000);
+									usleep(1000000);
 									rx_len = read(UartFd, rx_Array, ARRAY_SIZE(rx_Array)); // read response if data count match 512 or timeout.
 									failCount++;
 								} while ((rx_len == 0) && (failCount < RETRY_LIMIT));
@@ -1022,6 +1037,7 @@ int main(void)
 													DEBUG_INFO("TK[%d]: \n", idx);
 													show_data(C9_Result.tkData[idx], getSentinelPosition(C9_Result.tkData[idx], ARRAY_SIZE(C9_Result.tkData[idx]), 0)+2);
 												}
+												buzzer_on(UartFd, 1);
 												break;
 											case Mifare:
 												data_len = C9_Result.result_data[6];
@@ -1058,6 +1074,7 @@ int main(void)
 														DEBUG_INFO("MIFARE JCOP31, UID: \n");
 														break;
 												}
+												buzzer_on(UartFd, 1);
 												break;
 											case ISO_15693:
 												data_len =(C9_Result.result_data[5]<<8) | C9_Result.result_data[6];
@@ -1065,6 +1082,7 @@ int main(void)
 												memcpy(C9_Result.u_id, &C9_Result.result_data[4+data_len-8], 8);
 
 												DEBUG_INFO("ISO_15693, UID: %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X\n", C9_Result.u_id[0], C9_Result.u_id[1], C9_Result.u_id[2], C9_Result.u_id[3], C9_Result.u_id[4], C9_Result.u_id[5], C9_Result.u_id[6], C9_Result.u_id[7]);
+												buzzer_on(UartFd, 1);
 												break;
 											case Apple_Pay:
 												DEBUG_INFO("Apple_Pay VAS only.\n");
@@ -1077,6 +1095,7 @@ int main(void)
 													DEBUG_INFO("TK[%d]: \n", idx);
 													show_data(C9_Result.tkData[idx], getSentinelPosition(C9_Result.tkData[idx], ARRAY_SIZE(C9_Result.tkData[idx]), 0)+2);
 												}
+												buzzer_on(UartFd, 1);
 												break;
 											case No_Data:
 												//DEBUG_INFO("No any data.\n");
@@ -1129,6 +1148,7 @@ int main(void)
 									{
 										DEBUG_INFO("C9 Parsing result fail.\n");
 										C9_Result.isCommandError = ON;
+										buzzer_on(UartFd, 3);
 										// Wait card removed
 										do
 										{
@@ -1165,6 +1185,7 @@ int main(void)
 								else
 								{
 									DEBUG_WARN("C9 Response timeout: %d \n", failCount);
+									buzzer_on(UartFd, 3);
 								}
 							}
 						}

+ 1 - 1
EVSE/Modularization/Module_Payment.h

@@ -42,7 +42,7 @@
 #include	<stdint.h>
 #ifndef X86
 	#include	"define.h"
-	#define TTY_PORT		"/dev/ttyS3"
+	#define TTY_PORT		"/dev/ttyS2"
 #else
 	#define ConsloePrintLog
 	#define TTY_PORT		"/dev/ttyUSB0"