Mathias Uhle wrote:
My problem: I want to open a serial device in a GP-Program to read and write to it in changing order. I look for a way that allowes to do (non blocking) read AND write to one single file-variable assigned to eg /dev/ttySx. So far I have found the "CanRead-function" in the manual which serves perfect for the non blocking job! But still I have to use two file-variables, one opened with reset, one opened with rewrite, and both symbolically linked to the desired serial file eg. /dev/ttySx. And it works, reading from the first when "CanRead" is true and writing to the latter whenever it is necessary.
Having read almost all portions of the GNU Pascal Manual nevertheless could not find a solution to use only one file-variable.
The following should work (I works on ordinary file):
program do_rw; var f : file of char; c : char; begin reset(f, '/dev/ttyS0'); write(f, 'b'); read(f, c); writeln(c); end .
The crucial point is that I use "file of char" (one can use other typed files, but for serial port using anything bigger then byte is going to loose). AFAICS bidirectional access to non-disk text files is not supported.