Crate rs485 [] [src]

RS485 support for serial devices

RS485 is a low-level specification for data transfer. While the spec only defines electrical parameter and very little else, in reality it is most often used for serial data transfers.

To realize an RS485 connection, a machine's UARTs are usually used. These support sending and receiving, each through a dedicated pin for RX (receive) and TX (transmit). RS232 can be directly connected this way to allow full duplex (simultaneous send and receive) connections.

RS485 differs from RS232 in an important aspect: Instead of dedicating a single line to send and another one to receive, two wires each are used to transport a differential signal. In combination with higher voltage levels and twisted-pair cabling, this allows for much more reliable transmission results.

A working full-duplex RS485 connection requires a transceiver chip and four wires, two for RX and TX. To reduce the number of wires back down to two, a suitable protocol can be used to establish a bi-directional half-duplex connection. Commonly, a "master" device will turn on its line driver, send a request, turn it back off and wait for a reply.

Most transceivers have a pins dedicated to turning the linw driver on and off. Being able to turn the driver on just before sending and back off after the transmission is complete is a requirement for implementing these protocols.

Often a UART's RTS (request-to-send) pin is connected in a way that makes the transceiver enable the line driver when RTS is on but the receiver instead when RTS off. Since this functionality is common, kernel serial drivers usually support turning RTS on/off. This crate allows configuring that functionality, provided it is setup correctly.

When running into issues with RS485, verify that the RTS pin of your UART is actually connected to the transceiver, properly pinmuxed (if necessary) and that the UART itself is enabled.

Structs

Rs485Flags
SerialRs485

RS485 serial configuration

Constants

SER_RS485_ENABLED
SER_RS485_RTS_AFTER_SEND
SER_RS485_RTS_ON_SEND
SER_RS485_RX_DURING_TX

Traits

Rs485

Rs485 controls