TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Peter Schuller
from: Darin McBride
date: 1996-07-21 21:22:48
subject: Modem and Direct Screen Writes

PS>> 1) To write/read characters to/from an open port (such as doors do)
 PS>> how do I do? It should be pretty easy, I shouldn't have to set any
 PS>> bit-registers or baud-rate or whatever, read/write should be the
 PS>> only thing. So how du I read/write from/to an open port using
 PS>> port-handles passes by an BBS (since I can't access the port
 PS>> direktly, OS/2 wouldn't like that)

 MH> OS/2 handles COM ports as files. So, when the BBS 
 PS> program passes you a
 MH> COM handle, you can use it via DosWrite and DosRead.

 PS> I got a "tip" on that, tryed that, but I didn't get it 
 PS> to work, this is what a did

[example deleted]

Nonono.  :-)

Let's say Maximus gave you a "port handle" of 5 (since this is
what you mentioned).

Let's say you've taken that port handle and converted it back to int from
the string on the commandline (or is it in a DOOR.SYS or DORINFOx.DEF
file?) and stored that 5 in nPortHandle.

char ch;
USHORT usLenRead;
APIRET16 rc;

rc = DosRead(nPortHandle /* 5 */, &ch, sizeof(ch), &usLenRead);

Just use it, don't try to re-open it.  Heck, in the future it could be
COM36.  Or it could be a named pipe.  (Or an anonymous pipe.)  Or ... it
could be a parallel port modem (assuming you are on a system that can
handle them )!  Just using DosRead and DosWrite directly works.

If you'd like to stay a little farther from the OS, try using read/write
ANSI functions.  They should (theoretically ) work equally well.



--- Maximus/2 3.01
* Origin: Tanktalus' Tower BBS (PVT) (1:342/708)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1
@PATH: 342/5015 61 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™.