Solved

How to Clear RS232 Input buffer

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
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 …

932 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

13 Experts available now in Live!

Get 1:1 Help Now