LAUFMAN-H@osu-20.ircc.ohio-state.edu (Harry Laufman) (12/04/89)
I'm TRYING to write a brief communication program which sets the COM
ports, dials, etc. using the Turbo PORT[n] array rather than calls
to MSDOS() and INTR(). Can this be done? Included is code fragment
showing my idea, which doesn't work. The program works if I first
Mode Com1: 24,n,8,1... but if I try to change the baud rate, parity
etc. the modem subsequently does not respond with its "OK" to ANY
modem command and the program hangs. The functions INREADY, XMITCHAR,
and RECVCHAR seem functionally sound as a terminal.
I use a record for the ComPorts of
Com2Port :ComPortAddress = (io_data :$2f8;
line_control :$2fb;
line_status :$2fd;
modem_control :$2fc;
modem_status :$2fe;
inter_enable :$2f9);
where the fields are words and reassign port used with
ComPortUsed:=Com2Port;
Function Inready: Boolean;
begin
Inready := (port[ComPortUsed.Line_Status] and 1) > 0;
end;
Function RecvChar: Char;
begin
RecvChar := chr(port[ComPortUsed.io_Data]);
end;
Procedure XmitChar(ch:char);
begin
port[ComPortUsed.io_Data]:=Ord(ch);
delay(DelaySec1000);
end;
Procedure AdjustMode(NewByte:Byte);
begin
Port[ComPortUsed.Line_Control]:=NewByte;
end;
Var Choice:Char;
Procedure SetComMode;
Var NewByte:Byte;
begin
GoToXY(1,4);
Writeln(' (1) 300 N 8 1 (2) 300 E 7 1 (7) COM1');
Writeln(' (3) 1200 N 8 1 (4) 1200 E 7 1 (8) COM2');
Writeln(' (5) 2400 N 8 1 (6) 2400 E 7 1');
Write (' Your Choice (Q)uit : ');
Choice:=Readkey;
{** Line Control Register
bit 7 baud for 765 :(000=110,001=130,011=600,100=1200,101=2400)
6 baud
5 baud
4 Even Parity
3 Parity Enable
2 1 or 2 (0 or 1) Stop bits
1 Always 1
0 7 or 8 (0 or 1) Data bits **}
Case Choice of
'1':AdjustMode($43); { 01000011 }
'3':AdjustMode($83); { 10000011 }
'5':AdjustMode($A3); { 10100011 }
'2':AdjustMode($5E); { 01011110 }
'4':AdjustMode($9E); { 10011110 }
'6':AdjustMode($BE); { 10111110 }
'7':ComPortUsed:=Com1Port;
'8':ComPortUsed:=Com2Port;
end;
end;
Thanks for any advice. Harry