TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Marcel Vandevusse
from: Peter Schuller
date: 1996-07-28 15:18:52
subject: Modem and Direct Screen Writes

MV> DosOpen opens a file (or device) for which you give a name. Here you
 MV> are trying to open a file or device, whose name is in argv[ 1 ],
 MV> which, if I understand you correctly, is the (already open) file
 MV> handle for the com port.

 MV> So you don't have to use DosOpen at all. Just change the number held
 MV> in the string argv[ 1 ] to an integer, and you have the file handle
 MV> you can read from and write to:

 MV> HFILE ComHandle;
 MV> char pBufferArea[ 4096 ];
 MV> ULONG ulBufferLength, ulBytesRead, ulBytesWritten;
 MV> APIRET rc;

 MV> ComHandle = strtol( _argv[ 1 ], NULL, 10 ); /* assuming the handle was
 MV> passed in base 10 format */

Ugh... So there is a built-in fuction to convert the string.. errr... I've
always done that manually... Thanx!

 MV> ulBufferLength = 4096;  
 MV> rc = DosRead( ComHandle, pBufferArea, ulBufferLength, &BytesRead );

4096? Is that the maximum length a commandlineparameter can be?

 MV> ulBufferLength = strlen( pBufferArea);
 MV> rc = DosWrite( ComHandle, pBufferArea, ulBufferLength, &BytesWritten);

 MV> There is one problem with the above:
 MV> If the BBS program didn't tell the com driver to return a DosRead
 MV> after a certain period of time has expired, even if our buffer is not
 MV> full yet, the DosRead will never return until 4096 characters have
 MV> been received. To prevent this, the BBS program, right after using
 MV> DosOpen to open the com port, has to use a DosDevIoCtl call. For
 MV> information on this, look up ioctl functions, category 1 (async
 MV> functions), function 0x53 (set the device control block).

I'll look in to that, but that should have been taken are of already by Maximus.

Thanx!

/ Peter Schuller   [TeamOS/2]   petersch{at}kuai.se

--- FleetStreet 1.16 NR
* Origin: Gamma Epsilon 24h/day +46-(0)18-367781 (2:206/139)
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: 206/139 0 201/505 0 200 2104 109/347 18 13/25 396/1 270/101 712/515
@PATH: 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™.