| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Modem and Direct Screen Writes |
Replying to a message of Peter Schuller to Mikko Hyvarinen: MH>> OS/2 handles COM ports as files. So, when the BBS program passes you MH>> a 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 to work, this PS> is what a did PS> HFILE hCom = 0L; PS> ULONG ulAction = 0; PS> ULONG ulBytesRead = 0; PS> ULONG ulWrote = 0; PS> ULONG ulLocal = 0; PS> APIRET rc = NO_ERROR; PS> rc = DosOpen (_argv[1], &hCom, &ulAction, 100L, PS> FILE_NORMAL, PS> OPEN_ACTION_OPEN_IF_EXISTS, PS> OPEN_ACCESS_READWRITE, 0L); PS> But it won't work, DosOpen return 12. Maximus passes on porthandle "5" PS> for COM2. Is there any specific "flag" i have to use? DosOpen opens a file (or device) for which you give a name. Here you are trying to open a file or device, whose name is in argv[ 1 ], which, if I understand you correctly, is the (already open) file handle for the com port. So you don't have to use DosOpen at all. Just change the number held in the string argv[ 1 ] to an integer, and you have the file handle you can read from and write to: HFILE ComHandle; char pBufferArea[ 4096 ]; ULONG ulBufferLength, ulBytesRead, ulBytesWritten; APIRET rc; ComHandle = strtol( _argv[ 1 ], NULL, 10 ); /* assuming the handle was passed in base 10 format */ ulBufferLength = 4096; rc = DosRead( ComHandle, pBufferArea, ulBufferLength, &BytesRead ); ulBufferLength = strlen( pBufferArea); rc = DosWrite( ComHandle, pBufferArea, ulBufferLength, &BytesWritten); There is one problem with the above: If the BBS program didn't tell the com driver to return a DosRead after a certain period of time has expired, even if our buffer is not full yet, the DosRead will never return until 4096 characters have been received. To prevent this, the BBS program, right after using DosOpen to open the com port, has to use a DosDevIoCtl call. For information on this, look up ioctl functions, category 1 (async functions), function 0x53 (set the device control block). Marcel, Check out the baby pics; last updated on June 12, 1996: [Team OS/2] http://www.bright.net/~mvusse --- FleetStreet 1.16 NR* Origin: The Legacy Continues (1:2265/60.1) 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: 666/106 2265/60 2215/12 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™.