1 unstable release

Uses old Rust 2015

0.1.0 Jun 30, 2017

#7 in #rts

Download history 174/week @ 2024-03-14 141/week @ 2024-03-21 131/week @ 2024-03-28 107/week @ 2024-04-04 146/week @ 2024-04-11 147/week @ 2024-04-18 83/week @ 2024-04-25 69/week @ 2024-05-02 57/week @ 2024-05-09 145/week @ 2024-05-16 69/week @ 2024-05-23 231/week @ 2024-05-30 86/week @ 2024-06-06 83/week @ 2024-06-13 86/week @ 2024-06-20 74/week @ 2024-06-27

391 downloads per month
Used in profirust

MIT license

9KB
113 lines

Rust/Linux RS485 controls

Controls the RS485 functionality (automatic RTS to enabled/disable drivers on transceivers) on Linux serial ports. Integrates well with serial-rs.

Check the documentation for details.


lib.rs:

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.

Dependencies

~185KB