0% found this document useful (0 votes)
276 views27 pages

CRT-288 DLL Specification

This document provides a summary of a specification for a Windows DLL that interfaces with RFID and magnetic stripe card readers. The DLL includes: 1. Header and library files for Windows 32-bit environment. 2. Functions for opening and closing communication ports and executing commands to interface with readers for various card types including RFID and magnetic stripe cards. 3. Sample code demonstrating usage with different programming languages and environments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
276 views27 pages

CRT-288 DLL Specification

This document provides a summary of a specification for a Windows DLL that interfaces with RFID and magnetic stripe card readers. The DLL includes: 1. Header and library files for Windows 32-bit environment. 2. Functions for opening and closing communication ports and executing commands to interface with readers for various card types including RFID and magnetic stripe cards. 3. Sample code demonstrating usage with different programming languages and environments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Model No.

CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 1/27

·Windows DLL Specification


Provide Windows32 DLL on windows environment platform, files’ names as following:
1. CRT_288.H 32 digit dynamic library header file
2. CRT_288.LIB 32 digit input dynamic library
3. CRT_288.DLL Windows32 DLL file

·Applicable Card Type


1. RF Card: ISO/IEC 14443 TYPE A / B, MIFARE one (S50, S70, UL)
2. Contact IC Card:
SLE4428, SLE4442
24C01A, 24C02, 24C04, 24C08, 24C16, 24C32, 24C64
Contact CPU Card (T=0/T=1)
SAM/SIM Card(T=0/T=1)
3. Magnetic card (Read only)

Notes:
1. Code examples of DLL running on VC6, VB6, DELPHI7, C++BUILD6, PB9, VB2005.NET,
V#2005.NET environment are provided.
2. DLL running on Linux/Unix (.so) is provided for large demand.
3. JAVA environment technical support (comm.jar and RXTXcomm.jar) is provided for large
demand.
4. Technical support for OCX and website script control is available
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 2/27

CONTENTS
1. Combination of Function Parameter...................................................................................... 3

1.1 Function Parameter Specification According to Communication Protocol............... 3

2. API Reference Instruction ( RS-232 Interface)......................................................................4

2.1 Function for Open Com Port (Default Baud rate: 38400bps)......................................4

2.2 Function for Open Com Port by Specified Baud Rate..................................................5

2.3 Function For Close Com Port.......................................................................................... 6

2.4 Function for Execution of Command..............................................................................7

3 API Reference Instruction2 (USB Interface)...........................................................................8

3.1 Function for Open USB.................................................................................................... 8

3.2 Function For Close of USB Interface..............................................................................9

3.3 Function For Open Multiple USB Interface................................................................ 10

3.4 Function For Close Multiple USB Device.....................................................................11

3.5 Function For Command Execution...............................................................................12

4. Sample Code............................................................................................................................ 13

4.1 Command List................................................................................................................. 13

4.2 Function Calling Instruction..........................................................................................14

4.3 Sample Code 1 (Magnetic Stripe Card Operation)..................................................15

4.4 Sample Code 2 (CPU Card Operation)........................................................................ 22


Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 3/27

1. Combination of Function Parameter


1.1 Function Parameter Specification According to Communication Protocol
1. Command format ( HOST -> ICRW )
TxPmCode =0x33
TxCmCode=0x51

F2 00 08 43 51 33 00 84 00 00 08 03 54

TxDataLen=0x05 TxData={0x00,0x84,0x00,0x00,0x08}

2. Positive response format ( ICRW -> HOST )


RxCmCode=0x51 RxPmCode =0x33 RxDataLen =0x0a
RxData ={0x22,0x53, 0x85,0xFF,0xEC,0XB5,0x9F,0Xb4,0x90,0x00}

F2 00 0F 50 51 33 31 32 22 53 85 FF EC B5 9F B4 90 00 03 26

RxStCode1=0x31 RxStCode0=0x32

RxReplyType=0x50

3. Negative response format ( ICRW -> HOST )


RxCmCode=0x36 RxPmCode =0x31 RxDataLen =0x0B
RxData ={0x4E,0x32,0x36,0x7E,0x32,0x36,0x7E,0x32,0x36 }

F2 00 10 4E 36 31 31 32 4E 32 36 7E 4E 32 36 7E 4E 32 36 03 E1

RxStCode1=0x31 RxStCode0=0x32

RxReplyType=0x4E

Notes:
Positive Response: RxReplyType=0x50; RxStCode1and RxStCode0 is reader status code
Negative Response: RxReplyType=0x4E; RxStCode1 and RxStCode0 is error code
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 4/27

