i need to clear the data on serial port when i have read the data from it before i read the data again? i m using c/c++ on windows xp
how can i do so ?
thanx in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The C++ standard has interfaces for writing to files, to the screen and to a log. It also has interfaces for reading from files and reading from “standard input.” There is no standard way to interact with serial ports, network connections, etc.
Luckily your operating system or platform will have an interface for this. But (1) what you have to do to read from a serial connection, and (2) what you need to do between consecutive reads, and (3) how to do it are all platform dependent.
Looking at some Microsoft Documentation, you don’t have to “clear the port” at all. But when a flag is set to signal something — for instance that an error occurred — then you need to reset the flag before continuing. Of course you reset the flag after handling whatever the flag was meant to signal.