TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Charles Gaefke
from: Phil Crown
date: 1996-10-23 22:44:08
subject: DosDevIOCtl for COM ports

-=> Quoting Charles Gaefke to All <=-

 CG> Now, my questions being:
 CG> A) what INCL_xxxx lines do I need?

#define INCL_DOSDEVIOCTL

This one should resolve most ASYNC_IOCTL Category problems.
Also look in bsedev.h, *most* constants and structures are defined
there.

 CG> B) Could someone explain to me the "best" way to open a
COM port for
 CG> reading  and writing?

Best advice I can give is to get a copy of pmtermsr.lzh from Peter
Fitzsimmons.  Its an excellent multi-threaded comm port example.

 CG> C) For DosDevIOCtl, would someone explain, in detail (if at all
 CG> possible) what the ParmList is, and how/when to use it.. what the
 CG> DataArea is, and how/when  to use it, what the ParmLengthMax,
 CG> DataLengthMax, DataLengthInOut, and  ParmLengthInOut are, and how to
 CG> use them.

Its different for each function, you have to look at the docs for the
function to see what it should be.  Its always either a USHORT or a
ULONG, or a structure.  You only have to pass variables in one of the
items (Parameter or Data), and the other is NULL, 0, NULL.

    rc = DosDevIOCtl(hfHandle, IOCTL_ASYNC, ASYNC_GETCOMMERROR,
                     NULL, 0, NULL, &_usWord, sizeof(USHORT), NULL);

                     ^^^^^^^^^^^^^
                     First 3 are NULL.
                     Or it may be flip-flopped, the first 3 will be
                     variables and the last three are NULL.

 CB> D) I have two .INF files that give two different
 CG> specifications for the  DosDevIOCtl.  One needs 6 parameters, I
 CG> believe, and the other needs 9.   Unfortunately Watcom complains if I
 CG> only use 6, so I guess I should use 9.   The "6 parameter
one" would be
 CG> for OS/2 2.0 (pre-Warp), correct? 
 CG> I'm really lost here, in case you hadn't noticed. :)

I felt the same way when I started.  All take 9 parameters.

 CG> Also, just to make sure, a "word" is an "int"
or "short", correct?
 CG> And a "dword" is a "long", correct?
 CG> And a "byte" is a "char", correct?

WORD is two bytes (USHORT), DWORD is four bytes (ULONG), byte is a
UCHAR.  An int in OS/2 is four bytes.

 CG> So for function 0x43 in DosDevIOCtl for catagory 1, the ParmList
 CG> is  supposed to contain a "dword" (long baud=xxxxxx) and
a "byte" (char
 CG> divisor=xxxx)?  IF this is the case, how do you pass both of those as
 CG> one  parameter?  Use a structure?

Structure.

typedef struct _EXTSETRATEDATA {
    ULONG ulBitRate;
    BYTE  bFraction;
} EXTSETRATEDATA;

 CG> If above is correct, then ParmLengthMax would be 5 ("dword" is 4
 CG> bytes +  "byte" which is 1 byte).  What about DataLengthInOut,
 CG> ParmLengthInOut, and  DataLengthMax?

APIRET  Comport::setBaudExt(ULONG rate)
{
  ulPinout = sizeof(EXTSETRATEDATA);
  ulDinout = 0;

  extSetRateData.ulBitRate = rate;
  extSetRateData.bFraction = 0;

  rc = DosDevIOCtl(hfHandle, IOCTL_ASYNC, ASYNC_EXTSETBAUDRATE,
                  &extSetRateData, sizeof(EXTSETRATEDATA), &ulPinout,
                  NULL, 0, &ulDinout);
  return rc;
}

 CG> And if a port is "locked", do you have to
"unlock" it before you
 CG> can  change the rate, then do you have to "relock" it?

I'm lost here, I use SIO which locks the port.

 CG> I appreciate any and all feedback.  What would _really_ help me is
 CG> some  source code with comments telling me exactly what does what. :)

Get pmtermsr.lzh from Peter F.  I need a copy too, maybe he'll upload it
to an ftp site?

Phil Crown
pcrown{at}airmail.net
http://web2.airmail.net/pcrown/

--- Blue Wave/OS2 v2.30
* Origin: * MacSavvy OS/2 BBS * Dallas, Texas * 972-250-4479 * (1:124/1208)
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: 124/1208 1 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™.