۲۹-مرداد-۱۳۸۹, ۱۱:۳۷:۵۲
فکر کنم اگه یا کارت خودت طراحی کنی بهتر جواب میگیری تا بخوای روی کارت بنویسی ولی در کل میشه من خودم دیدم این کار رو کردن الان به چه نتیجه ای رسیدی ایا تحقیقی کردی
'------------------------------------------------------------------------------
' BCCARD.BAS
' This AN shows how to use the BasicCard from Zeitcontrol
' www.basiccard.com
'------------------------------------------------------------------------------
'connections:
' C1 = +5V
' C2 = PORTD.4 - RESET
' C3 = PIN 4 - CLOCK
' C5 = GND
' C7 = PORTD.5 - I/O
' /--------------------------------\
' | |
' | C1 C5 |
' | C2 C6 |
' | C3 C7 |
' | C4 C8 |
' | |
' \--------------------------------/
'
'
'----------- configure the pins we use ------------
Config Bccard = D , Io = 5 , Reset = 4
' ^ PORTD.4
' ^------------ PORTD.5
' ^--------------------- PORT D
'Load the sample calc.bas into the basiccard
' Now define the procedure in BASCOM
' We pass a string and also receive a string
Bcdef Calc(string)
'We need to dim the following variables
'SW1 and SW2 are returned by the BasicCard
'BC_PCB must be set to 0 before you start a session
'Our program uses a string to pass the data so DIM it
Dim S As String * 15
'Baudrate might be changed
$baud = 9600
' Crystal used must be 3579545 since it is connected to the Card too
$crystal = 3579545
'Perform an ATR
Bcreset
'Now we call the procedure in the BasicCard
'bccall funcname(nad,cla,ins,p1,p2,PRM as TYPE,PRM as TYPE)
S = "1+1+3" ' we want to calculate the result of this expression
Bccall Calc(0 , &H20 , 1 , 0 , 0 , S)
' ^--- variable to pass that holds the expression
' ^------- P2
' ^----------- P1
' ^--------------- INS
' ^-------------------- CLA
' ^-------------------------- NAD
'For info about NAD, CLA, INS, P1 and P2 see your BasicCard manual
'if an error occurs ERR is set
' The BCCALL returns also the variables SW1 and SW2
Print "Result of calc : " ; S
Print "SW1 = " ; Hex(sw1)
Print "SW2 = " ; Hex(sw2)
'Print Hex(_bc_pcb) ' for test you can see that it toggles between 0 and 40
Print "Error : " ; Err
'You can call this or another function again in this session
S = "2+2"
Bccall Calc(0 , &H20 , 1 , 0 , 0 , S)
Print "Result of calc : " ; S
Print "SW1 = " ; Hex(sw1)
Print "SW2 = " ; Hex(sw2)
'Print Hex(_bc_pcb) ' for test you can see that it toggles between 0 and 40
Print "Error : " ; Err
'perform another ATR
Bcreset
Input "expression " , S
Bccall Calc(0 , &H20 , 1 , 0 , 0 , S)
Print "Answer : " ; S
'----and now perform an ATR as a function
Dim Buf(25) As Byte , I As Byte
Buf(1) = Bcreset()
For I = 1 To 25
Print I ; " " ; Hex(buf(i))
Next
'typical returns :
'TS = 3B
'T0 = EF
'TB1 = 00
'TC1 = FF
'TD1 = 81 T=1 indication
'TD2 = 31 TA3,TB3 follow T=1 indicator
'TA3 = 50 or 20 IFSC ,50 =Compact Card, 20 = Enhanced Card
'TB3 = 45 BWT blocl waiting time
'T1 -Tk = 42 61 73 69 63 43 61 72 64 20 5A 43 31 32 33 00 00
' B a s i c C a r d Z C 1 2 3
'and another test
'define the procedure in the BasicCard program
Bcdef Paramtest(byte , Word , Long )
'dim some variables
Dim B As Byte , W As Word , L As Long
'assign the variables
B = 1 : W = &H1234 : L = &H12345678
Bccall Paramtest(0 , &HF6 , 1 , 0 , 0 , B , W , L)
Print Hex(sw1) ; Spc(3) ; Hex(sw2)
'and see that the variables are changed by the BasicCard !
Print B ; Spc(3) ; Hex(w) ; " " ; Hex(l)
'try the echotest command
Bcdef Echotest(byte)
Bccall Echotest(0 , &HC0 , &H14 , 1 , 0 , B)
Print B
End
![[تصویر: balanc3.jpg]](http://www.basiccard.com/pics/balanc3.jpg)
![[تصویر: tagtracer14443.jpg]](http://www.basiccard.com/pics/tagtracer14443.jpg)
:020000020000FC
:100000000FED0DBF03E407BB0FEF08BB0FEF0ABBFB
:1000100000270BBBD998D898C69846E0B3990EC074
:100020007ED04A95D9F72FE733274FE064E0D89880
:1000300076D0D89A74D06A95D1F753D0B59BEACFD1
:100040006ED06DD0C09AC098C0E6332720E1442717
:1000500018E04795C198B4994068C19A1A95C9F7B4
:1000600049932A95A1F7C0E6332720E100E1599191
:100070003CD02A9559F04517D1F35FE020E1500FAD
:10008000052FC0E6302F0F3751F0F1CFD89AD9980D
:10009000C69A45D0B39B20C0B599F8CFBBCFD898AE
:1000A000D99AB59902C03BD0B5CFB29B01C0F7CF6A
:1000B000B29BFECF58E0332700E117D03A954F307E
:1000C00021F05A9509F1300FF7CF20E1C0E64991B0
:1000D00013D02A95E1F79ECFB39BFECF20E130519C
:1000E0004FE00AD02A95E9F795CFE199FECF3EBBC4
:1000F000E09A4DB333950895E199FECF3EBB4DBBD9
:10010000E29AE19A3395089564E0D99AD89807D095
:100110006A95D998D89A03D06A95B9F708955FEF90
:0C0120000FEF0A95F1F75A95D9F70895F2
:00000001FF