2. API Reference Instruction ( RS-232 Interface)


2.1 Function for Open Com Port (Default Baud rate: 38400bps)
HANDLE APIENTRY CRT288ROpen(char *Port);
Parameter:
Port: Com Port Number String
E.g. : CRT288ROpen ("COM1");
Return:
Handle For Com Port
· 0 (Com open failure)
Possible reason for Com open failure:
① Invalid Com Port Number String
② This Com is occupied by other devices
· <>0 Com Open Success

Notes:
1) Call this function and return specified handle for Com port before calling of other functions.
2) Enable to open several com ports to get Com port number string for each, but disable to open one port
twice simultaneously.
3) Close Com port by calling CRT288RClose() after use.
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 5/27

2.2 Function for Open Com Port by Specified Baud Rate


HANDLE APIENTRY CRT288ROpenWithBaut(char *Port, unsigned int Baudrate);
Parameter:
Port: Com Port Number String
Baudrate: Baud rate
Baud Rate=9600,19200,38400,57600,115200。
E.g.: CRT288ROpenWithBaut ("COM1",38400);
Return:
Handle For Com Port
· 0 (Com open failure)
Possible reason for Com open failure:
① Invalid Com Port Number String
② This Com is occupied by other devices
· <>0 Com Open Success

Notes:
1) Call this function and return specified handle for Com port before calling of other functions.
2) Enable to open several com ports to get Com port number string for each, but unable to open one port
twice simultaneously.
3) Close Com port by calling CRT288RClose() after use.
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 6/27

2.3 Function For Close Com Port


int APIENTRY CRT288RClose(HANDLE ComHandle);
Parameter:
ComHandle: Com Handle
Return:
=0 Success
<>0 Fail

Notes:
CRT288ROpen () used together with CRT288ROpenWithBaut, call this function to close Com port
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 7/27

2.4 Function for Execution of Command


int APIENTRY RS232_ExeCommand(HANDLE ComHandle,BYTE TxCmCode,BYTE TxPmCode,
int TxDataLen,BYTE TxData[],
BYTE *RxReplyType,BYTE *RxStCode1,BYTE *RxStCode0,
int *RxDataLen,BYTE RxData[])
Execute command and return reply
Parameter:
ComHandle: Com Handle
TxCmCode: Command CM
TxPmCode: Command PM
TxDataLen: Length of Data Package
TxData: Data
RxReplyType: Reply Type
0x50 : Success
0x4E : Fail
0x10 : Cancel by Lower Machine (NAK )
0x20 : Communication Error
0x30 : Cancel by HOST machine (EOT)
RxStCode1: Return Status Code1 // Specific Information Please Refer to Communication Protocol
RxStCode0: Return Status Code0 // Specific Information Please Refer to Communication Protocol
RxDataLen: Length of Reply Data Package
RxData: Reply Data
Return:
=0 Success
<>0 Fail
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 8/27

3 API Reference Instruction2 (USB Interface)


3.1 Function for Open USB
HANDLE APIENTRY CRT288UOpen ();
Parameter:
E.g.: CRT288Uopen();
Return:
· =0 (Open USB Interface Fail)
Possible reason for Failure:
①The machine is not connected; please check the power cable and communication cable connection.
②Power supply is not complied with specification, check if the power is 5V and for better work
performance, the current should be around 150 mA
· <>0 Open USB Interface success

Notes:
1) Call this function first to obtain device handle and USB_ExeCommand is available to use.
2) Close com port through function of CRT310UClose() after use.
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 9/27

3.2 Function For Close of USB Interface


int APIENTRY CRT288UClose (HANDLE ComHandle);;
Parameter:
ComHandle: Com Port Handle
Return:
=0 Success
<>0 Fail

Notes:
CRT288UClose() should be used together with CRT288UOpen(), Call this function to close after use
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 10/27

3.3 Function For Open Multiple USB Interface


int APIENTRY CRT288UMultOpen(HANDLE DeviceHdlData[],int *DeviceNumbers);
Parameter:
DeviceHdlData: Device Handle Data
DeviceNumbers: Device Number
Return:
=0 Success
<>0 Fail

Notes:
1) Other function can not be called, unless call this function first to get device handle.
2) Enable to open device to device handle data for each, but unable to open one port twice simultaneously.
3 ) After use of CRT-288, call CRT288UClose (Close solely one device) or CRT288UMultClose (Close Multiple
Device) to close device
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 11/27

3.4 Function For Close Multiple USB Device


