Problem:
Reading data from the COM port using WIN 32 APIs/Sending data to the COM port using WIN 32 APIs
Resolution:
INTRODUCTION
==========
This example program demonstrates how to access the systems Serial communications ports using Windows API function calls.
Two projects are used in this example. SENDCOM wants to send some data to whatever is connected to COM1. It starts by sending a message to the device to get its attention. READCOM then responds with a short "OK" message and then receives (without any response) whatever is sent by SENDCOM. SENDCOM ends the connection by sending a final "finish" message which, when received, causes READCOM to terminate. SENDCOM terminates after sending the finish message.
SOURCE FILES:
==========
Program Files Description
------------------- -----------------------------------------------------------
SENDCOM .CBL Program that communicates through the COM1 port. This file is in the project
directory SENDCOM.
READCOM .CBL Program that communicates through the COM2 port. This file is in the project
directory READCOM.
REQUIREMENTS:
==========
These example programs illustrate basic capabilities. They are intended to be Animated in two separate Net Express sessions on the same machine. SENDCOM uses COM1 to communicate with READCOM which is listening at COM2. I used a "LapLink" serial cable to connect COM1 and COM2 together. This is a very reliable "null modem" cable.
OPERATION:
========
Rebuild both projects to create the files SENDCOM.EXE and READCOM.EXE. These are character mode programs that will display their progress to an application output window.
NOTE:
====
When Animating these programs step to a read in one of the programs and then step to a write in the other program. Once positioned, step through the read and transfer to the other program and step through the write. Control will be transferred to the program completing the read.
The "Time-Outs" used in these examples are appropriate for Animation, ensuring that you will have sufficient time to move from program to program while Animating. The interval time-out setting would be appropriate for an application, but the "constant" time-out setting could be reduced.
If you need additional information on communication via the PC's com ports, I recommend Joseph W. Campbell as the author of books on this subject. His books may be difficult to locate, but they were the best.
==========================================================
Keywords: demonstration, sample, example, demo, win32 api, comport.zip
demo.ex
demo.me
demo.ne