varunkrish
Newbie level 5
rfid reader looping vb
Hello Friends
i am doing a project in RFID
I have purchased an RFID Reader.
They gave me some source code with it.
It has Connect and Read Tag buttons.
I click connect ,Serial connection is started.
i click read tag, the port is opened and the writer turns into active read mode and scans any tag i place nearby.
Now my problem.
After one tag is read ,i have to click the Read Tag again ( 4 times ) really funny to make it come to the active read mode.
I am a student and want to display an automated library .
SO how can i make the reader come back into read mode after reading a tag,
say after 5 seconds.
visual basic code:
Private Sub Command1_Click() ' Connect RFID read write unit
Call Connect
End Sub
Private Sub Connect()
Dim Mystring As String
Dim readdata As String
Dim dummy As Integer
'Check if port is open or closed
If (MSComm1.PortOpen = True) Then
MSComm1.PortOpen = False
Command1.Caption = "Connect" ' Change button caption
Else
' Initialize MSCOMM
MSComm1.CommPort = CStr(Right(Combo1.Text, 1))
MSComm1.Settings = "19200,n,8,1"
MSComm1.DTREnable = False
MSComm1.EOFEnable = False
MSComm1.Handshaking = comNone
MSComm1.InBufferSize = 512
MSComm1.InputLen = 24
MSComm1.InputMode = comInputModeText
MSComm1.NullDiscard = False
MSComm1.OutBufferSize = 512
MSComm1.ParityReplace = "?"
MSComm1.RThreshold = 0
MSComm1.RTSEnable = False
MSComm1.SThreshold = 8
MSComm1.PortOpen = True
Mystring = CStr(MSComm1.Input) ' Flush input
Command1.Caption = "Disconnect"
End If
again1:
Do While Checkport() = True ' IF RFID reader is still connected
Do
dummy = DoEvents()
Loop Until MSComm1.InBufferCount >= 8 ' Then loop until a new value is received
Mystring = CStr(MSComm1.Input) ' Store value received in 'MyString'
txtFields(0) = Mystring ' Show ID
txtFields(1) = (Date) ' Show current Date
txtFields(2) = (Time) ' Show current Time
readdata = Mystring & " @ " & Date & "=" & Time
List1.AddItem readdata
Loop
End Sub
Static Function Checkport() As Boolean
If (MSComm1.PortOpen = True) Then
Checkport = True
Else
Checkport = False
End If
End Function
Hello Friends
i am doing a project in RFID
I have purchased an RFID Reader.
They gave me some source code with it.
It has Connect and Read Tag buttons.
I click connect ,Serial connection is started.
i click read tag, the port is opened and the writer turns into active read mode and scans any tag i place nearby.
Now my problem.
After one tag is read ,i have to click the Read Tag again ( 4 times ) really funny to make it come to the active read mode.
I am a student and want to display an automated library .
SO how can i make the reader come back into read mode after reading a tag,
say after 5 seconds.
visual basic code:
Private Sub Command1_Click() ' Connect RFID read write unit
Call Connect
End Sub
Private Sub Connect()
Dim Mystring As String
Dim readdata As String
Dim dummy As Integer
'Check if port is open or closed
If (MSComm1.PortOpen = True) Then
MSComm1.PortOpen = False
Command1.Caption = "Connect" ' Change button caption
Else
' Initialize MSCOMM
MSComm1.CommPort = CStr(Right(Combo1.Text, 1))
MSComm1.Settings = "19200,n,8,1"
MSComm1.DTREnable = False
MSComm1.EOFEnable = False
MSComm1.Handshaking = comNone
MSComm1.InBufferSize = 512
MSComm1.InputLen = 24
MSComm1.InputMode = comInputModeText
MSComm1.NullDiscard = False
MSComm1.OutBufferSize = 512
MSComm1.ParityReplace = "?"
MSComm1.RThreshold = 0
MSComm1.RTSEnable = False
MSComm1.SThreshold = 8
MSComm1.PortOpen = True
Mystring = CStr(MSComm1.Input) ' Flush input
Command1.Caption = "Disconnect"
End If
again1:
Do While Checkport() = True ' IF RFID reader is still connected
Do
dummy = DoEvents()
Loop Until MSComm1.InBufferCount >= 8 ' Then loop until a new value is received
Mystring = CStr(MSComm1.Input) ' Store value received in 'MyString'
txtFields(0) = Mystring ' Show ID
txtFields(1) = (Date) ' Show current Date
txtFields(2) = (Time) ' Show current Time
readdata = Mystring & " @ " & Date & "=" & Time
List1.AddItem readdata
Loop
End Sub
Static Function Checkport() As Boolean
If (MSComm1.PortOpen = True) Then
Checkport = True
Else
Checkport = False
End If
End Function