Solved

How to Clear RS232 Input buffer

Posted on 2006-07-13
3
1,144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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