:
This message was edited by Xela at 2004-12-5 4:49:58
: I need to write Pascal program which sends REAL numbers in any form (text, binary) to other computer running Windows using COM port.
:
:
: Program COM;
:
: uses DOS;
:
: const filename='com1';
:
: const bd110 = 0;
: bd150 = 1;
: bd300 = 2;
: bd600 = 3;
: bd1200 = 4;
: bd2400 = 5;
: bd4800 = 6;
: bd9600 = 7;
:
: pNone = 0;
: pOdd = 1;
: pEven = 3;
:
: sI = 0;
: sII = 1;
:
: b7 = 2;
: b8 = 3;
:
: com1 = 0;
: com2 = 1;
: com3 = 2;
: com4 = 3;
:
: var R: Registers;
: OperationResult: Word;
:
: PROCEDURE WRITE_DATA(V2,TIME_IS,V,V1,V4,V5:REAL);
: VAR
: results: text;
: BEGIN;
: assign (results, filename);
: append(results);
: writeln(results,V,' ',TIME_IS,' ',V2,' ',V1,' ',V4,' ',V5);
: close(results);
: END;
:
: procedure Initialize (Port: Byte; Szybkosc: Byte; Parzystosc: Byte; Stop: Byte; Dlugosc: Byte);
: begin
: R.AH:=0;
: R.AL:=Dlugosc+Stop*4+Parzystosc*8+Szybkosc*32;
: R.DX:=Port;
: Intr ($14,R);
: OperationResult:=R.AX;
: end;
:
: begin
: Initialize (com1,bd9600,pNone,sI,b8);
: Write_Data (1,2,3,4,5,6);
: end.
:
:
: It doesn't work, giving:
: Error 160: Device write fault
:
: on the line:
: writeln(results,V,' ',TIME_IS,' ',V2,' ',V1,' ',V4,' ',V5);
:
: To test this program I run it on the computer with two COM ports connected with null-modem. Pascal program sends data to COM1, and WinXP Hyper Terminal is connected to COM2. Hyper Terminal connection parameters are:
:
: Bits per second - 9600
: Data bits - 8
: Parity - None
: Stop bits - 1
: Flow control - Hardware
:
: Is there some problem in this code? Maybe I can use some other code for serial communication, any working sample. Thanks.
:
:
:
It could be that you can only write to the COM using untyped files and not text or typed files. You should try that for starters. Otherwise, it could be that your COM1 is broken, or is blocked by the OS on which the pascal program runs.