[fpc-pascal] Question on programming serial communication.

Rainer Hantsch office at hantsch.co.at
Mon Feb 25 18:13:59 CET 2008


On Mon, 25 Feb 2008, Johann Glaser wrote:

| >    I only want to use sme kind of API, Class, Object or set of procedures
| >    which allows me similar things as were possible with the FOSSIL 
| >    driver:
| >    - Buffered I/O
| >    - Flow Control as I need (RTS/CTS, XON/XOFF, Both, None)
| >    - Direct Control of control lines like DTR, ...
| >    - Possibilities for monitoring fill level of buffers, to force
| >      them to be erased (made empty), ...
| 
| In Linux you simply open() the /dev/ttySxx device and then read() and
| write() to it. This is for data, for other stuff (e.g. flow
| control, ...) can be done via ioctl() (please excuse the C syntax). But
| as Horacio already said you probably go better with a wrapper, e.g.
| Synaser or TSerial (but I didn't use either).

As far as I could find out some years ago, the /dev/ttySxx are having no 
buffer. I did first steps with writing a unit which gives me some interface 
similar to  that what I used for FOSSIL, but I always had blocking writes. I 
had to loop and wait, until the last char was sent. Well this is not such 
problematic in Unix because I can run that part as daemon and de-couple 
things a bit this way, but it is still unnecessarily complicated.

I cannot build a text string (as an example), write it to the buffer with an 
immediate return, and do other things while data are sent/received. -- At 
least I didn't get that working 10 years ago, so I gave finally up and took 
DOS, because I had to get my heating running, because winter was close, and 
FOSSIL allowed that. So this temporary solution is meanwhile running 10 years.

Some wrapper will surely be still required, because not very much will have 
changed at ttyS's. Is there some documentation about tSerial available?

"Luca Olivetti" mentioned SynaSer. I had a short look on the web site he 
pointed me to, but the first thing I read is: "This is library for blocking 
communication on serial ports. It is non-visual class as in Synapse, and 
programmer interface is very similar to Synapse..."
--> "BLOCKING" is the magic word which is the problem.   :-(

I see, I will have to do it by hands, writing a daemon by myself. I thought 
that FreePascal will possibly have such features built in meanwhile.

 

| Your second problem could be to find suitable Linux drivers for your
| special multiport-RS232 hardware. But I assume you already got it
| working.

Well, I run my self-invented bus protocol on one serial port. All 
microcontrollers (Microchip PIC) are sitting on a serial bus with 
opto-isolators, spread across my house, and each one has an address and can 
therefore be addressed precisely. So I can read the room temperatures and 
adjust the temperature of the central heating, position of mixers,...
And I only need one (serial) bus/port with 5 wires for that. :-D

But you are right, this part is no problem and approved since meanwhile 10 
years. (I wonder how quick time is running...)


mfg

  Ing. Rainer Hantsch

-- 
.---------------------------------------------------------------------.
|      \\|//              Ing. Rainer HANTSCH  -  Hardware + Software |
|      (o o)        Service - Support - WEB-Design und Programmierung |
|--oOOo-(_)-oOOo------------------------------------------------------|
| Ing. Rainer HANTSCH |  mail: office at hantsch.co.at                   |
| Khunngasse 21/20    |   www: http://www.hantsch.co.at               |
| A-1030 Vienna       |   tel: +43-1-79885380    fax: +43-1-798853818 |
| ** A u s t r i a ** | handy: +43-664-9194382   UID-Nr: ATU 11134002 |
'---------------------------------------------------------------------'



More information about the fpc-pascal mailing list