Linux a komunikace pres 485
Stanislav Meduna
stano na trillian.eunet.sk
Neděle Duben 11 14:40:54 CEST 1999
On 11 Apr 1999 13:26:48 +0200, Ivo Zacek wrote:
: Pokud jde o ty prevodniky, tak jsem pro ne psal driver pro DOS. Protoze
: RS485 je poloduplex, musi se prepinat prijem/vysilani. Obvykle se to
: dela signalem RTS. Tady je problem, ze bezne seriove porty typu 16*50
: nedavaji preruseni, kdyz vysilani skutecne fyzicky skonci.
Pokial nie je absolutnou prioritou okamzita reakcia,
nie je problem poll-ovat stav registrov - ci uz z jadra,
alebo z user space. Komentar v drivers/char/serial.c
napr. pise:
/*
* get_lsr_info - get line status register info
*
* Purpose: Let user call ioctl() to get info when the UART physically
* is emptied. On bus types like RS485, the transmitter must
* release the bus after transmitting. This must be done when
* the transmit shift register is empty, not be done when the
* transmit holding register is empty. This functionality
* allows an RS485 driver to be written in user space.
*/
static int get_lsr_info(struct async_struct * info, unsigned int *value)
{
Vysledok tejto funkcie je do userspace mozne
dopravit cez ioctl TIOCSERGETLSR.
Existuje tiez funkcia rs_wait_until_sent(), ktora pocka
(samozrejme prerusitelne), kym sa vsetko posle von
a zda sa, ze sa snazia aj o minimalne oneskorenie:
/*
* Set the check interval to be 1/5 of the estimated time to
* send a single character, and make it at least 1. The check
* interval should also be less than the timeout.
*
* Note: we have to use pretty tight timings here to satisfy
* the NIST-PCTS.
*/
Ako tak grepujem jadro a manualy dalej, objavil som aj funkciu
tcdrain, ktora by mala robit to iste na lubovolnom deskriptore.
Zdravi
--
Stano
Další informace o konferenci Linux