Solved

RS232 Communication in an MFC App

Posted on 1997-11-30
1
445 Views
Last Modified: 2012-06-21
I wish to write an MFC program that sends/receives data from COM2.  I know i can't use the inp and outp calls found in dos programs.  Are there any API functions that I can use? Can I use CFile to open and read/write to a serial port?
I would appreciate code snippets.  Many thanks!!!
0
Comment
Question by:karlon
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 40 total points
ID: 1174451
Use Win32 Communication Functions.

The following functions are used with communications devices.
 
BuildCommDCB  
BuildCommDCBAndTimeouts  
ClearCommBreak  
ClearCommError  
CommConfigDialog  
DeviceIoControl  
EscapeCommFunction  
GetCommConfig  
GetCommMask  
GetCommModemStatus  
GetCommProperties  
GetCommState  
GetCommTimeouts  
GetDefaultCommConfig  
PurgeComm  
SetCommBreak  
SetCommConfig  
SetCommMask  
SetCommState  
SetCommTimeouts  
SetDefaultCommConfig  
SetupComm  
TransmitCommChar  
WaitCommEvent  

There is a sample "Comm: Communications Demonstration" that comes with Win32 SDK or Visual C++.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best book to learn C++ 4 70
Problem with SqlConnection 4 160
How do I save this device context as a .bmp or a picture of some kind? 2 48
Why isn't object file created? 6 42
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

867 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

16 Experts available now in Live!

Get 1:1 Help Now