110 likes | 235 Views
Reader. Antenna. RWM600 (13.56MHz). PCR300 硬體設備架設. RS232. VB + MSCOMM. USB. Step1 :安裝 RWM600X.OCX 元件. VB 讀取 RWM600 資料. Command1 & command2. RWM600x. label1. listbox. Step2 :設計介面. VB 讀取 RWM600 資料. VB 讀取 RWM600 資料. Step3 : 撰寫抓取資料程式 Form_Load :清空 listbox Command1_Click :啟動連線
E N D
Reader Antenna RWM600 (13.56MHz)
PCR300硬體設備架設 RS232 VB + MSCOMM USB
Step1:安裝RWM600X.OCX元件 VB讀取RWM600資料
Command1 & command2 RWM600x label1 listbox Step2:設計介面 VB讀取RWM600資料
VB讀取RWM600資料 • Step3:撰寫抓取資料程式 • Form_Load:清空listbox • Command1_Click:啟動連線 • Command2_Click:關閉連線 • RWM600x_OnTagEvent:擷取資料 • MODULE1:模組程式
變數與API函數宣告 Const LB_FINDSTRING = &H18F Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long • Private Sub Form_Load() • List1.Clear • End Sub
Private Sub Command1_Click() With RWM600x 'RWM600X物件 .PortOpen = False Sleep 50 For I = 0 To 255 '掃描PORT 1 -255 szPort = .EnumCommPort(I) If Left$(szPort, 3) = "COM" Then .CommPort = Val(Mid$(szPort, 4)) .PortOpen = True If .PortOpen Then If .gnetPolling(0) = -1 Then .PortOpen = False Else szVersion = .gnetVersion If InStr(szVersion, "PGM-T0562") > 0 Then Me.Caption = "目前連線連接埠:" & " (" & szPort & ")" .EnableAutoMode = True '啟動自動掃描 呼叫 RWM600x_OnTagEvent 事件 Exit For Else .PortOpen = False End If End If End If Else Exit For End If If .PortOpen Then Exit For Next I If .PortOpen = False Then Me.Caption = m_szCaption & " (找不到讀取器!!)" End If End With Command2.Enabled = 1 CmdConnect.Enabled = 0 End Sub
Private Sub Command2_Click() MsgBox "連線關閉" RWM600x.PortOpen = False CmdConnect.Enabled = 1 Command2.Enabled = 0 Me.Caption = "RWM600SK系統" End Sub
Private Sub RWM600x_OnTagEvent(ByVal nEvent As Integer, ByVal nDSFID As Integer) Dim bUID(7) As Byte ' Byte Array for UID, Size 8 Bytes (0~7) Dim szUID As String Dim I As Long Select Case nEvent Case TAG_PRESENT With RWM600x .GetCurrentUID VarPtr(bUID(0)) szUID = BytesToHexRev(bUID) 'szUID卡號 List1.AddItem szUID Label1.Caption = "卡片數:" + Str(List1.ListCount) End With Case TAG_REMOVED With RWM600x .GetCurrentUID VarPtr(bUID(0)) End With szUID = BytesToHexRev(bUID) List1.RemoveItem (SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(szUID))) Label1.Caption = "卡片數:" + Str(List1.ListCount) End Select End Sub 抓到的是16進制資料,需要轉換成10進制
Public total_card As Integer Public Function BytesToHexRev(ByRef bData() As Byte) As String Dim I As Long, szData As String On Error GoTo Err_Proc For I = LBound(bData) To UBound(bData) szData = Right$(Hex$(&H100 + bData(I)), 2) & szData Next I Err_Exit: BytesToHexRev = szData Exit Function Err_Proc: Debug.Print "ByteToHex - " & Err.Description & "(" & Err.Number & ")" szData = vbNullString Resume Err_Exit End Function
讀取方向:天線(Antenna)前後左右上下(ㄧ次一片)讀取方向:天線(Antenna)前後左右上下(ㄧ次一片) • 卡片完全重疊讀取(兩張) • 卡片重疊但離開一段距離讀取(兩張) • 卡片錯開讀取(兩張) • 卡片與讀卡機垂直讀取(ㄧ張) • 直接丟卡片上去(三張) • 一張張放上去(三張) • 將卡片放在書裡面一本本放上去(三張) • 讀到三張卡片後,一張張拿走 • 隔著壓克力讀取,看讀取距離的變化 • 隔著水讀取,看讀取距離的變化 • 隔著鐵讀取,看讀取距離的變化 • 貼在人身上讀取,看讀取距離的變化 • 隔著PVC讀取,看讀取距離的變化 • 隔著木頭讀取,看讀取距離的變化 • 旁邊使用大哥大,看是否影響讀取 RWM600測試項目