HOME > .NET Framework > Forum > คัยรู้เรื่อง rfid ช่วยดูหน่อยคับ (vb.net) คือผมลองทำตามลิ้งนี้ อ่ะคับ แล้วมันอ่านแล้วก้อเขียนไม่ได้คับ โค้ดผิดตรงไหนหรือป่าวช่วยดูทีคับ
คัยรู้เรื่อง rfid ช่วยดูหน่อยคับ (vb.net) คือผมลองทำตามลิ้งนี้ อ่ะคับ แล้วมันอ่านแล้วก้อเขียนไม่ได้คับ โค้ดผิดตรงไหนหรือป่าวช่วยดูทีคับ
Imports VB = Microsoft.VisualBasic
Imports System.Data.SqlClient
Public Class frm_ReadTag
Dim j As Short
Dim port, baud As Integer
Dim buf(200) As Byte
Dim b1 As Byte
Dim s1 As String
Dim counttags As Short
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub frm_ReadTag_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim flag As Object
Dim lb_info As Object
Dim port, i, baud As Integer
Dim j As Short
Dim buf1(200) As Byte
port = 2 'กำหนด port
If (port = 0) Then
lb_info.Caption = "Please select COM Port!"
End If
baud = CInt(9600) ' กำหนด Rate
If (baud = 0) Then
lb_info.Caption = "Please select Baud rate!"
End If
'Open Port
i = rf_init_com(port, baud)
If (i <> 0) Then
MsgBox("Open Port Fail!")
Exit Sub
Else
flag = True
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' ตั้งเวลา อ่าน Tag
Dim s As Short
Dim sdata(200) As Byte
Dim sLen As Byte
Dim b3, b2 As Byte
'b3 = CByte(3)
b2 = CByte(3)
TextBox1.Text = ""
If ISO15693_Read(0, 0, buf(1), b3, b2, sdata(0), sLen) <> 0 Then
MsgBox("Red data faile", MsgBoxStyle.Critical, "")
Exit Sub
Else
For s = 0 To sLen - 1
TextBox1.Text = TextBox1.Text & VB.Right("0" & Hex(sdata(s)), 2)
Next
TextBox1.Text = TextBox1.Text.Substring(0, 8)
End If
End Sub
End Class
Tag : - - - -
Date :
2009-07-17 01:10:49
By :
moshi555
View :
3357
Reply :
5
No. 1
Guest
ลองตรวจสอบเครื่องอ่านผ่าน hyperterminal หรือ debug tool(มีรึป่าวไม่แน่ใจ) ที่มากับ strong
link ยังครับ ถ้าอ่านได้ค่อยไปเช็คโค้ดต่อครับ
Option Strict Off
Option Explicit On
Module mo_declare
Public Declare Function rf_init_com Lib "MasterRD.dll" (ByVal port As Integer, ByVal baud As Integer) As Integer
Public Declare Function rf_ClosePort Lib "MasterRD.dll" () As Integer
'******************************************MF1*****************************************
Public Declare Function rf_request Lib "MasterRD.dll" (ByVal icdev As Short, ByVal model As Byte, ByRef TagType As Short) As Integer
Public Declare Function rf_anticoll Lib "MasterRD.dll" (ByVal icdev As Short, ByVal bcnt As Byte, ByRef ppsnr As Byte, ByRef pRLength As Byte) As Integer
Public Declare Function rf_select Lib "MasterRD.dll" (ByVal icdev As Short, ByRef pSnr As Byte, ByVal srclen As Byte, ByRef size As Byte) As Integer
Public Declare Function rf_M1_authentication2 Lib "MasterRD.dll" (ByVal icdev As Short, ByVal model As Byte, ByVal block As Byte, ByRef key As Byte) As Integer
Public Declare Function rf_M1_read Lib "MasterRD.dll" (ByVal icdev As Short, ByVal block As Byte, ByRef buff As Byte, ByRef pLen As Byte) As Integer
Public Declare Function rf_M1_write Lib "MasterRD.dll" (ByVal icdev As Short, ByVal block As Byte, ByRef buff As Byte) As Integer
Public Declare Function rf_halt Lib "MasterRD.dll" (ByVal icdev As Short) As Integer
Public Declare Function rf_M1_initval Lib "MasterRD.dll" (ByVal icdev As Short, ByVal block As Byte, ByVal Value As Integer) As Integer
Public Declare Function rf_M1_readval Lib "MasterRD.dll" (ByVal icdev As Short, ByVal block As Byte, ByRef pValue As Byte) As Integer
Public Declare Function rf_M1_increment Lib "MasterRD.dll" (ByVal icdev As Short, ByVal block As Byte, ByVal Value As Integer) As Integer
Public Declare Function rf_M1_decrement Lib "MasterRD.dll" (ByVal icdev As Short, ByVal block As Byte, ByVal Value As Integer) As Integer
Public Declare Function rf_beep Lib "MasterRD.dll" (ByVal icdev As Short, ByVal Value As Integer) As Integer
Public Declare Function rf_light Lib "MasterRD.dll" (ByVal icdev As Short, ByVal color As Integer) As Integer
'////////////======== Function ISO14443B Function ================================
End Module