| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: DosDevIOCtl for COM ports |
-=*>})Charles Gaefke was nattering on to All
about DosDevIOCtl for COM ports on Wed 23 Oct 96 00:27({<*=-
CG> I'm _trying_ to write some OS/2 routines (using Watcom 10.6) to
CG> control the COM port.. and thus far I'm not having any luck. The
CG> documention I have seems to be FAR from user friendly. I can't even
Yeah, no kidding, eh?
CG> lock the port at a different rate. :)
You need to relinquish control of the comm port, and then reset it, using
the new locked baud rate.
CG> Here's my code..
CG> #define INCL_DOSPROCESS
CG> #define INCL_DOSFILEMGR
CG> #define INCL_DOSDEVICES
CG> #include
CG> int main(void)
CG> {
CG> HFILE FileHandle;
CG> ULONG Action;
CG> ULONG FileSize, SizeInOut = 0L;
CG> USHORT FileAttribute = 32;
CG> ULONG baud=115200;
CG> APIRET rc;
CG> rc = DosOpen("COM2", &FileHandle, &Action, 0L, 0,
0x01, 0x0012,
CG> 0L);
CG> rc = DosDevIOCtl(FileHandle, 0x01, 0x43, &baud, 4L, &FileSize,
CG> NULL, 0L, &SizeInOut);
DCBINFO dcb ;
dcb.usWriteTimeout=0 ; // Set the write timeout
dcb.usReadTimeout=0 ; // Set the read timeout
dcb.fbCtlHndShake=MODE_DTR_CONTROL ; // Set the hardware control
dcb.fbFlowReplace=MODE_NULL_STRIPPING | MODE_RTS_HANDSHAKE ; // Set the
hardware handshake; remove nulls
dcb.fbTimeout=MODE_NOWAIT_READ_TIMEOUT ; // Set the timeout features
dcb.bErrorReplacementChar=0 ;
dcb.bBreakReplacementChar=0 ;
dcb.bXONChar
rc=DosDevIOCtl( FileHandle,
IOCTL_ASYNC,
ASYNC_SETDCBINFO,
&dcb,
CG> rc = DosClose(FileHandle);
CG>
CG> return 0;
CG> }
CG> Now, my questions being:
CG> A) what INCL_xxxx lines do I need?
Just the INCL_DOSPROCESS for the DosDevIOCtl() function.
CG> B) Could someone explain to me the "best" way to open a
COM port for
CG> reading and writing?
As you've done above...however, you should also set your device control
blocks (DCB's). These set your flow control and your breaking, among
other things.
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. 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?
No. The 6 parameter one is for OS/2 1.x (16-bit). However, it's 5
parameters, not 6.
CG> I'm really lost here, in case you hadn't noticed. :)
CG> Also, just to make sure, a "word" is an "int"
or "short", correct?
A word is an unsigned short. Compare with sword.
CG> And a "dword" is a "long", correct?
A dword is an unsigned long. Compare with sdword.
CG> And a "byte" is a "char", correct?
A byte is an unsigned char. Compare with sbyte.
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?
typedef struct _parmlist43 {
DWORD baudRate ; /* Baud rate */
BYTE divisor ; /* Divisor */
} PARMLIST43 ;
PARMLIST43 pl43 ; /* Declare
Instance of
Structure */
CG> If above is correct, then ParmLengthMax would be 5 ("dword" is 4
Oui, monsieur.
CG> bytes + "byte" which is 1 byte). What about DataLengthInOut,
CG> ParmLengthInOut, and DataLengthMax?
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?
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. :)
CG> Thanks..
CG> C. Gaefke
CG> cdgaefke{at}sgi.net
CG> [CDRMAIL Author]
CG> -!- RG05-11/CDRMAIL 104á
CG> ! Origin: LOTL/2 * 412 746 3592 * V34 33.6k * RGSNet PA Host
CG> (1:129/230)
--- Blue Wave/Max v2.12 OS/2 [NR]
* Origin: Enitharmon/2 Beta Home Site 604-527-0195 (1:153/8028)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: 153/8028 831 800 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™.