Results 1 to 4 of 4

Thread: Testing Code

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    8

    Testing Code

    PHP Code:
    Option Explicit
    Dim intCnt 
    As Integer
    Dim intSer 
    As String
    Dim s 
    As String
    Dim capZ 
    As String



    Private Sub Command1_Click()
    Dim i&, j%, port&, baud&, buf1(200) As Byteb1 As Bytes1$
    port cb_ckh.ListIndex 1
    If (port 0Then
        lb_info
    .Caption "Please select COM Port!"
    End If
    baud CLng(cb_btl.Text)
    If (
    baud 0Then
        lb_info
    .Caption "Please select Baud rate!"
    End If
    'Open Port
    i = rf_init_com(port, baud)
    If (i <> 0) Then
        lb_info.Caption = "Open Port Fail!"
        Exit Sub
    End If
    '
    Request
    rf_request(0, &H52j)
    If (
    <> 0Then
        lb_info
    .Caption "Request Fail!"
        
    Exit Sub
    End 
    If
    'Anticollision
    i = rf_anticoll(0, 4, buf1(0), b1)
    If (i <> 0) Then
        lb_info.Caption = "Anticollision Fail!"
        Exit Sub
    End If
    s1 = ""
    For i = 0 To b1 - 1
        s1 = s1 & Right("00" & Hex(buf1(i)), 2)
    Next i
    tx_kh.Text = s1
    '
    Select card
    rf_select(0buf1(0), 4b1)
    If (
    <> 0Then
        lb_info
    .Caption "Select card fail!"
        
    Exit Sub
    ElseIf (intSer s1Then
        lb_info
    .Caption "Same Card"
        
    Exit Sub
    End 
    If
    lb_info.Caption "Select card succeed!"
    intSer s1
    Call Command2_Click
    End Sub

    Private Sub Command2_Click()
    Dim i&, m&, buf1(200) As Bytebuf2(200) As Bytes1$, b1 As Byteb2 As Byteb3 As Byte
    s1 
    Trim(tx_key.Text)
    If (
    Len(s1) <> 12Then
        lb_info
    .Caption "Wrong Key Length!"
        
    tx_key.SetFocus
        
    Exit Sub
    End 
    If
    For 
    0 To 5
        buf1
    (i) = Val("&H" Mid(s112))
    Next i
    cb_kh.ListIndex
    If (= -1Then
        lb_info
    .Caption "Select Block Please!"
        
    Exit Sub
    End 
    If
    If (
    op_a.ValueThen
       b1 
    = &H60
    End 
    If
    If (
    op_b.ValueThen
       b1 
    = &H61
    End 
    If
    b3 CByte(m)
    'Authentication
    i = rf_M1_authentication2(0, b1, b3, buf1(0))
    If (i <> 0) Then
        lb_info.Caption = "Authentication Fail£¡"
        Exit Sub
    End If
    '
    Read card
    rf_M1_read(0b3buf2(0), b2)
    If (
    <> 0Then
        lb_info
    .Caption "Read Card Fail!"
        
    Exit Sub
    End 
    If

    s1 ""
    For 0 To b2 1
        s1 
    s1 Right("00" Hex(buf2(i)), 2)
    Next i
    tx_sj
    .Text s1
    lb_info
    .Caption "Read Succeed!"
    If (s1 "00000000000000000000000000000001"Then
        lb_info
    .Caption "Numero Uno"
        
    "Personality One"
        
    For 9 To 1 Step -1
              Form1
    .ColorPct(i).Picture Form1.ColorPct(1).Picture
              
          Next i
          Form1
    .ColorPct(0).Picture LoadPicture("grape.jpg")
          
    ElseIf (
    s1 "00000000000000000000000000000002"Then
        lb_info
    .Caption "Numero Dos"
        
    "Personality Two"
        
    For 9 To 1 Step -1
              Form1
    .ColorPct(i).Picture Form1.ColorPct(1).Picture
              
          Next i
          Form1
    .ColorPct(0).Picture LoadPicture("introspective.jpg")
          
          
        Exit 
    Sub
    End 
    If
    End Sub

    Private Sub Command3_Click()
    Dim i&, m&, buf1(200) As Bytebuf2(200) As Bytes1$, b1 As Byteb2 As Byteb3 As Byte
    s1 
    Trim(tx_key.Text)
    If (
    Len(s1) <> 12Then
        lb_info
    .Caption "Wrong Key Length!"
        
    tx_key.SetFocus
        
    Exit Sub
    End 
    If
    For 
    0 To 5
        buf1
    (i) = Val("&H" Mid(s112))
    Next i
    cb_kh.ListIndex
    If (= -1Then
        lb_info
    .Caption "Select Block Please!"
        
    Exit Sub
    End 
    If
    If (
    op_a.ValueThen
       b1 
    = &H60
    End 
    If
    If (
    op_b.ValueThen
       b1 
    = &H61
    End 
    If

    s1 Trim(tx_sj.Text)
    If (
    Len(s1) <> 32Then
        lb_info
    .Caption "Wrong Data length "
        
    tx_sj.SetFocus
        
    Exit Sub
    End 
    If
    For 
    0 To 15
        buf2
    (i) = Val("&H" Mid(s112))
    Next i
    'Authentication
    b3 = CByte(m)
    i = rf_M1_authentication2(0, b1, b3, buf1(0))
    If (i <> 0) Then
        lb_info.Caption = "Authentication Fail!"
        Exit Sub
    End If
    '
    Write card
    rf_M1_write(0b3buf2(0))
    If (
    <> 0Then
        lb_info
    .Caption "Write Card Fail£¡"
        
    Exit Sub
    End 
    If

    lb_info.Caption "Write Succeed!"
    End Sub

    Private Sub Command4_Click()
    Dim i&
    rf_halt(0)
    If (
    <> 0Then
        lb_info
    .Caption "Halt Fail!"
        
    Exit Sub
    End 
    If
    lb_info.Caption "Halt Succeed"
    End Sub

    Private Sub Command5_Click()
    Form1.Show
    End Sub

    Private Sub Form_Load()
    Dim i&
    Timer1.Interval ' Add these 3 lines of code where ever you want timer to start calling the function
    Timer1.Enabled = True
    s = "Now is the time for all good men to come to the aid of their country  "
    Timer2.Interval = 300
    Timer2.Enabled = True
    intCnt = 1
    For i = 0 To 63
        cb_kh.AddItem CStr(i), i
    Next i
    cb_ckh.ListIndex = 0: cb_btl.ListIndex = 1: cb_kh.ListIndex = 4
    End Sub

    Private Sub Timer1_Timer()
    If intCnt = 60 Then
    Call Command1_Click
    intCnt = 1
    Else
    intCnt = intCnt + 1
    End If
    End Sub

    Private Sub Timer2_Timer()
    Dim n As Integer
    Static t As String
    Static ndx As Integer
    If Len(t) = 0 Then t = Space$(20)
    n = Len(s)
    ndx = (ndx Mod n) + 1
    Mid$(t, 1, 19) = Mid$(t, 2, 19)
    Mid$(t, 20, 1) = Mid$(s, ndx, 1)

    End Sub 

  2. #2
    New Member
    Join Date
    May 2007
    Posts
    1

    Re: Testing Code

    Hi I am using VB6.I have an RFID reader and when searched on google about a particular piece of could which was giving me a hard time, I found a link to this thread. Would you be kind enough to explain to me in some detail what actually happens in the request, anticollison and select card parts with reference to the variables and what is there use. Because altough I got the code working I have trouble documenting it given that I do not know what the variables actually mean....

    Any kind of help you provide will be greatly appreciated because this is for my thesis.

    Private Sub Command1_Click()
    Dim i&, j%, port&, baud&, buf1(200) As Byte, b1 As Byte, s1$
    port = cb_ckh.ListIndex + 1
    If (port = 0) Then
    lb_info.Caption = "Please select COM Port!"
    End If
    baud = CLng(cb_btl.Text)
    If (baud = 0) Then
    lb_info.Caption = "Please select Baud rate!"
    End If
    'Open Port
    i = rf_init_com(port, baud)
    If (i <> 0) Then
    lb_info.Caption = "Open Port Fail!"
    Exit Sub
    End If
    'Request
    i = rf_request(0, &H52, j)
    If (i <> 0) Then
    lb_info.Caption = "Request Fail!"
    Exit Sub
    End If
    'Anticollision
    i = rf_anticoll(0, 4, buf1(0), b1)
    If (i <> 0) Then
    lb_info.Caption = "Anticollision Fail!"
    Exit Sub
    End If
    s1 = ""
    For i = 0 To b1 - 1
    s1 = s1 & Right("00" & Hex(buf1(i)), 2)
    Next i
    tx_kh.Text = s1

  3. #3
    New Member
    Join Date
    Jan 2008
    Posts
    1

    Smile Hi Barun.....

    Hi Barun,

    My name is Thushara, I am from Kerala. I am working as a Embedded Engineer in a privare firm here. Now I got a assigment for Interfacing an RFID reader(SL015m) with a Mifare Ultra Light card. I also got the same Visual Basic code, form the company site for interfacing the RFID reader. But, it is not working for me. I don't know why. From your post, I saw that you have told, your code is working well. Can you please help me, friend? I will thankfull to you for a life time. My email id is Removed By Mod.

    Regards,

    Thushara.
    Last edited by Hack; Jan 30th, 2008 at 01:56 PM. Reason: Removed Email address

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Testing Code

    I have edited your post and removed your email address.

    You should never post your email address in an open post on an open forum. Mail spam bots can pick that up and before you know it, your mailbox is full of junk mail. If you wish to share your email address with other forum members, please do so via our PM system.

    In addition, we prefer all answers to questions be publically posted rather than sent via EMail or PM. That way, everyone with a similar problem can benefit.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width