SC-350 DLL Specification
SC-350 DLL Specification
Contents
Parameter:
Patameter:
ComHandle:Com Handle
Return:
=0 Success
<>0 Fail
ComHandle:Com Handle
Return:
=0 Success
=-1 Fail
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
3 Code Example
CmData[9]=0x30;// Ty
CmData[10]=0x31;// Cp
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
// Initialize command successfully finished.
if (ReType==0x50)
{
// Received positive reply
…
}
else (ReType==0x4e)
{
// Received negative reply
...
}
else
{
//Communication Error
// Initialize command failed.
…
}
}
// Setting Card In by Mag card
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x3a; // Card In
PmCode=0x32; // by Mag card
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
ResErrMsg(St1,St0); // ResErrMsg is a function to show the reason of error
// Details please see from error code of communication protocol
…
}
}
// Request Status
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x31; // Status request command
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
{
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 36 : //No start bits (STX)
break;
case 37 //No stop bits (ETX)
break;
case 30 : //Byte Parity Error(Parity))
break;
case 38 : //Parity Bit Error(LRC)
break;
case 34 : //Card Track Data is Blank
case 33 : //Only(SS-ES-LRC)
break;
}
}
}
else (ReType==0x4e)
{
// Command execution failed
ResErrMsg(St1,St0);
}
else
{
//Communication Error
}
}
// Read Track 2 of Mag card’s tracks
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x36; // Read Mag Card
PmCode=0x32; // Track 2
CmDataLen=0; // Data size
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
if(rc==0)
if (ReType==0x50)
{
//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 2 data
}
else if (ReData[0]==0x4e)
{
//Read track data Error
switch(ReData[2])
{
case 36 : //No start bits (STX)
break;
case 37 //No stop bits (ETX)
break;
case 30 : //Byte Parity Error(Parity))
break;
case 38 : //Parity Bit Error(LRC)
break;
case 34 : //Card Track Data is Blank
case 33 : //Only(SS-ES-LRC)
break;
}
}
}
else (ReType==0x4e)
{
// Command execution failed
ResErrMsg(St1,St0);
}
else
{
//Communication Error
}
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
}
// Read Track 3 of Mag card’s tracks
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x36; // Read Mag Card
PmCode=0x33; // Track 3
CmDataLen=0; // Data size
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
if (ReType==0x50)
{
//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 3 data
}
else if (ReData[0]==0x4e)
{
//Read track data Error
switch(ReData[2])
{
case 36 : //No start bits (STX)
break;
case 37 //No stop bits (ETX)
break;
case 30 : //Byte Parity Error(Parity))
break;
case 38 : //Parity Bit Error(LRC)
break;
case 34 : //Card Track Data is Blank
case 33 : //Only(SS-ES-LRC)
break;
}
}
}
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
else (ReType==0x4e)
{
// Command execution failed
ResErrMsg(St1,St0);
}
else
{
//Communication Error
}
}
// Closes communications between the Host Computer and the Card Reader/Writer
{
SC350RClose (hCom);
}
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
CmData[10]=0x31;// Cp
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
// Initialize command successfully finished.
if (ReType==0x50)
{
// Received positive reply
…
}
else (ReType==0x4e)
{
// Received negative reply
...
}
else
{
//Communication Error
// Initialize command failed.
…
}
}
// Setting Card In by Switch
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x3a; // Card In
PmCode=0x30; // by Switch
CmDataLen=0; // Data size
rc=RS232_ExeCommand(hCom,CmCode,PmCode,CmDataLen,CmData,
&ReType,&St1,&St0,&ReDataLen,ReData);
if(rc==0)
{
// Command successfully finished.
if (ReType==0x50)
{
// Received positive reply
…
}
else (ReType==0x4e)
{
// Received negative reply
ResErrMsg(St1,St0); // ResErrMsg is a function ,please see the error code of communication
protocol
…
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
}
else
{
//Communication Error, 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(St1 == '0' && St1 == '2')
{
// status code="02"
// Detected a card inside of Card Reader/Writer
...
}
}
else (ReType==0x4e)
{
//Command execution failed
ResErrMsg(St1,St0);
…
}
else
{
//Communication Error
…
}
}
// Switches IC contact on
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x40; // IC contact
PmCode=0x30; // IC contact set
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
else //(ReType==0x4e)
{
// Command execution failed
SANKYOErrMsg(St1,St0);
}
}
}
// 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;
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)
{
// ICCardTransmit failed
...
}
else
{
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);
}
Room 716, Yiben E-Commerce Tel: +86-755-82706901
and Industrial Park, Chaguang Road Fax: +86-755-82706900
Nanshan District, Shenzhen, China Email: [email protected]
Post Code: 518055 Http://www.syncotek.com
}
}
// 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
…
}
}
_EXIT2:
// Switches IC contact off
{
memset(CmData,0x00,sizeof(CmData));
CmCode= 0x40; // IC contact
PmCode=0x32; // IC contact release
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
SC350RClose (hCom);
_EXIT: