Thursday, August 23, 2012

RS232 - fifty years old!

It was 1962 that the first draft of the RS232 standard for serial communications was published. 
I used to have a good side-line in making null-modem RS232 cables for my colleague who were often confused by why you even need a cross-over cable. The thing to remember about RS232C is that it was only ever intended as a means of connecting dumb terminals (think VT100) to modems.
The EIA RS232C (1969) standard defines two types of equipment:
  • DCE - Data Communicating Equipment; typically a modem.
  • DTE - Data Terminal Equipment; typically a dumb-terminal or PC (in the last thirty years!)
Only one style of connector is defined - the 25-pin D-type (no 9-pins or RJ45s!) and the sex of the connector reflects DTE or DCE (male for DTE, female for DCE) - that's it; everything else is a departure from the standard. So, the original intention was:

terminal <-> modem <- phone or leased line -> modem <-> mainframe

or, put another way:

DTE <-RS232-> DCE <- phone or leased line -> DCE <-RS232-> DTE

And that's it - it wasn't intended for management ports on disk arrays or ethernet switches, just modem/computer connectivity. Once you've grasped that fact you get an understanding of what some of the pins (used to be!) used for and why you need null-modem adapters/cables sometimes.

DTE (P.C.) <-RS232-> null modem cable/adapter <-RS232-> DTE

So it's probably worth looking at the pinouts for RS232, 


There's an awful lot in there! All the signalling lines that allow the modem to tell the terminal that it's picked up the 'phone line and detected a carrier or is getting a ring signal (RI - ring indicator) are all largely historic now, but have to still be paid attention to in some circumstances. What the standard assumes is a 25-core cable, all pins wired pin-pin with a female end at the DTE (to connect to the terminal's male connector) and a male end at the DCE. Notice that the transmit pin on the DTE end connects to the receive pin on the DCE end (Tx - Rx) and vice versa. The same is true of all the handshaking pins (RTS; request to send - CTS; clear to send).
So, if you need to connect a DTE to a DTE (PC to PC or PC to anything else that regards itself as a DTE - has a male connector) you need a cable that does the cross-over for you, a null-modem cable.
At this point it's worth talking about handshaking; if you have a modem talking over a slow line (and in the 1960s that would have been 110 baud; some people can type faster than that!) you need a mechanism of first ensuring the link is up (DSR; Data Set Ready and DTR; Data Terminal Ready) and then the flow of data is controlled (RTS; Ready to Send, CTS; Clear to Send). BUT, spin forward thirty years and you're using RS232 for PC-PC or other management functionality and the flow control needs to be either 'spoofed' by the cross-over cable OR it's probably being done by the software using one of several RS232 flow-control protocols. The most common if these is XON/XOFF and uses two special character to pause and resume transmission;

If you look in your Windows device manager for a port's settings you can see;


 So with all this in mind here are the pinouts for a null-modem cable; in fact there are two you can make - a three-wire (use a piece of FST - useful if all you've got is an audio tieline!) or a six-wire (which takes the hardware handshaking pins through) - send it down a cat5 line! In the case of the three-wire the handshaking lines are looped back on their equivalents at each end so that hardware flow control never stops the link.
So the final thing is probably to give the pinouts for a 9-pin -> 9-pin (which would by definition be female to female) null modem cable for RS232C DTE-DTE cable;

No comments: