?
Solved

Using a serial port

Posted on 1998-06-30
1
Medium Priority
?
245 Views
Last Modified: 2010-04-10
I'm using VC++ 5.0 w/ MFC
How do I write to a serial port specifying baud rate and COM port?
0
Comment
Question by:awong726
[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
1 Comment
 
LVL 1

Accepted Solution

by:
sergem earned 150 total points
ID: 1166939
There are two ways:
 If you want specify baud rate and other parameters use TAPI functions and particualary OpenLine. You have to specify that line you want to open is not a modem. Tor more information and samples see comm sample in Viaul C++

Second way is much simpler. You have to open file (Use CreateFile function) instead of file name use "COM1","COM2" or port name you want to open.

After this you would be able to Read/Write using standart WIN32 API functions ReadFile/WriteFile. To use overlaped i/o use ReadFileEx/WriteFileEx
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

718 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