Serial Communication
Serial Communication
Serial Communication
Serial Communication
Serial Communication
Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication
Serial Communication Serial Communication
Serial Communication
Go Back  Xtreme Visual Basic Talk > > > Serial Communication


Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2009, 12:15 AM
annaJ annaJ is offline
Newcomer
 
Join Date: Apr 2009
Posts: 1
Default Serial Communication


hi...
m new to vb.net coding and need help regarding couple of issues...

Serial communication.

My project requires serial communication. so I hav configured the serial communication through design at 9600 baud,no parity,8-bits and no stop bit. I hav also set the ReceivedBytesThreshold to 4 since the code,on receiving 4-bytes say ABCD , is supposed to look for the correct sequence and then display a message i.e. if i get d correct sequence "ABCD" then it will show a message.The problem is that when i send 4chars it does not show the message. but if send the sequence 3 times, then it goes into the loop and shows the message.after that if i send any more charactes, it does the processing of the previously received chars (stored in its buffer )and then processes further.


Code:
Private Sub SERIAL_PORT1_DATARECEIVED(ByVal sender As System.Object, 
        ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

        myQ1.Enqueue(SerialPort1.ReadChar)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim Ch As String
        Dim store As String
        Dim j As Integer
       
        Try
            While (True)
                
                Ch = ChrW(myQ1.Dequeue)
               
                If (Ch = "A") Then

                    Ch = ChrW(myQ1.Dequeue)
                    If (Ch = "B") Then

                        Ch = ChrW(myQ1.Dequeue)
                        If (Ch = "C") Then

                            Ch = ChrW(myQ1.Dequeue)
                            If (Ch = "D") Then

                                MessageBox.Show("HEY")
                                
                            End If

                            
                        End If


			END IF 
		END IF

END WHILE



Edit by Moderator: Per the Posting Guidelines please start your own threads to ask your own questions and please post VB.Net questions in the VB.Net boards. Thank you.

Last edited by Colin Legg; 04-24-2009 at 07:54 AM. Reason: added code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Serial Communication
Serial Communication
Serial Communication Serial Communication
Serial Communication
Serial Communication
Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication Serial Communication
Serial Communication
Serial Communication
 
Serial Communication
Serial Communication
 
-->