LM048: Modem/RS232 Signal Handling

This article explains how LM048/LM058 Serial Adapter handles the RS232 control signals also known as modem signals. This article also covers how to configure your LM048/LM058 Serial Adapter so that the modem signals can be transmitted to the remote end over Bluetooth.

RS232 Interface

Pinout

LM048_modem_signal_handling_pin-outs

Signals

The below table explains the signals on the 9 pin connector of LM048 depending on the slide switch position (DCE to DTE). DTE position is away from the 9 pin connector and DCE position is towards the 9 pin connector.

PinRS232 Signal DTE positionDirection DTE positionRS232 Signal DCE positionDirection DCE position
1 CD (Carried Detect)Not connected on latest version or Connected to pin 9 on some older versionsCD (Carried Detect)Not connected on latest version or Connected to pin 9 on some older versions
2 RxD (Receive)Input
TxD (Transmit)Output
3TxD (Transmit)OutputRxD (Receive)Input
4DTR (Data Terminal Ready)OutputDSR (Data Set Ready)Input
5GND (Ground)N/AGND (Ground)N/A
6DSR (Data Set Ready)InputDTR (Data Terminal Ready)Output
7RTS (Request to Send)OutputCTS (Clear to Send)Input
8CTS (Clear to Send)Input
RTS (Request to Send)Output
9Vcc (Input Voltage)InputVcc (Input Voltage)Input

Setup

This section explains different kinds of set-up which can be done using our adapters in different configurations. Only the RS232 control lines are shown for simplification purpose. In reality TxD RxD lines will always be used and other RS232 signals are either left unconnected or connected to host depending on the selected configuration. A dotted line means wireless connection. The direction of lines (input/output) is shown via arrows.

The different configurations are shown below. The LM048/LM058 adapter can be configured to work in the below modes using AT+MODEM and AT+FLOW commands which is explained in the Modem Signal Settings section below.

DTR DSR Handshaking – No Hardware Flow Control

In this configuration 2 devices are connected using a serial cable. The DTR and DSR lines are interconnected. When a device wants to report an error condition, for example, if a label printer is connected to the PC and wants to report “Out of Paper” error, then the device is assert its DTR line low and the other end will see the DSR go low and hence will come to know that an error has occurred and take necessary action like stop sending data.

The below diagram shows this configuration using a serial cable and pair of adapters.

Connection using a Serial Cable

LM048_modem_signal_handling_1

Connection using a pair of LM048 Adapters

LM048_modem_signal_handling_2

The LM048 adapter transmits the status of DTR pin from one end to the other end and thereby toggling the DSR on the remote end. In this way a pair of LM048 can emulate a DTR DSR handshaking as done by a serial cable connection.

RTS CTS Flow Control – Hardware Flow Control

In this configuration, flow control is handled by the hardware drivers using the RTS/CTS lines. Software has no control over the RTS CTS lines. The flow control situation is not emulated over the Bluetooth link. LM048 supports this flow control in its UART driver.

The below diagram shows this configuration using a serial cable and pair of adapters.

Connection using a Serial Cable

LM048_modem_signal_handling_3

Connection using a pair of LM048 Adapters

In case of adapters the flow control exists only between the adapter and host to which the adapter is connected. The 2 adapters are connected via a Bluetooth connection. To prevent data loss over the air, Bluetooth flow control is used.  If the receiving adapter is unable to receive any more data, it will tell the sending adapter via Bluetooth protocol. The sending adapter will as a result tell its host to stop sending data by asserting its RTS line low.

No RS232 signals are transmitted wirelessly.

LM048_modem_signal_handling_4

RTS CTS and DTR DSR Handshaking – No Flow Control

In this case the hardware flow control is disabled. The status of all the RS232 control lines (RTS, CTS, DTR, DSR) is transmitted wirelessly to the remote side. It is up to the application using this configuration to use the DTR DSR lines or RTS CTS lines for handshaking. This configuration is useful for printers which use RTS CTS lines for handshaking and ignore the DTR DSR lines.

For printers that use DTR DSR lines for handshaking, the configuration is Section  DTR DSR Handshaking – No Hardware Flow Control can be used.

