mon678 48 Report post Posted February 29, 2012 tolong sy kawan2 perlukan utk simple coding utk baca S/N drpd RFID reader dan masuk ke dalam database. p/s : using visual studio 2008 and SQL server 2005 Quote Share this post Link to post Share on other sites
NeoLogy 74 Report post Posted February 29, 2012 ape interface dia?COM? Quote Share this post Link to post Share on other sites
mon678 48 Report post Posted March 1, 2012 interface -> [img]http://s12.postimage.org/oa93sybnt/Untitled.jpg[/img] scan RFID card utk login... COM port x slh aku Port 8 rasenya nnti aku cek blik Quote Share this post Link to post Share on other sites
NeoLogy 74 Report post Posted March 1, 2012 Pakai RS232 la ni?takat nak baca COM dari mana2 port xde hal..cuma data structure tu kena tahu dulu macam mana...header brape byte, body brape byte..ada brape section..then brape dia punya baud rate.. Quote Share this post Link to post Share on other sites
mon678 48 Report post Posted May 14, 2012 [quote name='NeoLogy' timestamp='1330621589' post='1079787'] Pakai RS232 la ni?takat nak baca COM dari mana2 port xde hal..cuma data structure tu kena tahu dulu macam mana...header brape byte, body brape byte..ada brape section..then brape dia punya baud rate.. [/quote] aku dh buat coding RFID utk detect card dri com yg di pilih tp setelah detect card tu ada error "invoke".... coding nya adalah seperti berikut -> Public Class Form1 Dim WithEvents myComPort As New System.IO.Ports.SerialPort Dim data As String Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ComboBox1.Enabled = True Button2.Enabled = False Button1.Enabled = True RadioButton1.Enabled = False RadioButton2.Checked = True myComPort.Close() End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If Not ComboBox1.SelectedItem Is Nothing Then If Not myComPort.IsOpen Then Try myComPort.BaudRate = 19200 myComPort.PortName = ComboBox1.SelectedItem myComPort.Parity = IO.Ports.Parity.None myComPort.DataBits = 8 myComPort.StopBits = IO.Ports.StopBits.One myComPort.Handshake = IO.Ports.Handshake.None myComPort.ReadTimeout = 3000 myComPort.ReceivedBytesThreshold = 1 myComPort.DtrEnable = True myComPort.Open() ComboBox1.Enabled = False Button1.Enabled = False Button2.Enabled = True RadioButton1.Enabled = True RadioButton1.Checked = True Catch ex As Exception MsgBox("Error Opening COM Port", MsgBoxStyle.Critical) End Try End If Else MsgBox("Select a valid COM Port", MsgBoxStyle.Information) End If End Sub Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For Each portName As String In My.Computer.Ports.SerialPortNames ComboBox1.Items.Add(portName) Next ' CheckBox1.Checked = True If Not myComPort.IsOpen Then Button2.Enabled = False ComboBox1.Text = ComboBox1.Items(0) RadioButton1.Enabled = False RadioButton2.Checked = True Else Button1.Enabled = False ComboBox1.Text = myComPort.PortName RadioButton2.Checked = True End If End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged myComPort.DtrEnable = True End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged myComPort.DtrEnable = False End Sub Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles myComPort.DataReceived TextBox1.Invoke(New myDelegate(AddressOf updateTextBox), New Object() {}) myComPort.Close() End Sub Public Delegate Sub myDelegate() Public Sub updateTextBox() data = data + myComPort.ReadExisting() If Len(data) = 4 Then TextBox1.Text = TextBox1.Text + Microsoft.VisualBasic.Mid(data, 1, 4) myComPort.DtrEnable = False RadioButton1.Enabled = False RadioButton2.Checked = True 'If CheckBox1.Checked = True Then 'Beep() 'End If Dim timeOut As DateTimeOffset = Now.AddMilliseconds(1500) Do Application.DoEvents() Loop Until Now > timeOut data = myComPort.ReadExisting() myComPort.DiscardInBuffer() data = "" myComPort.DtrEnable = True RadioButton1.Enabled = True RadioButton1.Checked = True Me.Close() 'Me.Hide() End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Text = "" End Sub End Class interfacenya begini -> [img]http://img851.imageshack.us/img851/5724/68796298.jpg[/img] Quote Share this post Link to post Share on other sites
halim56 0 Report post Posted July 14, 2012 (edited) salam mon678, sample code yg u download tu mula2 nampak macam tak working(value yg kuar cth "?"). So setelah digodek2 beberapa kali dapatlah jgak value dari card tu. data = data.Replace(ch, "") tu untuk replace character yg tak berkenaan. selamat mencuba. myComPort.BaudRate = 9600 .......................... Public Sub updateTextBox() Thread.Sleep(100) data = myComPort.ReadExisting Dim ch = Mid(data, 1, 1) data = data.Replace(ch, "") ch = Mid(data, 11, 11) data = data.Replace(ch, "") 'If Len(data) = 12 Then TextBox1.Text = TextBox1.Text + data & vbNewLine 'TextBox1.Text + Microsoft.VisualBasic.Mid(data, 2, 11) & vbLf 'myComPort.DtrEnable = False RadioButton1.Enabled = False RadioButton2.Checked = True If CheckBox1.Checked = True Then Beep() End If Dim timeOut As DateTimeOffset = Now.AddMilliseconds(500) Do Application.DoEvents() Loop Until Now > timeOut 'data = myComPort.ReadExisting() 'myComPort.DiscardInBuffer() data = "" myComPort.DtrEnable = True RadioButton1.Enabled = True RadioButton1.Checked = True 'End If End Sub Edited July 14, 2012 by halim56 Quote Share this post Link to post Share on other sites