Rts dtr in linux

What do IRQ, RTS, DTR & DSR mean here?

Got the below output on my linux. What do TX, RX, IRQ, RTS, DTR, DSR mean here in this context. I have read about Data Terminal Ready & Request to Send, but need help in understanding them in the example shown below. Do the numbers next to TX and RX mean the current number of characters in the respective buffer?

cat /proc/tty/driver/serial serinfo:1.0 driver revision: 0: uart:16550A port:000003F8 irq:4 tx:0 rx:0 1: uart:16550A port:000002F8 irq:3 tx:111780 rx:1321 RTS|DTR|DSR 

«Do the numbers next to TX and RX mean the current number of characters in the respective buffer?» Not characters.. bytes.. but yes.

1 Answer 1

You are looking at hardware attributes, statistics and status reported by a Linux serial terminal (e.g. UART or USART) device driver.

Do the numbers next to TX and RX mean the current number of characters in the respective buffer?

The numbers represent the number of frames that have been handled (transmitted and received respectively) by the device.
The frame size is configurable; the frame size could be for a full byte of 8 bits, or just 7 bits for ASCII characters.
The frame size is often also referred to as the character size, especially in UART/USART datasheets, which do not presume that «character» equates to ASCII codes.

This frame is delimited by the start and stop bits.

What do TX, RX, IRQ, RTS, DTR, DSR mean here in this context.

The irq is the (hardware) interrupt number that this device is using.

Читайте также:  Red hat linux buy

The active state of attached control lines (e.g. RTS, DTR, DSR) is reported.
If the name of the control line is listed, then that line is in an asserted state.
If the name of the control line is not listed, then that line is not asserted or is not even connected.
But the report of a control line could still be bogus (i.e. it’s listed but not connected) if it is not properly (electrically) pulled down/up and left «floating».

The port: indicates that this device is accessible at the given I/O port address.
Other devices might instead use memory-mapped I/O addresses, designated with MMIO: .

To see why your reference to a «buffer» is ambiguous, refer to the article Serial drivers for serial terminal and device driver relationships, and the various buffers involved.

Besides the frame counts for transmit and receive, other (receiver) statistics may be reported (when greater than zero):

fe: framing errors (stop bit not found) pe: parity errors brk: break conditions oe: receiver overrun errors bo: buffer overrun errors (not all drivers accumulate this number) 

These receiver statistics are typically counts of hardware-detected events, so consult the relevant datasheet for the exact how & what the hardware is reporting.

Besides the RTS, DTR, and DSR control lines that you mention, the CTS, CD, and RI can also be reported.

This information is reported by the Linux kernel routine uart_line_info() in the drivers/tty/serial/serial_core.c file.

Источник

Как управлять DTR/RTS порта?

Видимо, эти ioctl’ы старые. У меня ядро 5.0.4. Как в нем принято это делать? Работаю с эмулятором PL2303 на STM32F103.

Читайте также:  Сокет линукс что такое

UPD. Проверил на «настоящем китайском» PL2303: работает без ошибок. А мой эмулятор выдает ошибку и в dmesg вижу

pl2303 ttyUSB0: pl2303_set_control_lines - failed: -71

Вы сейчас чьим UARTом управляете , аппаратным (STM32) или вымышленным (эмулятором PL2303) ?

Я просто хочу передать ноль в состоянии DTR или RTS. Железяка на STM32 подключена к USB компьютера и эмулирует эмулятор последовательного порта PL2303. При подключении по сигналу SET_CONTROL_LINE_STATE от компьютера приходит DTR=1, RTS=1. А мне хочется переслать другие значения. На том же PL2303 можно таким образом дрыгать двумя ногами (что дает возможность сделать двухканальную USB-релюшку без микроконтроллера).

Уверены , что там полная эмуляция ? Даже если RXD-TXD работает , и даже если работает RTS ( квитирование при передаче данных ) оно может и не управляться как GPIO (дрыганьем ног).

Этот самый bitbang в PL2303 есть ? Вроде нет , насколько помню . В нем есть :Two general purpose I/O (GPIO) pins , но это отдельные ножки на м/c , никогда не приходилось с ними иметь дело .

PL2303HXD / EA / RA has 8 software controllable “General Purpose Input Output, GPIO” control signals pin, you can use this API to control

— USB Device with PL2303HXD, PL2303EA or PL2303RA controller chip NOTE: PL2303HXA and PL2303XA are not supported (Discontinued Products)

Я смотрел исходники модуля. Он не поддерживает эти GPIO! Только RTS/DTR.

Хм, полез в исходники модуля:

static int pl2303_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) < struct usb_serial_port *port = tty->driver_data; struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; u8 control; int ret; spin_lock_irqsave(&priv->lock, flags); if (set & TIOCM_RTS) priv->line_control |= CONTROL_RTS; if (set & TIOCM_DTR) priv->line_control |= CONTROL_DTR; if (clear & TIOCM_RTS) priv->line_control &= ~CONTROL_RTS; if (clear & TIOCM_DTR) priv->line_control &= ~CONTROL_DTR; control = priv->line_control; spin_unlock_irqrestore(&priv->lock, flags); ret = pl2303_set_control_lines(port, control); if (ret) return usb_translate_errors(ret); return 0; >

Источник

Оцените статью
Adblock
detector