Technical information

Pasterm Serial Solutions
Opening The File.________________
In Pasterm the Procedure ’Open_Com’ opens the port.
Figure 9-1. Procedure Open_Com.______________________________
PROCEDURE Open_Com; {Open COM port for input, output}
PROCEDURE Uncook (VAR Filename: FileRec); { Change the DOS mode of a
text file from cooked to raw }
VAR
ioregs :Registers;
BEGIN
WITH ioregs, Filename DO BEGIN
ax := $4400; { Function 44H, subservice 0H }
bx := Handle; { get device data. }
MsDos( ioregs );
dh := 0; { Set high byte of data zero }
dl := dl OR $20; { Set bit 5 of low byte-raw mode}
ax := $4401; { Subservice 1H, Set device data.}
bx := Handle;
MsDos( ioregs );
END;
END;
VAR
IO1,IO2 :Boolean;
BEGIN
{$I-}
Assign(Com_Inp,ComName); {Input Char file..}
Reset(Com_inp);
IO1 := IoResult <> 0; {Reset failed}
Assign(Com_Out,ComName); {Output Char file..}
ReWrite(Com_out);
IO2 := IoResult <> 0; {ReWrite failed}
{$I+}
IF
IO1 OR IO2
THEN BEGIN { Opens have failed }
Screen(’Failed to open ’+ComName+Newl,FromCtrl);
Screen(’Try different port parameters’+Newl,Fromctrl);
Close_Com; {Close files}
END
ELSE BEGIN { Opens ok }
UnCook(FileRec(Com_Inp)); {Set RAW data mode}
UnCook(FileRec(Com_Out)); {Set RAW data mode}
END;
END;
Chapter 9 Page 143