Solved

Using a serial port

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.
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.

828 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