1 unstable release

Uses old Rust 2015

0.1.0 Jun 30, 2017

#3 in #rts

Download history 48/week @ 2023-12-18 24/week @ 2023-12-25 68/week @ 2024-01-01 70/week @ 2024-01-08 48/week @ 2024-01-15 72/week @ 2024-01-22 87/week @ 2024-01-29 56/week @ 2024-02-05 166/week @ 2024-02-12 132/week @ 2024-02-19 186/week @ 2024-02-26 155/week @ 2024-03-04 222/week @ 2024-03-11 162/week @ 2024-03-18 156/week @ 2024-03-25 136/week @ 2024-04-01

688 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