🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7152

Re: modem programming in BASIC

#7152
From: Steve Resnick
Date: Wed, 19 Jun 1991 20:12
84 lines
4364 bytes
In article <1991Jun19.060721.26616@kessner.denver.co.us> david@kessner.denver.co.us (David Kessner) writes:
>In article <1991Jun18.175638.8957@murdoch.acc.Virginia.EDU> dmm0t@holmes.acc.Virginia.EDU (Dave Meyer) writes:
>>I'm trying to write a string to my modem in BASIC, but when
>>I try to open the COM port I get device timeouts.  I'm using
>>OPEN "COM1:9600,n,8,1" as #1
>>to get these timeouts.  I vaguely remember reading about this,
>>and there was a very simple solution to the problem.  Sadly,
>>I don't remember what it was.
>>
>>Does anyone happen to remember how to open a COM port with
>>a modem attached?  If it matters, I have a USR HST 9600.
>>
>
>I strongly reccomend that you don't access the modem in that way-- or
>if you do, don't run it at anything above 1200 baud.  The reason why is
>because you are going though DOS _and_ the BIOS.  The BIOS is pittifully
>slow and putting DOn on top of that is asking for trouble.  The other reason
>is that the DOS/BIOS routines are not intterupt driven, essentally giving
>you a ONE byte buffer.  If you cannot read that byte before the next one
>comes in then you will loose characters, and in BASIC this is highly possible.
>

The BASIC interpreter (or compiler) uses an interupt driven asynch driver.
BASIC can talk at higher speeds than 1200 baud w/o polling. The problem here
is that of signals, since BASIC expects DSR to be active before allowing
communications. (This is according to my GW-BASIC user's manual)

To open the port, try this:

OPEN "COM1:9600,n,8,1,rs,ds,cd" as #1

This will keep basic from bitching....

>The 'proper' way to access the serial ports in MS-DOS is to write a small
>assembly language driver with an 'interface' to the language of choice (BASIC,
>C, Pascal, etc).
>
>Given that here is how I would access the modem using _your_ way.  (Please
>keep in mind that I have not written in BASIC for five years.)

I don't want to sound like an asshole or anything, but your absence from BASIC
shows. BASIC, BASICA, GWBASIC, IBM BASIC Compiler, and ALL of the MS BASIC and
QuickBASIC compilers have always worked this way.

SoapBox: On

Being a long time reader on the net, contributing here and taking there,
I have found that incorrect information can be more damaging than no
information at all.

SoapBox: Off

> Anyway, I
>would use the DOS 'mode' command to set the baud rate, parity, etc.  Then,
>in BASIC I would open the file 'com1' for READ AND WRITE.  I don't believe 
>that you can set the baud rate from the open command-- but I could be 
>wrong.  At any rate, this method is only reliable at slow speeds and
>is only useful when sending to a printer...
>

The DOS mode command is useless in this instance, since BASIC wants to
open the port itself, and initialize its parameters. OPEN "file" and
OPEN "COMn:" are treated differently. Also note that when BASIC is
dealing with a device, the device name MUST be preceded by a colon.


>David Kessner - david@kessner.denver.co.us            |
>1135 Fairfax, Denver CO  80220  (303) 377-1801 (p.m.) | Reunite PANGEA!
>Compuserve?  Isn't that some sort of FIDO BBS?        |
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nah .... Fido has more class!
              

Really, I'm not trying to flame you. :)

- Steve

-- 
-------------------------------------------------------------------------------
        resnicks@netcom.com, steve@camphq, IFNA:        1:143/105.0, 
                 co moderator for comp.binaries.os2
 Real life: Steve Resnick. Chief Software Architect, Process Scientific, Inc
 Flames, grammar and spelling errors >/dev/null
 The Asylum OS/2 BBS - (408)263-8017 12/2400,8,1 - Running Maximus CBCS 1.2
-------------------------------------------------------------------------------
Technical Details
Message-ID: <1991Jun19.201250.12330@netcom.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!netcomsv!resnicks
References: <1991Jun18.175638.8957@murdoch.acc.Virginia.EDU> <1991Jun19.060721.26616@kessner.denver.co.us>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!netcomsv!resnicks
From: resnicks@netcom.COM (Steve Resnick)
Newsgroups: comp.os.msdos.programmer
Subject: Re: modem programming in BASIC
Message-ID: <1991Jun19.201250.12330@netcom.COM>
Date: 19 Jun 91 20:12:50 GMT
References: <1991Jun18.175638.8957@murdoch.acc.Virginia.EDU> <1991Jun19.060721.26616@kessner.denver.co.us>
Organization: Netcom - Online Communication Services  UNIX System {408 241-9760 guest}
Lines: 84