RS485 Emulator

Overview

The development of protocols for embedded systems that are based on shared buses (e.g. RS485), it's not always easy to implement and validate when implemented directly on the target system, which often lacks high-level debug capabilities.

This project aims to create an emulator/server that runs inside a linux/unix environment. It emulates the behaviors observed on shared buses, for example collision of data, echo, noise and lost information.

Description

The following figure describes an overview of the functionality.

Both the client and the server are linux processes. The server emulates the functionality of the shared RS485 bus. The client emulates the embedded nodes connected to the bus.

The target embedded nodes usually use their internal UART (Universal Asynchronous Receiver/Transmitter) to send and receive serial data on the bus and uses a RS-485 transceiver to send and receive data on the bus with RS-485 levels.

Since the RS-485 is used normally in a shared bus then the transmitted data is received in all nodes, including the one making the transmission. Some HW implementations block the reception data during transmission. That will not allow the transmitter to detect collisions in the case other node starts transmitting at the same time.

The UART can only report that a new byte is received after that byte is fully transmitted. This implies that there is always one byte latency between transmission and reception of the data, even on the transmitter. In addition this also implies that implementations that are based only on UART information to detect when the bus is idle have a potential collision interval equal to the byte transmission period.

The RS485 emulator implements this two "characteristics" of a RS485 bus:

  • Latency equal to one byte period;
  • Collision of information if more than one client starts transmitting with less than one byte period of time difference

The usage instructions of the server are the following:

./rs485 -p <port> -b <baud rate>

<port>      - TCP port for connections
<byte rate> - Number of byte to transfer per second

The server accepts connections at the specified TCP "port" from multiple clients and uses the "byte rate" to determine the collision interval size.

Files and download

The source code, files, tickets, support and blog of this project can be found on SourceForge in the following link:

https://sourceforge.net/projects/rs485emulator/

-- PedroMaiaAlves - 2015-07-14

Topic revision: r1 - 2015-07-14 - PedroMaiaAlves
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback