CRT-288 DLL Specification
CRT-288 DLL Specification
CRT-288
SPECIFICATION Date 2010/09/20
Ver. V1.0
DLL Page 1/27
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
2.1 Function for Open Com Port (Default Baud rate: 38400bps)......................................4
4. Sample Code............................................................................................................................ 13
F2 00 08 43 51 33 00 84 00 00 08 03 54
TxDataLen=0x05 TxData={0x00,0x84,0x00,0x00,0x08}
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
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
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
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
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
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
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
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
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
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
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
{
//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
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: