Results 1 to 4 of 4

Thread: [2005] need help to read data from com port for rfid reader

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    8

    [2005] need help to read data from com port for rfid reader

    Hi, i need help on how to start coding to read data from a RFID reader thru com port. i'm new to vb and i'm not sure how to start coding.

    Thus anyone can help me on how to go about coding the reading of data from the reader and updating the data up to database? what is the reference i need to add? etc...

    I'm using VB 2005 and MS SQL 2005.


    Thanks!

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] need help to read data from com port for rfid reader

    You can use the System.IO.Ports.SerialPort class included in .net 2.0 framework to communicate with your RFID. The first thing you should do is go to MSDN library and read the documentation for this class.
    Once you have the communication between the rfid and your app done, now you're looking at upload the data to a database... You can use ADO.Net for this... There are plenty of tutorials on ADO.Net floating around on the Internet, read some of them and try to do it yourself... if you still have problems, you can post a specific question here...

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    8

    Re: [2005] need help to read data from com port for rfid reader

    Hi,
    I've tried using the follow code (code1) to try to read from the RFID reader thru serial port and display it in a textbox but nothing happen.

    code1
    vb Code:
    1. Public Class Form1
    2.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    3.         Try
    4.             With port1
    5.                 .PortName = "Com1"
    6.                 .BaudRate = 115200
    7.                 .Parity = Parity.None
    8.                 .DataBits = 8
    9.                 .StopBits = StopBits.Two
    10.                 .ReadTimeout = -1
    11.             End With
    12.             port1.Open()
    13.             MsgBox("com1 ok!")
    14.         Catch ex As Exception
    15.             MsgBox(ex.ToString)
    16.         End Try
    17.     End Sub
    18.  
    19.     Private Sub port1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles port1.DataReceived
    20.         Me.TextBox1.Invoke(New AddItemDelegate(AddressOf AddItem), New Object() {})
    21.     End Sub
    22.  
    23.     Private Delegate Sub AddItemDelegate()
    24.  
    25.     Private Sub AddItem()
    26.         Dim itm As String = Me.port1.ReadByte()
    27.         Me.TextBox1.Text = itm
    28.     End Sub
    29. End Class

    from the command guide that comes with the reader, inside stated that for a "inventorised command" i need to send:
    command
    # of bytes 1
    description 0xF1

    in the source code they provided in vb6, the command is used is as following:

    vb Code:
    1. Private Sub Gen2Inventorised_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Gen2Inventorised.Click
    2.     Dim Code(0) As Byte
    3.        
    4.     If InventorisedFlag = False Then
    5.         If (ReadStatus = False) Then ' The button is not activated
    6.             If (MSComm1.PortOpen = True) Then ' Check if com port is opened
    7.                 Gen2Inventorised.Text = "Stop" ' Change the display to Stop
    8.                 Gen2_RFOnOff.Text = "RF Off"
    9.                 ReadStatus = True
    10.                 InventorisedFlag = True
    11.                 Code(0) = 241
    12.                 MSComm1.Output = VB6.CopyArray(Code)
    13.                 Else
    14.                 MsgBox("Com Port not Selected") ' Display com port not selected
    15.                 End If
    16.             Else
    17.                 Gen2Inventorised.Text = "Stop"
    18.                 InventorisedFlag = True
    19.                 Code(0) = 241
    20.                 MSComm1.Output = VB6.CopyArray(Code)
    21.             End If
    22.     Else
    23.             Gen2Inventorised.Text = "Inventorised" ' Change the display to Stop
    24.             InventorisedFlag = False
    25.             Code(0) = 244
    26.             MSComm1.Output = VB6.CopyArray(Code)
    27.     End If
    28. End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    8

    Re: [2005] need help to read data from com port for rfid reader

    Can someone help me how i shd code in vb 2005 using the system.io.ports
    i'm totally clueless on how to start.
    Thanks!
    if u guys need to see the codes for MSComm1, i can paste the code in here too.
    thanks again!

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