Anda di halaman 1dari 5

Version 1.

1 10-2004

Advanced Card Systems Ltd.


Unit 2910-2913, 29/F, The Center,
99 Queens Road Central, Hong Kong

Tel: +852 2796 7873


Website: www.acs.com.hk

Fax: +852 2796 1286


Email: info@acs.com.hk

ACR30 Proprietary ActiveX Component

version 1.1 October 2004

Introduction
You can access the ACR30 Proprietary Driver via ActiveX Component (OCX). Please register the file
ReaderXControl.ocx in your system; you will then be able to program the ACR30 as an object component.

TReaderActiveX Object
The ACR30 component is referred to as TReaderActiveX in your system. It has the following attributes:

Properties

Port 16-bit value to specify which port the ACR30 is connected to. Use 15 to indicate USB port.
Fill up this member before calling the Open method.
CardType 8-bit value to specify which type of card you intend to power up. Fill up this member
before calling the StartSession method. It can have the following values:
MCU T=0
IIC Type 1
IIC Type 2
AT88SC153
AT88SC1608
SLE4418
SLE4428
SLE4432
SLE4442

30
12
13
14
15
16
17
18
19

ATR String, in hexadecimal notation, that holds the cards Answer To Reset String. This property
is filled up by the StartSession method.
ATRLEN Length of the ATR Property. This property is filled up by the StartSession method.
HISTLEN Length of the cards historical bytes. This property is filled up by the StartSession
method.
HISTOFFEST offset in ATR Property containing the cards Historical data. This property is filled up
by the StartSession method.
APDULenMAX maximum length of the APDU Data field. This property is filled up by the
StartSession method.
CStat holds the current status of the reader. This property is filled up by the GetInfo method. It can
have the following values: 0=No Card; 1=Card Inserted; 3=Card Inserted and Powered Up.
szRev String that holds the readers Firmware Revision Code. This property is filled up by the
GetInfo method.
szRevIndx index that allows you to access each character in the szRev member.
CLA byte to hold the CLASS member of the APDU
INS - byte to hold the INS member for the APDU
P1 byte to hold the P1 member for the APDU
P2 byte to hold the P2 member for the APDU
Lc - byte to hold the P2 member for the APDU
Le byte to hold the P2 member for the APDU
DataStr byte to copy to/from APDUDataIn/ApduDataOut, use in conjunction with DataIndx
member
DataIndx byte to indicate which element of APDUDataIn or APDUDataOut you want to access.

Advanced Card Systems Ltd.

Page 2 of 5

ACR30 Proprietary ActiveX Component

version 1.1 October 2004

Methods

Open connects your application to the ACR30 reader. It requires the Port member to be initialized
by the application.
Close closes your connection to the ACR30 reader. Call this method when your application no
longer needs the ACR30 reader.
StartSession powers up the card inserted in the ACR30 reader. The CardType member must be
initialized by the application. On success, it will fill up the ATR and History properties of
TReaderActiveX.
EndSession powers off the card in the ACR30 reader.
GetInfo retrieves information from the ACR30 reader. It will fill up the following TReaderActiveX
properties: CStat, szRev, nMaxC, nMaxR, nLibVer, lBaudRate.
ApduDataIn this method will copy one byte from the DataStr member to TReaderActiveX APDU
DataIn data structure. Use DataStr and DataIndx to specify the offset to be copied.
ApduDataOut this method will copy one byte from the TReaderActiveX APDU DataOut data
structure to the DataStr member. Use DataStr and DataIndx to specify the offset to be copied.
SendAPDU this method will send an APDU command to the card. The application must fill the
following properties: CLA, INS, P1, P2, Lc, Le, DataIn.
GetStatus holds the SW1 SW2 status bytes in hexadecimal string notation after sending
APDU command to the card.

Examples in VB using the TReaderActiveX object:


1. Connecting / Disconnecting reader
Dim ReaderX as TReaderActiveX
ReaderX.Port = 15
ReaderX.Open

connect to USB

if fail, VB will generate runtime error


MsgBox ACR30 Opened
disconnect the reader
ReaderX.Close
2. Power Up T=0 Card
Dim ReaderX as TReaderActiveX
ReaderX.Port = 15
ReaderX.Open

connect to USB

ReaderX.CardType = 30 power up T=0 card


ReaderX.StartSession
display the cards ATR
MsgBox ATR = & ReaderX.ATR
ReaderX.EndSession

power off the card

ReaderX.Close

disconnect reader

Advanced Card Systems Ltd.

Page 3 of 5

ACR30 Proprietary ActiveX Component

version 1.1 October 2004

3. Get Reader Status


Dim ReaderX as TReaderActiveX
ReaderX.Port = 15
ReaderX.Open

connect to USB

ReaderX.GetInfo
' display the Reader's firmware revision code
for i = 0 to 9
ReaderX.szRevIndx = i
temp = temp & chr (ReaderX.szRev)
next
MsgBox "REV CODE: " & temp

' get the ith element

' check card status


i = ReaderX.CStat
if i <> 0 then
MsgBox "Card Inserted"
else
MsgBox "Card Not Inserted"
end if
ReaderX.Close
4. Send APDU Command
assume reader is already opened
assume card is already powered up
send this command: CLA=$80 INS=$A4 P1=0 P2=0 Lc=2 Le=0, DataIn=$FF $02
ReaderX.cla = 128
ReaderX.ins = 164
ReaderX.p1 = 0
ReaderX.p2 = 0
ReaderX.lc = 2
ReaderX.le = 0
ReaderX.datastr = 255
ReaderX.dataindx = 0
ReaderX.APDUDataIn
ReaderX.datastr = 2
ReaderX.dataindx = 1
ReaderX.APDUDataIn

' $80
' $A4

' $FF02
copy FF to the 1st element of DataIN
copy 02 to the 2nd element of DataIN

ReaderX.sendapdu
result =ReaderX.getstatus
msgbox "Result: " & result

Advanced Card Systems Ltd.

display the SW1 SW2

Page 4 of 5

ACR30 Proprietary ActiveX Component

version 1.1 October 2004

5. Send APDU Command


assume reader is already opened
assume card is already powered up
send this command: CLA=$80 INS=$B2 P1=0 P2=0 Lc=0 Le=4
ReaderX.cla = 128
ReaderX.ins = 178
ReaderX.p1 = 0
ReaderX.p2 = 0
ReaderX.lc = 0
ReaderX.le = 4

$80
$B2

get 4 bytes from card

ReaderX.sendapdu
result =ReaderX.getstatus
display the SW1 SW2
msgbox "Result: " & result
get DATAOUT, store it in variable TEMP
for i = 0 to 3
ReaderX.dataindx = i
temp = temp &" " & ReaderX.APDUDataOut
next
msgbox temp

Advanced Card Systems Ltd.

get the ith element of DataOut

Page 5 of 5

Anda mungkin juga menyukai