Serial Over RJ-45
From Devpit
RJ-45 plugs with 8-conductor flat satin cabling are usually more convenient than the bulky DE-9 connectors found on most equipment. There are many ways to wire a DB-9 to RJ-45 adapter. Obviously any wiring will work for a straight-through cable. Since a serial port uses nine wires and an RJ-45 plug only has eight conductors, at least one wire must be dropped. Nearly everyone agrees that the Ring Indicator (RI) signal is pointless and the first connection to drop, since almost no equipment uses it. Even modem communication software typically watches the RX line for the string "RING" and ignores RI.
It makes life much easier to minimize the number of different wirings used for the various serial applications. The most common applications are a simple straight-through cable, a null-modem cable, and cables where not all eight pins are available. A four-pin cable may be useful, for example, when running two serial consoles to another room using a single cat-5 cable by splitting the cable in half. These wirings make it easy to create a null-modem wiring by simply crimping the RJ-45 plug on backwords on one end of the flat satin cable. (Here, this is called a cross-over cable, not to be confused with an Ethernet cross-over cable.)
Most signals are paired. For example, TX with RX, RTS with CTS, and DTR with DSR. Problematic signals are GND, CD, and RI, because when using a cross-over cable, these don't have a simple opposite pin on the other end. Since RI is almost never used, it's simply dropped. The others are addressed differently depending on the wiring scheme.
To simplify things, wire all the female connectors with the DTE wiring and all the male connectors with the DCE wiring (the DCE wiring is simply the cross-over wiring). Use the cross-over wiring for all the cables. This creates the null-modem wiring when connecting two DTE devices (such as two computers) and the straight-through wiring connecting a DTE device to a DCE evice (such as a computer to a modem) because the male connectors undo the cross-over effect of the cable. This is convenient because nearly all of the cables and connectors can be wired the same way.
The exceptions are, of course, devices which require a non-standard wiring, such as a wiring for APC UPSs. These devices will always need a specially wired adapter. Ideally, the special wiring should always be in the adapter connected to the special device so the adapters don't get mixed up. For APC UPSs with a male DE-9 connector, make a special DE-9 to RJ-45 adapter. For UPSs with a RJ-45 connector, wire the RJ-45 on the UPS side differently. (A Cat-3 or equivalent cable may be required to do the honors, since flat satin is hard to use for special wirings. At least this will make the cable stand out as different.) Also, always label cables and adapters that have special wiring.
Contents |
Wirings
| Name | DE-9 | DB-25 | RJ-45 - Leif (DTE) | RJ-45 - Leif (DCE) | RJ-45 - Yost (DTE) | RJ-45 - Yost (DCE) | |
|---|---|---|---|---|---|---|---|
| TX | 3 | 2 | 4 (red) | 5 (green) | 3 (black) | 6 (yellow) | |
| RX | 2 | 3 | 5 (green) | 4 (red) | 6 (yellow) | 3 (black) | |
| RTS | 7 | 4 | 3 (black) | 6 (yellow) | 1 (blue) | 8 (white) | |
| CTS | 8 | 5 | 6 (yellow) | 3 (black) | 8 (white) | 1 (blue) | |
| DTR | 4 | 20 | 2 (orange) + 1 (blue) | 7 (brown) | 2 (orange) | 7 (brown) | |
| DSR | 6 | 6 | 7 (brown) | 2 (orange) | 7 (brown) | 2 (orange) | |
| CD | 1 | 8 | 8 (white) | 1 (blue) | 7 (brown) | NC | |
| RI | 9 | 22 | NC | NC | NC | NC | |
| GND | 5 | 7 | Shield | Shield | 4 (red) + 5 (green) | 4 (red) + 5 (green) |
DTE wiring should be used for female connectors (the computer side). DCE wiring should be used for male connectors (the modem side).
Remember, all connections use a cross-over cable, so connecting a DTE wiring to a DCE, for example, connects pin 1 DTE to pin 8 DCE.
RJ-45 - Leif
This wiring connects DTR to both pins 2 and 1. This way when using cross-over wiring, it will cross DTR over to both 7 (DSR) and 8 (CD), but when using straight-through wiring, DSR and CD will not be shorted. The pin order was chosen with the most important signals towards the center, to maximize the utility of 2-pin, 4-pin, and 6-pin connectors. For no practical reason, lines controlled by the DTE are grouped as 1-4, and lines controlled by the DCE are grouped as 5-8. This uses either a floating ground or a ground tied to the shield, which can cause problems with some devices. Wiring the ground pin to the device's shield should cause fewer problems than a floating ground, as long as the devices share a common earth ground in the building's AC wiring.
Notice the subtle difference in the DCE wiring, which does not connect pin 8. This is because DSR and CD are both generated by the DCE equipment. When connecting two DCE devices, shorting pins 7 and 8 would short DSR and CD, rendering both signals undefined. Leaving pin 8 unconnected simply disconnects CD when connecting two DCE devices, which is appropriate. This only affects connecting two DCE devices, which is uncommon. When connecting a DTE device to a DCE device (with the usual cross-over cable), the result is straight-through wiring on all pins (except GND and RI).
RJ-45 - Yost
This wiring is very careful to ensure correct grounding. Two ground pins are used so that the cross-over cables connect the ground wire correctly. This is done at the expense of a distinct CD signal. CD is always shorted with DSR to save a pin, but this will usually cause problems communicating with dial-in modems because most software expects the CD signal to be high only when a call is in progress.
CD is very nice for a Unix TTY on a dial-in line, because getty will simply wait for CD to switch high to display a login prompt, and if the user unexpectedly disconnects, CD will switch low causing the session to terminate. Without this, there is a potential security hole: if a user unexpectedly disconnects, his session will remain open and the next caller may connect to it.
Notice the subtle difference in the DCE wiring, which does not short DSR and CD. This is because DSR and CD are generated by the DCE equipment, so shorting them would cause the DSR signal to be undefined. Yost's wiring is not the best option when DCE equipment is involved because CD cannot be connected, but if it is used, do not short these signals on the DCE side (in the male adapters).
Related Hardware
- The USB-16COM-RM is a nice USB-based device based on the FT2232C chip that provides 16 serial ports for under $400. It works in FreeBSD 6.1 with the uftdi driver. (Remember to load the module; as of 6.1, FreeBSD can't load it automatically for this device yet.) It probes as two USB hubs and eight FTDI serial adaptors, each of which provides two serial ports.
- RJ45 Adaptor supplies from Jameco:

