On Thu, 6 Jul 2000, Pavel Kucera wrote:

> Hi,
> 
> Please can you help me with special RS-232 communication.
> I want to use Linux to communicate with EIB bus thru RS-232.
> I have some message n bytes long, and I tried to send with read(),
> write() and CTS RTS functions.
> 
> But I have only 130ms to send this message. If this message
> is more than 9 bytes long, timeout appear and otherside resets.
> Can I use  another access to serial port for faster communication ?

As far as I see your application is time critical.

I assume that you do not want to write your own device drive
(which is sometimes really necessary, especially if you want to
do something with the handshake lines which is unusual).


 Due to the
fact that LINUX is a multitasking system this are my advices:

1: remove the printf() Statements of your code below.

Reason:  You should avoid unnecessary task switching in the
time critical code section: on each system call (if you are
unlucky) the kernel will switch to the next process, and it will
take some time (at least 10ms on my system) until your program
will be invoked again. So if you only have 130ms to react and
you send about 10-12 characters with the code below this must
fail... 


2: Try to let the linux serial driver do the handshake.
(see below on the remarks of your code).
This is much better than trying to do that manually using
functions of the c-library...


Of course I must say that I don't know what EIB is !
(let me know, please).
But I try to analyze your emission:

> 
> Only four lines (TxD, RxD, CTS, RTS) are used as follows:
> 
> -set RTS and wait for CTS to come up

This will be done by the Linux serial driver automtically if you
enable RTSCTS handshake upon initialization.

> -send n, receive byte
ok, each byte you send will be answered, right?

> -clear RTS and wait for CTS to come down
Why this? Is this part of the EIB protocol?
In fact this seems to me to be copied from a code for an older
microprocessor (running BASIC, most likely PET ;-) ) which had
no serial input buffer. It should not be really necessary
with Linux( or BSD and even MS-Win*) !!!

That you must receive a byte after you have send one is surely a
part of the EIB protocol. 

But try the following:

Just initialize the serial driver to use CTSRTS handshake upon
initialization (refer to the Linux serial Howto).
Before sending anything you should clear the input buffer.

!!      Then send your byte and wait for the response in a loop
!!      says your algorithm.

And just that is sometimes not successfull with Linux (also
MS-Win*, BSD and so on) !!

Better try the following:
write all the data you must send in one chunk and afterwards
read the answer-bytes from the EIB-opposite and analyse them (if
possible).

Regards,
        gme

--
++++++++++++
+ Gerald Emig Software, Engelstr. 17, D - 66564 Ottweiler
+ Tel.+Fax +49 6858 6197
+ http://sites.inka.de/heisch/
++++++++++++


-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to