Dec 222017
 
Short sample of Quick BASIC code that traps and returns baud rate.
File BAUDRATE.ZIP from The Programmer’s Corner in
Category BASIC Language
Short sample of Quick BASIC code that traps and returns baud rate.
File Name File Size Zip Size Zip Type
BAUDRATE.DOC 2048 1013 deflated
TPCREAD.ME 199 165 deflated

Download File BAUDRATE.ZIP Here

Contents of the BAUDRATE.DOC file


From: Donn Bly
To: Chris Holten Msg #101, 13-Jun-89 09:18pm
Subject: Help!

In a message of <10 Jun 89 15:50:01>, Chris Holten (1:303/1.1) writes:

>everywhere and is about 5k in size. To get QB to detect the Baud will
>most likely require that you write a routine in assembly or C to detect
>baud and then link it with QB. Try out Ray Gwins BAUD.* before you get
>too hot an heavy into it.

I have the following code floating around is my source code directory. I
don't know who wrote it (it wasn't me). It can be used to determine the BAUD
rate (It actually works too, even at 19200!)

DECLARE FUNCTION GetBaudRate% (Port%)
PRINT "COM1:"; GetBaudRate%(1)
PRINT "COM2:"; GetBaudRate%(2)

DEFINT A-Z
FUNCTION GetBaudRate% (Port%)

IF (Port% <> 1 AND Port% <> 2) THEN
GetBaudRate% = -1
EXIT FUNCTION
END IF

ADDR = &H4F8 - (&H100 * Port) ' base address of port reg's
ADDR.LCR = ADDR + 3 ' Line Control Register
ADDR.DL.LSB = ADDR + 0: ADDR.DL.MSB = ADDR + 1' Divisor Latch LSB & MSB
VAL.LCR = INP(ADDR.LCR) ' get old LCR value
OUT ADDR.LCR, VAL.LCR AND &H7F ' Disable DLAB to get to inters
VAL.INT = INP(ADDR.DL.MSB) ' Get the int enable statuses
OUT ADDR.DL.MSB, 0 ' Disable all modem intertupts
OUT ADDR.LCR, VAL.LCR OR &H80 ' Enable DLAB to gain access

'get the current baud rate

MSB = INP(ADDR.DL.MSB)
LSB = INP(ADDR.DL.LSB)'get old baud rate
DIVISOR = MSB * 2 ^ 8 + LSB

OUT ADDR.LCR, VAL.LCR AND &H7F ' Disable DLAB to get to inters
OUT ADDR.DL.MSB, VAL.INT ' Replace orig. inter. values
OUT ADDR.LCR, VAL.LCR ' Replace orig. LCR values

GetBaudRate% = (1843200! / DIVISOR) / 16

END FUNCTION



--- msged 1.99S ZTC
* Origin: [Copyright (C) The Loft -HST-, All Wrongs Reserved] 😉 (1:236/7)
SEEN-BY: 1/8 8/0 1 70 70/0 74/450 79/7 129/37 261/671 7000/16
SEEN-BY: 7001/1 7101/2 7700/0


 December 22, 2017  Add comments

Leave a Reply