Solved

Using a serial port

Posted on 1998-06-30
1
232 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 50 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

Independent Software Vendors: 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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

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