|
-
Sep 21st, 2007, 11:12 PM
#1
Thread Starter
New Member
[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!
-
Sep 22nd, 2007, 07:52 AM
#2
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...
-
Oct 4th, 2007, 08:51 PM
#3
Thread Starter
New Member
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:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
With port1
.PortName = "Com1"
.BaudRate = 115200
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.Two
.ReadTimeout = -1
End With
port1.Open()
MsgBox("com1 ok!")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub port1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles port1.DataReceived
Me.TextBox1.Invoke(New AddItemDelegate(AddressOf AddItem), New Object() {})
End Sub
Private Delegate Sub AddItemDelegate()
Private Sub AddItem()
Dim itm As String = Me.port1.ReadByte()
Me.TextBox1.Text = itm
End Sub
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:
Private Sub Gen2Inventorised_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Gen2Inventorised.Click
Dim Code(0) As Byte
If InventorisedFlag = False Then
If (ReadStatus = False) Then ' The button is not activated
If (MSComm1.PortOpen = True) Then ' Check if com port is opened
Gen2Inventorised.Text = "Stop" ' Change the display to Stop
Gen2_RFOnOff.Text = "RF Off"
ReadStatus = True
InventorisedFlag = True
Code(0) = 241
MSComm1.Output = VB6.CopyArray(Code)
Else
MsgBox("Com Port not Selected") ' Display com port not selected
End If
Else
Gen2Inventorised.Text = "Stop"
InventorisedFlag = True
Code(0) = 241
MSComm1.Output = VB6.CopyArray(Code)
End If
Else
Gen2Inventorised.Text = "Inventorised" ' Change the display to Stop
InventorisedFlag = False
Code(0) = 244
MSComm1.Output = VB6.CopyArray(Code)
End If
End Sub
-
Oct 4th, 2007, 08:53 PM
#4
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|