Solved

Using a serial port

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now