Data Carrier Detect
, abbreviated as DCD
, or alternately Carrier Detect
abbreviated as CD
, is a control signal present inside an RS-232
In telecommunications, RS-232 is the traditional name for a series of standards for serial binary single-ended data and control signals connecting between a DTE and a DCE . It is commonly used in computer serial ports...
serial communications cable that goes between a computer and another device, such as a modem. This signal is a simple "high/low" status bit
A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...
that is sent "from DCE to DTE", or in a typical scenario, from the peripheral to the computer. It is present on virtually all PC serial ports - pin 1 of a nine-pin (DE9) serial port, or pin 8 over a 25-pin (DB25) port. Its purpose varies depending on the device connected, but the most typical meaning is to indicate when a modem is connected to another remote modem via telephone lines.
The word "carrier" is a reference to the analog carrier
In telecommunications, a carrier wave or carrier is a waveform that is modulated with an input signal for the purpose of conveying information. This carrier wave is usually a much higher frequency than the input signal...
signal generated by a modem, which is modulated
In electronics and telecommunications, modulation is the process of varying one or more properties of a high-frequency periodic waveform, called the carrier signal, with a modulating signal which typically contains information to be transmitted...
to carry the data. On a data modem, loss of the carrier equates to termination of the connection.
Much like the Ring Indicator
Ring Indicator, abbreviated as RI, is a control signal that is used in RS-232 serial communications cables between a computer and a modem. The signal is sent from the modem to the computer, typically over pin 9 of a nine-pin serial port, or pin 22 of a 25-pin serial port...
signal, on a PC's serial port, changes to the DCD signal state generate a hardware interrupt that can be captured by the processor any time the DCD signal changes state, preventing the PC from needing to constantly poll the pin.
Although DCD is a one-way signal from the device to the computer, the DTR (Data Terminal Ready
Data Terminal Ready, abbreviated as DTR, is a control signal present inside an RS-232 serial communications cable that goes between a computer and another device, such as a modem...
) is the corresponding line that carries the same status from the computer back to the device, when applicable.
As used on modems
DCD is very important on modems, as it is the computer's primary way to find out that the modem has lost its connection to the remote host. Aside from intentional disconnects, modems can lose their connection for a variety of reasons unexpectedly - such as the phone line being disconnected. It is possible to use a modem without the DCD signal, however the only way for the computer to know that a connection is disconnected is by the modem transmitting the words "NO CARRIER" over the data lines. Because the words "NO CARRIER" are also a message that could appear in the context of a normal data session (for example, if typed by a person on the remote end), there is no positive way for a computer program to differentiate the words being sent over the connection versus from the modem.
External modems with LED status lights usually have a light labeled "CD" (carrier detect
). This status light is directly coupled with what the modem is sending the DCD line.
By default, when a modem is powered up, the DCD signal stays low. It does not go high until the modem either makes an outgoing call, or answers an incoming call, and then connects with a data modem on the other end. The signal goes high at the same time the modem reports its CONNECT message, and stays high until the call is disconnected. The signal goes low again once the local modem has lost contact with the remote modem, regardless of which side initiated the disconnect. So long as the DCD signal is high, the computer can assume that any data coming from the modem was actually sent from the remote side.
DCD configurability on modems
Virtually all newer modems have a built-in capability of modifying what they do with RS-232 signals, depending on the application. The AT command for manipulating DCD is typically
followed by a single digit. More frequently, the setting is buried in a longer initialization string - such as
. Note that per the specifications
The Hayes command set is a specific command-language originally developed for the Hayes Smartmodem 300 baud modem in 1981. The command set consists of a series of short text strings which combine together to produce complete commands for operations such as dialing, hanging up, and changing the...
, AT commands can be concatenated
In computer programming, string concatenation is the operation of joining two character strings end-to-end. For example, the strings "snow" and "ball" may be concatenated to give "snowball"...
together by only specifying the characters "AT" once, followed by all the remaining commands strung together.
AT&C0 - Always assert DCD : This command tells a modem that it should always hold DCD high, regardless of the connection state. This takes away the ability for the host to positively detect a loss of connection. But in some cases it can be useful - such as when using a pre-configured modem to automatically answer and provide remote access to some equipment that wasn't meant to be connected to a modem. In that case, that equipment may require a "high" signal at all times for the communication setup to function. An external modem that has been configured with AT&C0 will have its CD light on at all times - even when not connected to a remote modem - to reflect the asserted DCD pin.
AT&C1 (default for nearly all modems) - Assert DCD only when connected : This sets the modem to behave normally, with DCD high only when connected to a host.
AT&C2 (supported by most but not all modems) - Always assert DCD with disconnect signalling : The modem asserts DCD whenever it is powered on, except
immediately after sensing a disconnect. Upon sensing a disconnect, the DCD line goes low for a brief time (typically 1–2 seconds), and then returns high. Support can easily be determined by attempting the command, and noting the modem's response (ERROR versus OK).
The meaning of DCD differs when the modem is in fax
Fax , sometimes called telecopying, is the telephonic transmission of scanned printed material , normally to a telephone number connected to a printer or other output device...
or voice modes. In these modes, its importance is diminished. The fax and voice protocols provide for a data link escape (DLE) character in the data stream that permits the computer to differentiate between reports from the modem and data from the remote side. In those cases, if the remote side sends a byte matching the DLE byte, the modem sends it to the host PC twice in a row to signal that it came from remote. During fax and voice transmission, flow control (such as over RTS/CTS pair) is much more important than the DTR/DCD signal.
As used with null modems
A frequent use of a serial port is for a direct computer-to-computer connection. This requires an adapter called a null modem
Null modem is a communication method to connect two DTEs directly using an RS-232 serial cable. The name stems from the historical use of the RS-232 cable to connect two teleprinter devices to modems in order to communicate with one another; null modem communication was possible by instead using...
, which isn't actually a modem in the traditional sense, but rather a connector plug that simply crosses the complementary pins on two serial ports so the two sides can communicate. A null modem connects the DTR output of each computer to the DCD input of the other.
When used in this scenario, DCD is used to simply detect the presence and/or readiness of the other side to start a session. For example, on PC's running Windows, the DTR output is kept low until some program is run to access the serial port and raise the DTR signal high. The remote side will sense this as the DCD input going high. Some equipment will recognize the transition alone as the beginning of a session. Other equipment (such as the console port of a router) may expect characters to be transmitted, but the DCD signal high is still a prerequisite for every communication.
As used with other hardware
Not very much hardware, beyond modems and direct serial communication links, uses the DCD signal. Serial mice do not use it, neither do serial printers
In computing, a printer is a peripheral which produces a text or graphics of documents stored in electronic form, usually on physical print media such as paper or transparencies. Many printers are primarily used as local peripherals, and are attached by a printer cable or, in most new printers, a...
Sometimes a computer is connected to a device that doesn't provide a DCD signal at all. If the computer software requires a DCD signal to properly recognize a connection, then this is mitigated simply by connecting a wire between the computer's own DTR and DCD pins, so the computer sees the high DCD signal it needs. Since DTR and DCD are typically used as a pair, any computer program requiring DCD high is likely to also provide a high DTR as output.
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
, each serial port is referenced by two device names - one being (for the first serial port)
. Although these both refer to the same physical port, one important distinction between the way Linux treats these two device names has to do with the DCD line. When ttyS0 is waited on in a system call
In computing, a system call is how a program requests a service from an operating system's kernel. This may include hardware related services , creating and executing new processes, and communicating with integral kernel services...
, Linux assumes that since this device is for receiving telephone calls, it will put a process
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...
A computer program may sleep, which places it into an inactive state for a period of time. Eventually the expiration of an interval timer, or the receipt of a signal or interrupt causes the program to resume execution.- Usage :...
— figuring that so long as DCD is low, there is nothing to do. When cua0 is used - as it is when placing telephone calls - Linux assumes that the software needs to access the port while DCD is low for the purpose of dialing the number, so this blocking
Blocking occurs when a subroutine does not return until it either completes its task or fails with an error or exception. A process that is blocked is one that waits for some event, such as a resource becoming available or the completion of an I/O operation.In a multitasking computer system,...
behavior doesn't exist. Nevertheless, there is a control mode flag
In computer programming, flag can refer to one or more bits that are used to store a binary value or code that has an assigned meaning, but can refer to uses of other data types...
called CLOCAL that is what actually activates or deactivates this behavior, and by default the flag is set for cua0 but not for ttyS0. An application that insists on using a "tty" port versus a "cua" port is an example of one that might require a jumper
In electronics and particularly computing, a jumper is a short length of conductor used to close a break in or bypass part of an electrical circuit...
wire to force DCD high in order to work properly.