The port is connected to another machine, which is sending a string of data
at 4800 baud, 8N1.
My program looks something like
ASSIGN(data, 'COM1');
RESET(data);
REPEAT
READ(data,string);
WRITELN(string);
UNTIL string='end';
and I have done a MODE com1 4800,N,8,1 before running the program. It runs ok
with no errors, but nothing comes through from the port.
What am I doing wrong?
I'm using turbo-pascal, MSDOS3.3 (I've tried it on DOS 5 also).
Thanks,
Steve.
--
___
(o o)
--------------------------------ooO(_)Ooo----------------------------------
Steve Gilbert, 38 Melrose Road, Gainsborough, Lincs. DN21 2SD
st...@donald.demon.co.uk sgil...@cix.clink.co.uk
---------------------------------------------------------------------------
I think that may be your problem, it might think you are dealing with text file.
One big problem is this part:
REPEAT
READ(data,string);
WRITELN(string);
UNTIL string='end';
Actually, there are two problems, the first is that you are reading one letter
at a time, and WRITELN will put each letter on a new line. The second is that
since you are only reading one letter at a time, 'end' will never occur. A
quick-fix for this would be to have it quit when it found a certain character,
such as a ~. Oops, found another problem, you should write it so that it only
writeln's STRING when STRING is new. (Otherwise, you are going to have the last
letter repeating until another letter is sent)
If you look in the TP manual, there is a sample comm program, otherwise, I can
send you some code thru email.
-Greg
Yep, but for a _very_ subtle reason. Since he is using READ, it will not
be able to get past the end of the first line when reading strings! It seems
that he is assuming that TP reads one word at a time when reading strings.
Instead, TP reads whole lines at a time, unless the length of the string
is less than the length of the line. Try changing the READ to a READLN
and see if that will fix it.