Article View: net.micro.mac
Article #1013Re: Setting modem baud rate from MacPascal
From: Jerry Parrish
Date: Fri, 29 Mar 1985 15:34
Date: Fri, 29 Mar 1985 15:34
65 lines
3039 bytes
3039 bytes
Apparently, there is a way to set the baud rate for the serial ports from
inside MacPascal. Scott Gillespie from Reed College sent me some code
written by Mike Byrne of THINK Technologies, Inc. that uses the builtin
procedure Generic to access the ROM serial driver. There's no mention of
Generic in the MacPascal documentation, so don't bother looking.
Here's a program that does nothing but set the modem line baud rate to
1200:
{HowToSetBaudRate will open the mode serialPort (serialA)}
{using the default settings (300 baud). A control call is done}
{to change the characteristics to a different baud. The ROM based}
{serial driver only supports _CONTROL calls to the output ports.}
program HowToSetBaudRate;
const
AOut = -7;{RefNum of serial output serialPort A}
Control = $A004;{Trap Number of _Control}
SetSCC = 8;{Reset SCC Channel}
FastBaud = $CC5E;{BD is 600 baud, 8 data bits, 2 stop and no parity bit}
{5E is 1200 baud, 17C is 300 baud}
type
ParamBlk = record
IOLink : LongInt;{queue link in header}
IOType : Integer;{type byte for safety check}
IOTrap : Integer;{FS: the Trap}
IOCmdAddr : LongInt;{FS: Address to dispatch}
IOCompletion : LongInt;{pointer to IOCompletion routine}
IOResult : Integer;{IO result code}
IOFileName : LongInt;{file name pointer}
IOVRefNum : Integer;{refnum}
IORefNum : Integer;{reference number for I/O operation}
IOFileType : Integer;{Type and permission access}
IONewType : Integer;{baud rate etc.}
end;
var
serialPort : text; {Port to transmit data over}
regs : record
a0 : ^ParamBlk;
a1, a2, a3, a4 : LongInt;
d0, d1, d2, d3, d4, d5, d6, d7 : LongInt;
end;
ParamBlock : ParamBlk;
begin
open(serialPort, 'modem:');{Open the serial port with default settings}
ParamBlock.IOCompletion := 0;
ParamBlock.IORefNum := AOut;
ParamBlock.IOFileType := SetSCC;
ParamBlock.IONewType := FastBaud;
Regs.A0 := @ParamBlock;{A0 pointer to Parameter Block}
Generic(Control, Regs);{Change the baud rate}
if Regs.D0 <> 0 then
writeln('Serial Port B error: ', Regs.D0);{Error codes returned in D0}
{Use the serial port}
close(serialPort);
end. {of HowToSetBaudRate}
That's it. I hope this helps someone.
Jerry Parrish
parrish@dartmouth.CSNET
Technical Details
Message-ID:
<2877@dartvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!dartvax!parrishReferences:
<2795@dartvax.UUCP> <2831@dartvax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site dartvax.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!dartvax!parrish From: parrish@dartvax.UUCP (Jerry Parrish) Newsgroups: net.micro.mac Subject: Re: Setting modem baud rate from MacPascal Message-ID: <2877@dartvax.UUCP> Date: Fri, 29-Mar-85 10:34:50 EST Article-I.D.: dartvax.2877 Posted: Fri Mar 29 10:34:50 1985 Date-Received: Sun, 31-Mar-85 03:26:14 EST References: <2795@dartvax.UUCP> <2831@dartvax.UUCP> Distribution: net Organization: Dartmouth College, Hanover, NH Lines: 65