int APIENTRY CRT288UMultClose(HANDLE DeviceHdlData[],int DeviceNumbers);
Parameter:
DeviceHdlData: Device Handle Data
DeviceNumbers: Device Number
Return:
=0 Success

Call CRT288UMultClose to close multiple devices. This function should be used together with CRT288UmultOpen
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 12/27

3.5 Function For Command Execution


int APIENTRY RS232_ExeCommand(HANDLE ComHandle,BYTE TxCmCode,BYTE TxPmCode,
int TxDataLen,BYTE TxData[],
BYTE *RxReplyType,BYTE *RxStCode1,BYTE *RxStCode0,
int *RxDataLen,BYTE RxData[])
Execute command and return reply
Parameter:
ComHandle: Com Port Handle
TxCmCode: Command CM
TxPmCode: Command PM
TxDataLen: Length of Data Package
TxData: Data
RxReplyType: Reply Type
0x50 : Success
0x4E : Fail
0x10 : Cancel by lower machine (NAK )
0x20 : Communication Error
0x30 : Cancel by HOST machine (EOT)
RxStCode1: Return Status Code 1 // Refer to Communication Protocol about Status Code
RxStCode0: Return Status Code 0 // Refer to Communication Protocol about Status Code
RxDataLen: Length of reply data
RxData: Reply Data
Return:
=0 Success
<>0 Fail ( Close USB connection and re-run CRT288Uopen to connect device)
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 13/27

4. Sample Code
4.1 Command List
CM: Command code pm: Parameters (The command specification please refer to communication Protocol)
Command Functions CM PM Description
30H Initialized and release the lock
Initialize Initialize CRT-288 30H
31H Initialized and keep lock up
30H Latch lock up
31H Latch release
Latch Latch Operation B0H
32H Auto-Lock when card insert
33H Non-Lock when card insert

Serial Number Read reader’s serial number A2H 30H Read serial number

Inquire the current status of


Status request 31H 30H Obtain status code ST0, ST1
reader
30H LED indicator on/off control
LED Indicator Control of two LED indicators 80H
31H LED indicator flicker control
30H Auto test IC card type
Auto Test Card Type 50H
31H Auto test RF card type
30H Reading method (Pulling / Withdraw)
Magnetic Stripe Card Magnetic Stripe Card 31H Read magnetic stripe card data buffer
36H
Operation Application 32H Actively uploading magnetic stripe data
39H Clear magnetic stripe card buffer
30H CPU Card Reset (Initialization)
31H CPU card power down
32H CPU card status inquiry
33H T=0 CPU Card APDU operation
CPU Card Operation CPU card application 51H
34H T=1 CPU Card APDU operation
38H CPU card warm reset
Auto select T=0/T=1 CPU card APDU
39H
operation
30H SAM Card reset (Initialization)
31H SAM Card power down
32H SAM Card status inquiry
33H T=0 SAM Card APDU Operation
SAM Card Operation SAM Card application 52H 34H T=1 SAM Card APDU Operation
38H SAM Card warm reset
Auto Select T=0/T=1 SAM Card APDU
39H
Operation
40H Select SAM Card stand
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 14/27

30H SLE4442/4428 reset (Initialization)


31H SLE4442/4428 power down (Release)
SLE4442/4428 Card
53H 32H Inquire SLE4442/4428 status
Operation
33H Operate SLE4442 card
34H Operate SLE4428 card
30H I²C card reset (Initialization)
31H I²C card power down(Release)
I²C Memory Card 24C01—24C256 card
54H 32H Inquire I²C card status
Operation application
33H Read I²C card data
34H Write I²C card data
30H RF card reset (Initialization)
31H RF card power down
Contactless IC Card
Mifare one Type A & B 32H Inquire RF card status
Operation 60H
T=CL protocol 33H Mifare card operation
(13.56 MHZ)
34H Type A RF card communication
35H Type B RF card communication
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 15/27

4.2 Function Calling Instruction


The calling process for USB and RS232 is the same
1. Device Connection
USB interface call CRT288UOpen function and RS232 interface CRT288ROpen function
2. Communication Process
USB interface call USB_ExeCommand function and RS232 interface RS232_ExeCommand function
USB interface will automatically close USB device if function calling is unsuccessful and need to execute CRT288UOpen
to re-connect the device
RS232 interface will not close the Com port if function calling is unsuccesful
3. Device Disconnection
USB interface call CRT288UClose and RS232 interface CRT288RClose function
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 16/27

4.3 Sample Code 1 (Magnetic Stripe Card Operation)

