Am Samstag, den 22.04.2006, 08:22 +0100 schrieb Ian bell: > Marc Santhoff wrote: > > Am Freitag, den 21.04.2006, 22:28 +0100 schrieb Ian bell: > > > >>I am just starting to port some programs to fpc using Lazarus form > >>Tcl/Tk. I have some questions about things I can do fairly easily in > >>Tcl/Tk which I am not sure how to achieve in fpc/lazarus. At present I > >>only need Linux specific answers. > >> > >>1. I am connecting to an external microcontoller development board by > >>a serial interface. I need to be able to set this interface non > >>blocking. I can see how to open the serial interface using the serial > >>unit but it is not clear how to set it non blocking. > > > > > > For Linux/*nix there is the "serial" unit, does something similar here. > > See > > > > <fpc-source-dir>/rtl/unix/serial.pp > > > > Yes, as I mentioned above I looked at the 'serial' unit. It seems to > basicaly call fpopen as expected. To set the serial port paramaters, > which includes blocking, a call to ioctl is normaly needed which > appears to be implemented by a call to tcsetattr which I assume is in > the termio unit. I have now tracked this down and the tcsetattr seems > to be inplemented by a cal to fpioctl -surprise surprise! The only > other unit used by termio is BaseUnix.
Thats correct. If you want to know even more about Unix serial programming you can read this one: http://www.easysw.com/~mike/serial/serial.html Programming examples are in C but you can do all of that in fpc, too. Or you could try synapse, as someone in this thread mentioned, looks pretty good (if I had known that it is bsd-licenced, cross plattform and fpc compatible I would have uesd it from the start, I think ...). -> http://www.ararat.cz/synapse/ > >>2. I need to respond to the occurence of input on the serial port. > >>This is trivial in Tcl - fileevent FileDescriptor FunctionName - how > >>do I achieve this in fpc? > > > > > > Hum, not sure about this, but maybe a "select" on the port will help? > > Another possibility would be to watch the status lines (in a separate > > thread if necessary) or simply the input data ... depend on what event > > you're waiting for. > > > > I think this is an additional filed in the termios structure which I > gues is the same as the one used in C. It's a system call, the doc mentioned above has a chapter about using it. Or try "man select" in a terminal. Regards, Marc _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
