[comp.windows.ms.programmer] Serial Port Programming Under Win3 - How?

scott@blueeyes.kines.uiuc.edu (scott) (03/03/91)

Hello All, New Windows Programmer here.

I just got Borland C++ 2.0, and of course I'm itchin' to try it out. As my
first "real" project, I want to write a Windows program to act as a user
interface for a video editing controller (Note: I've already written a 
similar program which runs under DOS). The edit controller interfaces with
the PC via an RS232 port at 1200bps. The PC sends commands (such as STOP, 
PLAY, REWIND, etc.) to the controller, and gets a response packet back from 
the controller after each command. 

The program places a modeless dialog box on the screen. On it are pushbuttons
for the various functions. Thus, when the user clicks on the PLAY button, the
program will send the PLAY command out the serial port to the controller,
wait for a response packet, and display the response in an area of the dialog
box. At least, this is how I want it to work.

I've bootstrapped myself up a little bit - I've figured out that I need to
use OpenComm, WriteComm, etc., but there are still some questions not 
addressed by the Windows Programmer's Refernce or the Petzold book. For
example, what are "Event Masks" (as set by SetCommEventMask()) used for?
Can I set an event mask which will automatically send a message when one
of the enabled events occurs? How would I implement a "timeout" error trap
routine? I would like to avoid the following: If the program sends a command
to the controller, but does not get a response packet within 100ms, this
problem needs to be recognized and dealt with; I don't want the program to
just hang forever waiting for a packet which may never come.

Are there any standard references for using the serial ports under Win3? 
Is there any freely available source code, and where can I get it? Any
other tips, tricks, caveats, etc. you'd like to share? 

Consider it a good investment - since there introduction of an affordable
Windows development tool, there's going to be a HUGE FLOOD of greenhorns
like myself asking similar questions. ;-)  If desired, I can create a summary
of responses and submit it for inclusion in the FAQ list.

Thanks!

-- 
Scott Coleman                                                    tmkk@uiuc.edu

"Unisys has demonstrated the power of two. That's their stock price today."
       - Scott McNealy on the history of mergers in the computer industry.