HANDLE hCom; // Target device's HANDLE


int rc=0; //Result
unsigned char CmCode;
unsigned char PmCode;
int CmDataLen;
unsigned char CmData[1024];

unsigned char ReType;


unsigned char St1;
unsigned char St0;
int ReDataLen;
unsigned char ReData[1024];
// Open Comm. port
{
hCom=CRT288ROpenWithBaut (“COM1”,38400);
if(hCom<=0)
{
// failed

}
else
{
// successfully.

}
}
// Initialize
{
memset(CmData,0x00,sizeof(CmData));
CmCode=0x30; // Initialize command
PmCode=0x30; // Parameter code
CmDataLen=0; // Data size (bytes)

rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
{
// Initialize command successfully finished.
if (ReType==0x50 || ReType==0x4E)
{
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 17/27

if (ReType==0x50)
{
// Received positive reply

}
else
{
// Received negative reply
...
}
}
else
{
//Communication Error
// Initialize command failed.

}
else
{
//Communication Error
// Initialize command failed.

}
}
// Request Status
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x31; // Status request command
PmCode= 0x30; // Parameter code
CmDataLen=0; // Data size
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
if (ReType==0x50)
{
//Execute Ok
if(St0 == '2') // One card in the ICRW, but it is inserted in place
{
// Detected a card inside of ICRW
...
}
}
else (ReType==0x4e)
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 18/27

{
//Command execution failed
ResErrMsg(St1,St0);

}
else
{
//Communication Error

}
}
// Read Track 1 of Mag card’s tracks
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x36; // Read Mag Card
PmCode=0x31; // Track 1
CmDataLen=2; // Data size
CmData[0]=0x30; //ASCII mode
CmData[0]=0x31; //Read Track 1
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
{
if (ReType==0x50 || ReType==0x4E)
{
//Read track data OK
if (ReData[0]==0x50)
{
CString Tra1Buf,t;
int n;
for(n=1; n<ReDataLen; n++)
{
t.Format("%c",ReData[n]);
Tra1Buf += t;
t="";
}
//Tra1Buf is the buffer of track 1 data
}
else if (ReData[0]==0x4e)
{
//Read track data Error
switch(ReData[2])
{
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 19/27

case 0x36 : //No start bits (STX)


break;
case 0x37 //No stop bits (ETX)
break;
case 0x30 : //Byte Parity Error(Parity))
break;
case 0x38 : //Parity Bit Error(LRC)
break;
case 0x34 : //Card Track Data is Blank
break;
case 0x33 : //Only(SS-ES-LRC)
break;
}
}
}
else (ReType==0x4e)
{
// Command execution failed
ResErrMsg(St1,St0);
}
else
{
//Communication Error
}
}
Else
{
//Communication Error
}
}
// Read Track 2 of Mag card’s tracks
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x36; // Read Mag Card
PmCode=0x31; // Track 1
CmDataLen=2; // Data size
CmData[0]=0x30; //ASCII mode
CmData[0]=0x32; //Read Track 2
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
{
if (ReType==0x50 || ReType==0x4E)
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 20/27

{
//Read track data OK
if (ReData[0]==0x50)
{
CString Tra1Buf,t;
int n;
for(n=1; n<ReDataLen; n++)
{
t.Format("%c",ReData[n]);
Tra1Buf += t;
t="";
}
//Tra1Buf is the buffer of track 1 data
}
else if (ReData[0]==0x4e)
{
//Read track data Error
switch(ReData[2])
{
case 0x36 : //No start bits (STX)
break;
case 0x37 //No stop bits (ETX)
break;
case 0x30 : //Byte Parity Error(Parity))
break;
case 0x38 : //Parity Bit Error(LRC)
break;
case 0x34 : //Card Track Data is Blank
break;
case 0x33 : //Only(SS-ES-LRC)
break;
}
}
}
else (ReType==0x4e)
{
// Command execution failed
ResErrMsg(St1,St0);
}
else
{
//Communication Error
}
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 21/27

}
Else
{
//Communication Error
}
}
// Read Track 3 of Mag card’s tracks
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x36; // Read Mag Card
PmCode=0x31; // Track 1
CmDataLen=2; // Data size
CmData[0]=0x30; //ASCII mode
CmData[0]=0x33; //Read Track 3
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
{
if (ReType==0x50 || ReType==0x4E)
{
//Read track data OK
if (ReData[0]==0x50)
{
CString Tra1Buf,t;
int n;
for(n=1; n<ReDataLen; n++)
{
t.Format("%c",ReData[n]);
Tra1Buf += t;
t="";
}
//Tra1Buf is the buffer of track 1 data
}
else if (ReData[0]==0x4e)
{
//Read track data Error
switch(ReData[2])
{
case 0x36 : //No start bits (STX)
break;
case 0x37 //No stop bits (ETX)
break;
case 0x30 : //Byte Parity Error(Parity))
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 22/27

break;
case 0x38 : //Parity Bit Error(LRC)
break;
case 0x34 : //Card Track Data is Blank
break;
case 0x33 : //Only(SS-ES-LRC)
break;
}
}
}
else (ReType==0x4e)
{
// Command execution failed
ResErrMsg(St1,St0);
}
else
{
//Communication Error
}
}
Else
{
//Communication Error
}
}
// Closes communications between the Host Computer and the Card Reader/Writer
{
CRT288RClose (hCom);
}
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 23/27

