parrish@dartvax.UUCP (Jerry Parrish) (03/03/85)
I'm trying to set the baud rate for the modem port from MacPascal. The manual says that "A file variable opened with 'modem:' as the title parameter reads from and writes to the modem at 300 baud." No problem, I say to myself, I'll use MacPascal's InLine facility to set 1200 baud via the Serial Driver or the Device Manager. That doesn't (read: I wasn't able to get it to...) work because the Serial Driver and Device Manager routines are OS traps, not Toolbox traps. Apparently, InLine only works for Toolbox traps. Can anyone tell me how to set the modem's baud rate from inside MacPascal, or (better) provide me with source code to do that, or (best) give me MacPascal code that does some serious communications work (a dumb terminal program, for example)? Please mail your answers to me. I'll post to the net when I find the solution to this problem. Thanks in advance. Jerry Parrish parrish@dartmouth.CSNET
parrish@dartvax.UUCP (Jerry Parrish) (03/13/85)
About a week and a half ago, I asked if anyone knew how to set the baud rate for the modem line from inside MacPascal. I received only one response (:-(), which was from John Peterson. He said that nobody seems to know how to do this, but that it doesn't matter since MacPascal is too slow to keep up with anything faster than 300 baud (the enforced default) anyway. Yet another problem "solved" by brute force... Jerry Parrish parrish@dartmouth.CSNET
parrish@dartvax.UUCP (Jerry Parrish) (03/29/85)
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
dtw@cmu-cs-k.ARPA (Duane Williams) (03/31/85)
There is an article on the use of Pascal's Generic procedure in the latest (April) issue of MacTutor. It explains in detail how to set up the parameters to the routine and gives as an example a routine which changes the modem port communication parameters. According to the article, Generic is in effect pre-declared as follows: procedure Generic (InstructionWord:integer; VAR Registers:RegRcd); RegRcd is a structure with 13 32-bit values: var Registers:record A0,A1,A2,A3,A4:^char; D0,D1,D2,D3,D4,D5,D6,D7:longint end; The register values are loaded into the 68K registers before the one-word instruction is executed. The Register structure is updated with the values from the 68K registers before Generic returns to your program. For further information, consult the article. MacTutor is obtainable from: MacTutor P. O. Box 846 Placentia, CA 92670 ($24/year, in the U.S.) -- uucp: ..!seismo!cmu-cs-k!dtw arpa: dtw@cmu-cs-k.ARPA