How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
Go Back  Xtreme Visual Basic Talk > > > How to clear the input buffer of serial communication port?


Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2003, 09:40 AM
xiaoDD xiaoDD is offline
Regular
 
Join Date: May 2003
Posts: 52
Default How to clear the input buffer of serial communication port?


Hi,

I write a vB program to communicate with AT89C51 microcontroller via serial communication port. When I first run the program, the communication between the VB program and the AT89C51 works as expected. However, when I exit the program and then execute it again (after few seconds), I found that the first few bytes received from AT89C51 are not correct. I suspect that the input buffer of the serial port still has something after exit from the program and the data in the input buffer causes the first few received bytes of next program excecution to be not correct. Therefore, I think of clear (flush) the input buffer at the start of each program execution. Please advise how could I do that.

TQvM
Reply With Quote
  #2  
Old 06-21-2003, 02:09 PM
DrPunk's Avatar
DrPunkHow to clear the input buffer of serial communication port? DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

You can clear the Input Buffer and the Output Buffer by calling
Code:
MScomm1.InBufferCount = 0 MsComm1.OutBufferCount = 0
respectivly. What you are seeing can also happen on the output buffer and the device yu are talking to will have similar problems if so, so it's best to clear these too.

Rather than clearing them each time your program loads, clear them every time you are going to send something to ensure that nothing remains, i.e. write a PrepareComms (or the like) method that is called before each Output call and clears all the buffers.
Reply With Quote
  #3  
Old 06-21-2003, 08:14 PM
xiaoDD xiaoDD is offline
Regular
 
Join Date: May 2003
Posts: 52
Default

Hi DrPunk,

Thanks for sharing.

TQvM
Reply With Quote
  #4  
Old 09-17-2003, 12:14 AM
pshardi pshardi is offline
Newcomer
 
Join Date: Sep 2003
Posts: 1
Default

Hi,

I am having the same problem when I received incoming message from Serial Port. I tried to use the method you mentioned here, but it still doesn't work. Any other suggestion how to flush the buffer ?

thanks in advance
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Communication Serial Port Com1 anandxx Communications 2 03-06-2003 03:50 AM
How do you set up a serial port MScomm object? vbad Communications 2 12-12-2002 10:42 AM
Serial Port Communication El Gato Communications 1 10-30-2002 02:14 PM
Any possible way to set/reset PC serial port logic level via VB code? Flash Communications 4 09-06-2002 11:24 AM
Serial port communication viper8888 Communications 3 03-20-2002 12:47 PM

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
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port? How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
 
How to clear the input buffer of serial communication port?
How to clear the input buffer of serial communication port?
 
-->