TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Charles Gaefke
from: Coridon Henshaw
date: 1996-10-25 12:47:28
subject: DosDevIOCtl for COM ports

On Wednesday October 23 1996 at 00:27, Charles Gaefke wrote to All:

 CG>     I'm _trying_ to write some OS/2 routines (using Watcom 10.6) to control
 CG> the COM port..  and thus far I'm not having any luck.  The documention I have
 CG> seems to be FAR from user friendly.  I can't even lock the port at
a different
 CG> rate.  :)

Here's some port setup code of mine:

#define INCL_BASE
#define INCL_NOPMAPI
#define INCL_DOSDEVIOCTL
#include 


int Openport(char *Port, HFILE &Comhandle)
{

 APIRET rc;
 ULONG Retcode;

 LINECONTROL LineCTRL;
 DCBINFO DCB;
 MODEMSTATUS MSB;
 USHORT BPS = 57600;
 USHORT Comerror = 0;

 rc = DosOpen(Port, &Comhandle, &Retcode, 0, FILE_NORMAL,
OPEN_ACTION_CREATE_IF_NEW + OPEN_ACTION_OPEN_IF_EXISTS,
     OPEN_FLAGS_SEQUENTIAL + OPEN_SHARE_DENYWRITE + OPEN_ACCESS_READWRITE, NULL);

 if (rc != 0) return(1);

 rc = DosDevIOCtl(*Comhandle, 1, 0x41, &BPS, sizeof(USHORT), 0, NULL, 0, 0);

 if (rc != 0) return(2);

 LineCTRL.bDataBits = 8;
 LineCTRL.bParity = 0;
 LineCTRL.bStopBits = 0;
 LineCTRL.fTransBreak = 0;

 rc = DosDevIOCtl(*Comhandle, 1, 0x42, &LineCTRL, sizeof(LineCTRL), 0,
NULL, 0, 0);

 if (rc != 0) return(3);

 rc = DosDevIOCtl(*Comhandle, 1, 0x73, NULL, 0, 0, &DCB, sizeof(DCB), 0);

 if (rc != 0) return(4);

 DCB.usReadTimeout = 50;   //.50 seconds
 DCB.fbCtlHndShake = MODE_CTS_HANDSHAKE + MODE_DTR_CONTROL;
 DCB.fbFlowReplace = MODE_RTS_HANDSHAKE;
 DCB.fbTimeout = 0x4B;
 rc = DosDevIOCtl(*Comhandle, 1, 0x53, &DCB, sizeof(DCB), 0, NULL, 0, 0);

 if (rc != 0) return(5);

 MSB.fbModemOn = 0x01;
 MSB.fbModemOff = 0xFE;
 rc = DosDevIOCtl(*Comhandle, 1, 0x46, (void *)&MSB, sizeof(MSB), 0,
&Comerror, 2, (void *)&BPS);

 return(0);
}

--- GoldED/2 2.50 UNREG
* Origin: For sale: 30 pieces of silver. Contact N. Gingrich. (1:250/820)
SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 250/820 501 99 3615/50 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.