|
@@ -31,6 +31,7 @@
|
|
|
//==================================
|
|
|
// HOST ID, offset = 0, length = 2 bytes ,
|
|
|
//==================================
|
|
|
+unsigned char HOST_ID_Auto[] = {0x30, 0x30};//信用卡/ 電子票證/ 掃碼支付
|
|
|
unsigned char HOST_ID_CreditCard[] = {0x31, 0x30};//信用卡
|
|
|
unsigned char HOST_ID_eTicket_Polling[] = {0x35, 0x30};//電子票證
|
|
|
|
|
@@ -94,7 +95,7 @@ int SendRequest(int uart, unsigned char* cmd, int length)
|
|
|
int len, TotalRtn=0, Rtn,i;
|
|
|
unsigned int StartTime;
|
|
|
unsigned char LRC=0;
|
|
|
- unsigned char SendBuffer[RequestLength+4], RecvBuf[8];
|
|
|
+ unsigned char SendBuffer[RequestLength+4];
|
|
|
|
|
|
len=length+3;
|
|
|
memset(SendBuffer,0,RequestLength+4);
|
|
@@ -221,7 +222,7 @@ reRecv:
|
|
|
}
|
|
|
memset(tmpBuf,0,sizeof(tmpBuf));
|
|
|
memcpy(tmpBuf,RecvBuffer+1,8 );
|
|
|
- if((strstr(tmpBuf,"00000000")==NULL)&&(strstr(tmpBuf,"000000TD")==NULL))
|
|
|
+ if((strstr((char *)tmpBuf,"00000000")==NULL)&&(strstr((char *)tmpBuf,"000000TD")==NULL))
|
|
|
{
|
|
|
DEBUG_INFO_1("RecvResponse: Response Code failed (%s)\n", tmpBuf);
|
|
|
memset(tmpBuf,0,sizeof(tmpBuf));
|
|
@@ -255,13 +256,13 @@ reRecv:
|
|
|
//==========================================
|
|
|
int CreditCardSearch(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoReturn)
|
|
|
{
|
|
|
- unsigned char Buffer[RequestLength], *ptr, tmpbuf[12];
|
|
|
+ unsigned char Buffer[RequestLength], *ptr;
|
|
|
|
|
|
memset(Buffer,0x20,RequestLength);
|
|
|
ptr=Buffer;
|
|
|
- strncpy(ptr,HOST_ID_CreditCard,2);//Host ID
|
|
|
+ strncpy((char *)ptr,(char *)HOST_ID_Auto,2);//Host ID
|
|
|
ptr+=2;
|
|
|
- strncpy(ptr,TRANS_TYPE_Search,2);//Transaction type
|
|
|
+ strncpy((char *)ptr,(char *)TRANS_TYPE_Search,2);//Transaction type
|
|
|
ptr+=2;
|
|
|
/*memset(tmpbuf,0,sizeof(tmpbuf));
|
|
|
sprintf(tmpbuf,"%d", PreCost);
|
|
@@ -278,7 +279,7 @@ int CreditCardSearch(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoRe
|
|
|
ptr+=12;//Approval No
|
|
|
//strncpy(ptr,CardNum, strlen(CardNum));
|
|
|
ptr+=20;//Card No
|
|
|
- strncpy(ptr,EVSEID, strlen(EVSEID));
|
|
|
+ strncpy((char *)ptr,(char *)EVSEID, strlen((char *)EVSEID));
|
|
|
ptr+=18;//Store Id
|
|
|
//ptr+=2;//Period
|
|
|
if(SendRequest(Fd, Buffer, RequestLength)>0)
|
|
@@ -286,9 +287,9 @@ int CreditCardSearch(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoRe
|
|
|
memset(Buffer,0,RequestLength);
|
|
|
if(RecvResponse(Fd,Buffer)>0)
|
|
|
{
|
|
|
- strncpy(TransInfoReturn->TransDate,Buffer+56,6);
|
|
|
- strncpy(TransInfoReturn->TransTime,Buffer+62,6);
|
|
|
- strncpy(TransInfoReturn->CardNo,Buffer+24,20);
|
|
|
+ strncpy((char *)TransInfoReturn->TransDate,(char *)Buffer+56,6);
|
|
|
+ strncpy((char *)TransInfoReturn->TransTime,(char *)Buffer+62,6);
|
|
|
+ strncpy((char *)TransInfoReturn->CardNo,(char *)Buffer+24,20);
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
@@ -323,23 +324,23 @@ int CreditCardPreAuth(int Fd, int PreCost,unsigned char *EVSEID, struct TransInf
|
|
|
|
|
|
memset(Buffer,0x20,RequestLength);
|
|
|
ptr=Buffer;
|
|
|
- strncpy(ptr,HOST_ID_CreditCard,2);//Host ID
|
|
|
+ strncpy((char *)ptr,(char *)HOST_ID_CreditCard,2);//Host ID
|
|
|
ptr+=2;
|
|
|
- strncpy(ptr,TRANS_TYPE_Pre_Auth,2);//Transaction type
|
|
|
+ strncpy((char *)ptr,(char *)TRANS_TYPE_Pre_Auth,2);//Transaction type
|
|
|
ptr+=2;
|
|
|
memset(tmpbuf,0,sizeof(tmpbuf));
|
|
|
- sprintf(tmpbuf,"%d", PreCost);
|
|
|
- if(strlen(tmpbuf)>12)
|
|
|
+ sprintf((char *)tmpbuf,"%d", PreCost);
|
|
|
+ if(strlen((char *)tmpbuf)>12)
|
|
|
{
|
|
|
DEBUG_INFO_1("CreditCardPreAuth: Wrong PreCost (PreCost=%d)\n", PreCost);
|
|
|
return -1;
|
|
|
}
|
|
|
memset(ptr,0x30,12);
|
|
|
- strncpy(ptr+12-(strlen(tmpbuf)+2),tmpbuf,strlen(tmpbuf));//Trans Amount
|
|
|
+ strncpy((char *)ptr+12-(strlen((char *)tmpbuf)+2),(char *)tmpbuf,strlen((char *)tmpbuf));//Trans Amount
|
|
|
ptr+=12;//Trans Amount
|
|
|
ptr+=12;//Approval No
|
|
|
ptr+=20;//Card No
|
|
|
- strncpy(ptr,EVSEID, strlen(EVSEID));
|
|
|
+ strncpy((char *)ptr,(char *)EVSEID, strlen((char *)EVSEID));
|
|
|
ptr+=18;//Store Id
|
|
|
//ptr+=2;//Period
|
|
|
if(SendRequest(Fd, Buffer, RequestLength)>0)
|
|
@@ -349,15 +350,15 @@ int CreditCardPreAuth(int Fd, int PreCost,unsigned char *EVSEID, struct TransInf
|
|
|
{
|
|
|
//for(int i=0;i<RequestLength;i++)
|
|
|
//printf("%x, ",Buffer[i] );
|
|
|
- strncpy(TransInfoReturn->TransAmount,Buffer+44,12);
|
|
|
- strncpy(TransInfoReturn->TransDate,Buffer+56,6);
|
|
|
- strncpy(TransInfoReturn->TransTime,Buffer+62,6);
|
|
|
- strncpy(TransInfoReturn->StoreId,Buffer+97,18);
|
|
|
- strncpy(TransInfoReturn->ROC,Buffer+12,12);
|
|
|
- strncpy(TransInfoReturn->ApprovalNo,Buffer+115,9);
|
|
|
- strncpy(TransInfoReturn->RRN,Buffer+124,12);
|
|
|
- strncpy(TransInfoReturn->CardNo,Buffer+24,20);
|
|
|
- strncpy(TransInfoReturn->VemData,Buffer+246,64);
|
|
|
+ strncpy((char *)TransInfoReturn->TransAmount,(char *)Buffer+44,12);
|
|
|
+ strncpy((char *)TransInfoReturn->TransDate,(char *)Buffer+56,6);
|
|
|
+ strncpy((char *)TransInfoReturn->TransTime,(char *)Buffer+62,6);
|
|
|
+ strncpy((char *)TransInfoReturn->StoreId,(char *)Buffer+97,18);
|
|
|
+ strncpy((char *)TransInfoReturn->ROC,(char *)Buffer+12,12);
|
|
|
+ strncpy((char *)TransInfoReturn->ApprovalNo,(char *)Buffer+115,9);
|
|
|
+ strncpy((char *)TransInfoReturn->RRN,(char *)Buffer+124,12);
|
|
|
+ strncpy((char *)TransInfoReturn->CardNo,(char *)Buffer+24,20);
|
|
|
+ strncpy((char *)TransInfoReturn->VemData,(char *)Buffer+246,64);
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
@@ -387,40 +388,40 @@ int CreditCardPreAuthComplete(int Fd, int PreCost,unsigned char *EVSEID, unsigne
|
|
|
|
|
|
memset(Buffer,0x20,RequestLength);
|
|
|
ptr=Buffer;
|
|
|
- strncpy(ptr,HOST_ID_CreditCard,2);//Host ID
|
|
|
+ strncpy((char *)ptr,(char *)HOST_ID_CreditCard,2);//Host ID
|
|
|
ptr+=2;
|
|
|
- strncpy(ptr,TRANS_TYPE_Pre_Auth_Complete,2);//Transaction type
|
|
|
+ strncpy((char *)ptr,(char *)TRANS_TYPE_Pre_Auth_Complete,2);//Transaction type
|
|
|
ptr+=2;
|
|
|
memset(tmpbuf,0,sizeof(tmpbuf));
|
|
|
- sprintf(tmpbuf,"%d", PreCost);
|
|
|
- if(strlen(tmpbuf)>12)
|
|
|
+ sprintf((char *)tmpbuf,"%d", PreCost);
|
|
|
+ if(strlen((char *)tmpbuf)>12)
|
|
|
{
|
|
|
DEBUG_INFO_1("CreditCardAuthComplete: Wrong PreCost (PreCost=%d)\n", PreCost);
|
|
|
return -1;
|
|
|
}
|
|
|
memset(ptr,0x30,12);
|
|
|
- strncpy(ptr+12-(strlen(tmpbuf)+2),tmpbuf,strlen(tmpbuf));//Trans Amount
|
|
|
+ strncpy((char *)ptr+12-(strlen((char *)tmpbuf)+2),(char *)tmpbuf,strlen((char *)tmpbuf));//Trans Amount
|
|
|
ptr+=12;//Trans Amount
|
|
|
ptr+=12;//Approval No
|
|
|
ptr+=20;//Card No
|
|
|
- strncpy(ptr,EVSEID, strlen(EVSEID));
|
|
|
+ strncpy((char *)ptr,(char *)EVSEID, strlen((char *)EVSEID));
|
|
|
ptr+=18;//Store Id
|
|
|
//ptr+=2;//Period
|
|
|
- strncpy(Buffer+500,VemData,64);
|
|
|
+ strncpy((char *)Buffer+500,(char *)VemData,64);
|
|
|
if(SendRequest(Fd, Buffer, RequestLength)>0)
|
|
|
{
|
|
|
memset(Buffer,0,RequestLength);
|
|
|
if(RecvResponse(Fd,Buffer)>0)
|
|
|
{
|
|
|
- strncpy(TransInfoReturn->TransAmount,Buffer+44,12);
|
|
|
- strncpy(TransInfoReturn->TransDate,Buffer+56,6);
|
|
|
- strncpy(TransInfoReturn->TransTime,Buffer+62,6);
|
|
|
- strncpy(TransInfoReturn->StoreId,Buffer+97,18);
|
|
|
- strncpy(TransInfoReturn->ROC,Buffer+12,12);
|
|
|
- strncpy(TransInfoReturn->ApprovalNo,Buffer+115,9);
|
|
|
- strncpy(TransInfoReturn->RRN,Buffer+124,12);
|
|
|
- strncpy(TransInfoReturn->CardNo,Buffer+24,20);
|
|
|
- strncpy(TransInfoReturn->VemData,Buffer+246,64);
|
|
|
+ strncpy((char *)TransInfoReturn->TransAmount,(char *)Buffer+44,12);
|
|
|
+ strncpy((char *)TransInfoReturn->TransDate,(char *)Buffer+56,6);
|
|
|
+ strncpy((char *)TransInfoReturn->TransTime,(char *)Buffer+62,6);
|
|
|
+ strncpy((char *)TransInfoReturn->StoreId,(char *)Buffer+97,18);
|
|
|
+ strncpy((char *)TransInfoReturn->ROC,(char *)Buffer+12,12);
|
|
|
+ strncpy((char *)TransInfoReturn->ApprovalNo,(char *)Buffer+115,9);
|
|
|
+ strncpy((char *)TransInfoReturn->RRN,(char *)Buffer+124,12);
|
|
|
+ strncpy((char *)TransInfoReturn->CardNo,(char *)Buffer+24,20);
|
|
|
+ strncpy((char *)TransInfoReturn->VemData,(char *)Buffer+246,64);
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
@@ -451,28 +452,28 @@ int CreditCardPreAuthCancel(int Fd, int PreCost,unsigned char *EVSEID, unsigned
|
|
|
|
|
|
memset(Buffer,0x20,RequestLength);
|
|
|
ptr=Buffer;
|
|
|
- strncpy(ptr,HOST_ID_CreditCard,2);//Host ID
|
|
|
+ strncpy((char *)ptr,(char *)HOST_ID_CreditCard,2);//Host ID
|
|
|
ptr+=2;
|
|
|
- strncpy(ptr,TRANS_TYPE_Pre_Auth_Cancel,2);//Transaction type
|
|
|
+ strncpy((char *)ptr,(char *)TRANS_TYPE_Pre_Auth_Cancel,2);//Transaction type
|
|
|
ptr+=2;
|
|
|
memset(tmpbuf,0,sizeof(tmpbuf));
|
|
|
- sprintf(tmpbuf,"%d", PreCost);
|
|
|
- if(strlen(tmpbuf)>12)
|
|
|
+ sprintf((char *)tmpbuf,"%d", PreCost);
|
|
|
+ if(strlen((char *)tmpbuf)>12)
|
|
|
{
|
|
|
DEBUG_INFO_1("CreditCardPreAuthCancel: Wrong PreCost (PreCost=%d)\n", PreCost);
|
|
|
return -1;
|
|
|
}
|
|
|
memset(ptr,0x30,12);
|
|
|
- strncpy(ptr+12-(strlen(tmpbuf)+2),tmpbuf,strlen(tmpbuf));//Trans Amount
|
|
|
+ strncpy((char *)ptr+12-(strlen((char *)tmpbuf)+2),(char *)tmpbuf,strlen((char *)tmpbuf));//Trans Amount
|
|
|
ptr+=12;//Trans Amount
|
|
|
- strncpy(ptr,ApprovalNo, strlen(ApprovalNo));
|
|
|
+ strncpy((char *)ptr,(char *)ApprovalNo, strlen((char *)ApprovalNo));
|
|
|
ptr+=12;//Approval No
|
|
|
- strncpy(ptr,CardNum, strlen(CardNum));
|
|
|
+ strncpy((char *)ptr,(char *)CardNum, strlen((char *)CardNum));
|
|
|
ptr+=20;//Card No
|
|
|
- strncpy(ptr,EVSEID, strlen(EVSEID));
|
|
|
+ strncpy((char *)ptr,(char *)EVSEID, strlen((char *)EVSEID));
|
|
|
ptr+=18;//Store Id
|
|
|
//ptr+=2;//Period
|
|
|
- strncpy(Buffer+500,VemData,64);
|
|
|
+ strncpy((char *)Buffer+500,(char *)VemData,64);
|
|
|
if(SendRequest(Fd, Buffer, RequestLength)>0)
|
|
|
{
|
|
|
memset(Buffer,0,RequestLength);
|
|
@@ -501,13 +502,13 @@ int CreditCardPreAuthCancel(int Fd, int PreCost,unsigned char *EVSEID, unsigned
|
|
|
//==========================================
|
|
|
int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoReturn)
|
|
|
{
|
|
|
- unsigned char Buffer[RequestLength], *ptr, tmpbuf[12];
|
|
|
+ unsigned char Buffer[RequestLength], *ptr;
|
|
|
|
|
|
memset(Buffer,0x20,RequestLength);
|
|
|
ptr=Buffer;
|
|
|
- strncpy(ptr,HOST_ID_CreditCard,2);//Host ID
|
|
|
+ strncpy((char *)ptr,(char *)HOST_ID_CreditCard,2);//Host ID
|
|
|
ptr+=2;
|
|
|
- strncpy(ptr,TRANS_TYPE_UnionSettlement,2);//Transaction type
|
|
|
+ strncpy((char *)ptr,(char *)TRANS_TYPE_UnionSettlement,2);//Transaction type
|
|
|
ptr+=2;
|
|
|
/*memset(tmpbuf,0,sizeof(tmpbuf));
|
|
|
sprintf(tmpbuf,"%d", PreCost);
|
|
@@ -524,7 +525,7 @@ int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID, struct TransInfo *Tr
|
|
|
ptr+=12;//Approval No
|
|
|
//strncpy(ptr,CardNum, strlen(CardNum));
|
|
|
ptr+=20;//Card No
|
|
|
- strncpy(ptr,EVSEID, strlen(EVSEID));
|
|
|
+ strncpy((char *)ptr,(char *)EVSEID, strlen((char *)EVSEID));
|
|
|
ptr+=18;//Store Id
|
|
|
//ptr+=2;//Period
|
|
|
if(SendRequest(Fd, Buffer, RequestLength)>0)
|
|
@@ -532,15 +533,15 @@ int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID, struct TransInfo *Tr
|
|
|
memset(Buffer,0,RequestLength);
|
|
|
if(RecvResponse(Fd,Buffer)>0)
|
|
|
{
|
|
|
- strncpy(TransInfoReturn->TransAmount,Buffer+44,12);
|
|
|
- strncpy(TransInfoReturn->TransDate,Buffer+56,6);
|
|
|
- strncpy(TransInfoReturn->TransTime,Buffer+62,6);
|
|
|
- strncpy(TransInfoReturn->StoreId,Buffer+97,18);
|
|
|
- strncpy(TransInfoReturn->ROC,Buffer+12,12);
|
|
|
- strncpy(TransInfoReturn->ApprovalNo,Buffer+115,9);
|
|
|
- strncpy(TransInfoReturn->RRN,Buffer+124,12);
|
|
|
- strncpy(TransInfoReturn->CardNo,Buffer+24,20);
|
|
|
- strncpy(TransInfoReturn->VemData,Buffer+246,64);
|
|
|
+ strncpy((char *)TransInfoReturn->TransAmount,(char *)Buffer+44,12);
|
|
|
+ strncpy((char *)TransInfoReturn->TransDate,(char *)Buffer+56,6);
|
|
|
+ strncpy((char *)TransInfoReturn->TransTime,(char *)Buffer+62,6);
|
|
|
+ strncpy((char *)TransInfoReturn->StoreId,(char *)Buffer+97,18);
|
|
|
+ strncpy((char *)TransInfoReturn->ROC,(char *)Buffer+12,12);
|
|
|
+ strncpy((char *)TransInfoReturn->ApprovalNo,(char *)Buffer+115,9);
|
|
|
+ strncpy((char *)TransInfoReturn->RRN,(char *)Buffer+124,12);
|
|
|
+ strncpy((char *)TransInfoReturn->CardNo,(char *)Buffer+24,20);
|
|
|
+ strncpy((char *)TransInfoReturn->VemData,(char *)Buffer+246,64);
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
@@ -634,4 +635,4 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|