How to Clear RS232 Input buffer

Posted on 2006-07-13
Last Modified: 2010-05-19
hi, All!

I try using PurgeComm(hComm, PURGE_RXCLEAR) to Clear RS232 Input Buffer before reading.
But It is not working, it always get the same message. Somebody could tell me how to do it.
And I also hope to clear input buffer automaticaly after I reading RS232.

Question by:abdate
LVL 17

Expert Comment

Comment Utility
You're using it correctly.
Make sure hComm is correct handle.

This is an example of clearing the rest of buffer after reading nCount bytes from it
    ReadFile(m_hPort, PChar(buf)^, nCount, nReceived, nil);
LVL 26

Accepted Solution

Russell Libby earned 50 total points
Comment Utility

1 - Does the function return success?
2 - If its failing, what is the error code (message)


  if not(PurgeComm(hComm, PURGE_RXCLEAR)) then


Author Comment

Comment Utility
Thanks all,

I find problem is from the other code. PurgeComm function is working well.


Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now