The below diagram shows this configuration using a serial cable and pair of adapters.

Connection using a Serial Cable

LM048_modem_signal_handling_5

Connection using a pair of LM048 Adapters

DTR, DSR, RTS, CTS signal status is transmitted wirelessly to the remote side when the Bluetooth is connected.

LM048_modem_signal_handling_6

Modem Signal Settings Configuration

The LM048/LM058 Serial Adapter can be configured ignore, loop back or transmit status of the RS232 lines. This is done by using the combination of AT+FLOW and AT+MODEM command. For details on the complete command set, See LM048 AT Command Manual

The different combination of AT+FLOW and AT+MODEM and how it affects RS232 Signal Handling is shown in the table below.

Flow Control (AT+FLOW)Modem Signal (AT+MODEM)RS232 SignalsDescription
FLOW-MODEM-Tx, Rx, GND3 wire configuration
FLOW+MODEM-Tx, Rx, GND, RTS, CTSRTS CTS signals are used for data flow control between host and adapter, and NOT transferred to remote side wirelessly.
FLOW-MODEMLTx, Rx, GND, RTS<->CTS, DTR<->DSRRTS looped back to CTS, DTR looped back to DSR
FLOW+MODEMLTx, Rx, GND, RTS, CTS, DTR<->DSRRTS CTS signals used for data flow control between host and adapter, and NOT transferred to remote side wirelessly. DTR looped back to DSR. This configuration is equivalent to LM048 adapter running v4.5x firmware.
FLOW-MODEMRTx, Rx, GND, RTS(R), CTS(R), DTR(R), DSR(R)All 7 signals used. All RS232 control signals (DTR, DSR, RTS and CTS) transferred wirelessly to remote side.If RTS, CTS signals are looped back in hardware, then this configuration is equivalent to LM048 SPA Adapter running v4.6X firmware.
FLOW+MODEMRTx, Rx, GND, RTS, CTS, DTR(R), DSR(R)All 7 lines used. Only DTR, DSR signals transferred wirelessly to remote side.

Difference between RTS/CTS flow control and DTR/DSR handshaking

DTR/DSR lines are mainly used as handshaking signal and also error reporting. However RTS/CTS lines are mostly used for data flow control between the host and device. The below description has been written in context of LM Technologies Serial Adapters.

The description is true in most of the cases but for some applications these descriptions may not hold true. Also the below descriptions may not be true for some other applications where LM Technologies Adapters are not used. Users are advised to use this document as a guide only and also check their own application to see if the below description holds true in their case.

 DTR/DSRRTS/CTS
ConnectionsDTR (Host) <-> DSR (Device)
DSR (Host) <-> DTR (Device)
RTS (Host) <-> CTS (Device)
CTS (Host) <-> RTS (Device)
DirectionDTR: Output
DSR: Input
RTS: Output
CTS: Input
PurposeHandshaking signals – The host asserts to DTR line to tell the device that it is up and running. The host de-asserts its DTR lines in case of any error.[1]Flow Control Signals - If hardware flow control is enabled, the host and the device always check the status on these lines before sending the data. If the CTS line is high only then the data is sent. When the device or host is ready to receive data, it asserts RTS line high.[1]
Driven by?These lines are driven by the firmware in the adapters. The adapter asserts its DTR line as soon as there is an active Bluetooth connection. The DTR line is de-asserted (driven low), when Bluetooth connection drops or there is an error condition on the remote side eg “Power Failure on Remote Host”, “Out of Paper in Printer”.When hardware flow control is enabled, these lines are controlled by hardware. Firmware has no control over these lines. When hardware flow control is disabled, these lines are either not used or used by firmware in the exact way as DTR DSR line depending on the configuration of adapters. The RTS CTS lines are used as DTR DSR line to cover the printers which use RTS CTS lines for handshaking instead of DTR DSR lines
BufferingThere is no buffering when using DTR DSR handshakingThe hardware does buffering when using hardware flow control
ApplicationsPOS, EPOS, PrintersIndustrial, Healthcare, Academic, Vending, Domestic, General Serial Communication