Question How to integrate RFID reader

Sythe

Member
Joined
Jul 18, 2012
Messages
13
Programming Experience
Beginner
I have a UHF-RFID reader with rs232 connected to a port on my laptop but i am having a hard time trying to figure out the codes i needed to connect it to Visual Basic 2010.
What i am trying trying to do is that integrate RFID reader to vb.net and once the reader detects a RFID tag it will show the info of that tag on vb.
 
Yes it has sdk, dlls, and a sample program. I tried opening the sample program with visual studio but cant find the code i need so i can integrate it to my vb.net program.
 
Does it include a sample program written in VB.NET? Is there documentation provided that lists what functions are available and what they do? Most likely the software was written in unmanaged C++. That means that you cannot reference the DLL the way you can .NET assemblies and COM libraries. You need to use Platform Invoke, which is the same technique used to invoke the Windows API, which is also written in unmanaged C++. In that case, you have to declare an empty method in VB.NET with a signature compatible with that of the unmanaged function you want to call and then decorate it with a DllImport attribute to tell .NET where to find the original. You then call that method as you would any other .NET method. Behind the scenes, .NET maps the call to the unmanaged library automatically. You then just deploy the unmanaged library to the same folder as your EXE.

If you need examples of PInvoke, look on the web for two of the most common Windows API functions: FindWindow and SendMessage. That will show you the sort of thing you have to do. If you need help with your managed method signatures then post the original C++ function signatures here and we can help.
 
Well in all honesty you don't really need a SDK for a serial port card reader... All you really need is the detailed protocol and command list, and the SerialPort class. If these things are anything standardized, this should get you started:
 

Attachments

  • rfid.png
    rfid.png
    67.3 KB · Views: 158
Last edited:
Well in all honesty you don't really need a SDK for a serial port card reader... All you really need is the detailed protocol and command list, and the SerialPort class. If these things are anything standardized, this should get you started:
Yeah thats what i think, i tried to find some sample on the web and this is what i found.

VB.NET:
Public Class Form1
    Dim WithEvents myComPort As New System.IO.Ports.SerialPort
    Dim data As String
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ComboBox1.Enabled = True
        Button2.Enabled = False
        Button1.Enabled = True
        RadioButton1.Enabled = False
        RadioButton2.Checked = True
        myComPort.Close()
    End Sub


    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not ComboBox1.SelectedItem Is Nothing Then
            If Not myComPort.IsOpen Then
                Try
                    myComPort.BaudRate = 2400
                    myComPort.PortName = ComboBox1.SelectedItem
                    myComPort.Parity = IO.Ports.Parity.None
                    myComPort.DataBits = 8
                    myComPort.StopBits = IO.Ports.StopBits.One
                    myComPort.Handshake = IO.Ports.Handshake.None
                    myComPort.ReadTimeout = 3000
                    myComPort.ReceivedBytesThreshold = 1
                    myComPort.DtrEnable = True


                    myComPort.Open()


                    ComboBox1.Enabled = False
                    Button1.Enabled = False
                    Button2.Enabled = True
                    RadioButton1.Enabled = True
                    RadioButton1.Checked = True


                Catch ex As Exception
                    MsgBox("Error Opening COM Port", MsgBoxStyle.Critical)
                End Try
            End If
        Else
            MsgBox("Select a valid COM Port", MsgBoxStyle.Information)
        End If
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each portName As String In My.Computer.Ports.SerialPortNames
            ComboBox1.Items.Add(portName)
        Next
        CheckBox1.Checked = True
        If Not myComPort.IsOpen Then
            Button2.Enabled = False
            ComboBox1.Text = ComboBox1.Items(0)
            RadioButton1.Enabled = False
            RadioButton2.Checked = True
        Else
            Button1.Enabled = False
            ComboBox1.Text = myComPort.PortName
            RadioButton2.Checked = True
        End If
    End Sub


    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        myComPort.DtrEnable = True
    End Sub


    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        myComPort.DtrEnable = False
    End Sub
    Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles myComPort.DataReceived
        TextBox1.Invoke(New myDelegate(AddressOf updateTextBox), New Object() {})
    End Sub
    Public Delegate Sub myDelegate()
    Public Sub updateTextBox()


        data = data + myComPort.ReadExisting()
        If Len(data) = 16 Then
            TextBox1.Text = TextBox1.Text + Microsoft.VisualBasic.Mid(data, 2, 11) & vbLf
            myComPort.DtrEnable = False
            RadioButton1.Enabled = False
            RadioButton2.Checked = True


            If CheckBox1.Checked = True Then
                Beep()
            End If


            Dim timeOut As DateTimeOffset = Now.AddMilliseconds(1500)
            Do
                Application.DoEvents()
            Loop Until Now > timeOut
            data = myComPort.ReadExisting()
            myComPort.DiscardInBuffer()
            data = ""
            myComPort.DtrEnable = True
            RadioButton1.Enabled = True
            RadioButton1.Checked = True


        End If
    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = ""
    End Sub
End Class

I tried running that but it cant read the RFID tag that i have, then after some seconds this what it outputs on the textbox.
Untitled1.png

Do you guys want me to post here the code of the sample program the manufacturer of the RFID gave me and can you also help me identify the code i need so i can connect the RFID to my project. Thanks in advance guys :3

Also here a picture of the sample program, it can read the rfid tag(2) that i have.
RRU1861.png

Hope you can help me guys with this. I really need this for my project. Thanks in advance.
 
Back
Top