4.4 Sample Code 2 (CPU Card Operation)


HANDLE hCom; // Target device's HANDLE
int rc=0; //Result
unsigned char CmCode;
unsigned char PmCode;
int CmDataLen;
unsigned char CmData[1024];

unsigned char ReType;


unsigned char St1;
unsigned char St0;
int ReDataLen;
unsigned char ReData[1024];
// Open Comm. port
{
hCom= CRT288ROpenWithBaut (“COM1”,38400);
if(hCom<=0)
{
// failed

}
else
{
// successfully.

}
}
// Initialize
{
memset(CmData,0x00,sizeof(CmData));
CmCode=0x30; // Initialize command
PmCode=0x30; // Parameter code
CmDataLen=0; // Data size (bytes)
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
{
// Initialize command successfully finished.
if (ReType==0x50 || ReType==0x4E)
{
if (ReType==0x50)
{
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 24/27

// Received positive reply



}
else
{
// Received negative reply
...
}
}
else
{
//Communication Error
// Initialize command failed.

}
else
{
//Communication Error
// Initialize command failed.

}
}
// Activates CPU card
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x51; // IC card control
PmCode=0x30; // Activate
CmDataLen=1; // Data size
CmData[0]=0x30; //EMV2000 V4.0 Vcc=5v
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc!=0))
{
// Command sending failed or time is out
}
if (ReType==0x50 || ReType==0x4E)
{
CString t;
CString TempBuf="";
If(ReData[n]==0x30)
{
//CPU card is T=0
}
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 25/27

else
{
//CPU card is T=1
}
if (ReType==0x50)
{
for(int n=1; n<ReDataLen; n++) // ATR= start from n= 1
{
t.Format("%02x",ReData[n]);
TempBuf += t;
t="";
}
//TempBuf is the buffer of ATR data
}
if((ReType==0x4e) && (ReDataLen>0)) //the card is not EMV
{
for(int n=1; n<ReDataLen; n++) // ATR= start from n= 1
{
t.Format("%02x",ReData[n]);
TempBuf += t;
t="";
}
//TempBuf is the buffer of ATR data
}
if((ReType==0x4e) && (ReDataLen==0))
{
// Command execution failed
SANKYOErrMsg(St1,St0);
}
}
else
{
//Communication Error

}
}
// Exchanges data between the Host Computer and IC card
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x49; // IC card control
PmCode=0x39; // Deactivate
CmDataLen=5; // Data size
CmData[0]=0x00;
Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 26/27

CmData[1]=0x84;
CmData[2]=0x00;
CmData[3]=0x00;
CmData[4]=0x08;
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc!=0)
{
// Command sending failed or time is out
...
}
else
{
if (ReType==0x50 || ReType==0x4E)
{
if (ReType==0x50)
{
CString t;
CString TempBuf="";
for(int n=0; n<ReDataLen; n++) // R-APDU= start from n=0
{
t.Format("%02x",ReData[n]);
TempBuf += t;
t="";
}
// TempBuf is the buffer of R-APDU data
}
else //(ReType==0x4e)
{
// Command execution failed
SANKYOErrMsg(St1,St0);
}
}
else
{
//Communication Error

}
}
else
{
//Communication Error

Model No. CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 27/27

}
}
// Deactivates IC card
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x49; // IC card control
PmCode=0x31; // Deactivate
CmDataLen=0; // Data size
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc!=0) || ReType != 0x50)
{
// Command sending failed or command execution failed

}
}
_EXIT1:
// Closes communications between the Host Computer and the Card Reader/Writer
CRT288RClose (hCom);
_EXIT:

You might also like