Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Clear RS232 Input buffer

Posted on 2006-07-13
3
Medium Priority
?
1,158 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 150 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

927 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