Solved

How to Clear RS232 Input buffer

Posted on 2006-07-13
3
1,140 Views
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.

Regards,
abdate
0
Comment
Question by:abdate
3 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 17102489
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);
    PurgeComm(m_hPort,PURGE_RXCLEAR);
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 50 total points
ID: 17103981

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

eg:

  if not(PurgeComm(hComm, PURGE_RXCLEAR)) then
     ShowMessage(SysErrorMessage(GetLastError));


Russell
0
 

Author Comment

by:abdate
ID: 17119294
Thanks all,

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

Regards,
abdate
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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