Previous Section  < Day Day Up >  Next Section

Hack 77 Break the Rules with COM Ports

figs/moderate.gif figs/hack77.gif

Allow more than two COM ports to work simultaneously without conflicts.

We don't seem to use COM ports very much these days, but even new USB-connected devices emulate the tried-and-true methods of serial communications in today's technology. The plain old serial port is still imperative for communicating with most of the devices that make the Internet possible: modems, routers, switches, and headless servers.

In the design of the original PC, IBM created a deliberate conflict between COM ports that has never been resolved through any change of standards or design. The conflict is the IRQ assignments for COM1 and COM3, which both use IRQ4, and COM2 and COM4, which both use COM3. Apparently IBM never thought anyone would want to use more than two COM ports at the same time: you cannot use COM1 and COM3 at the same time, nor COM2 and COM4 at the same time.

This conflict came to light as early online pioneers started running bulletin board systems with multiple modems to allow multiple users access at the same time. Early communications software relied on the system BIOS for many hardware I/O functions, and serial communications was one of them. The BIOS, of course, was hard-coded to adhere to strict rules, and COM port configuration and IRQs were encompassed by them.

As time passed, developers determined the BIOS functions were not the only or best way to get the hardware to do what they wanted. Flexibility in software and hardware configurations came about to the advantage of users. They could work around the limitations of the BIOS by addressing system hardware directly, which worked well if it was certain that other hardware and software were not going to get in the way.

The first thing that got in the way of expanding the communications capabilities of the PC was the COM-port IRQ conflict. The conflict could only be resolved through some clever hacking of software and hardware to make things work. Software programmers had to know and provide for the many different addresses and IRQs that were likely to be available in the PC, and hardware makers or technically inclined users had to know how to get the hardware configured to their advantage.

Since the source of conflict with using multiple COM ports at the same time is the lack of a unique IRQ for each port, you need to scrounge for two more IRQ lines to give the COM3 and COM4 ports their own IRQs.

Even if you are not going to physically plug in additional COM ports, you may have to reconfigure the virtual COM ports created by USB-to-serial adapters and ensure that each has a nonconflicting setting to work with. See the steps at the end of this hack to make COM port settings changes.


Recovering an unused IRQ or two from one or more LPT ports [Hack #76] can be a rather fortunate coincidence. You can usually repurpose IRQ7 for one of the four COM ports. You may be able to repurpose IRQ5 as well, if a sound card or another device has not laid claim to it. With only IRQ 5, 9, 10, and 11 to choose from, you face another dilemma; most serial/COM port add-in cards use the 8-bit ISA bus form factor and thus lack any electrical connection or access to IRQs 8-15. This forces you to use IRQ5 for the fourth COM port expansion, which forces you to use a 16-bit ISA or a PCI-bus sound card.

Once you have determined that IRQs 5 and 7 are the only ones suitable and available to an 8-bit ISA serial/COM port expansion board, buy an expansion board that has jumpers or switches you can use to select these alternate IRQs, like the one shown in Figure 8-2.

Figure 8-2. A new COM port card with jumpers to set optional IRQs
figs/pchk_0802.gif


The card shown in Figure 8-2 is available from Startech.com as part number ISA2S550 and provides an extended connection into a 16-bit ISA slot to pick up IRQs 9, 10, 11, 12, and 15. Startech also offers PCI-based serial I/O and many other hard-to-find cards for many different types of PC expansion.

It is often suggested that using a USB-to-serial adapter is the way to solve COM port limitations and avoid IRQ constraints. However, USB adapters create virtual COM ports, which must in turn emulate real COM ports, up to and including using their hardware addresses and IRQ signals.

Additionally, many USB drivers create these virtual COM ports with nonstandard COM port numbers (anywhere from COM5 and much higher), which are not traditional port numbers and may not be recognized by the programs you use to communicate with a COM-port-connected device.

In a worst-case scenario, the USB-to-serial adapters, like those offered for handheld-to-PC synchronization, are known to change the COM port number they assign to themselves between reboots, leaving you to have to reconfigure the adapter or your applications to find the new randomly assigned port. Sometimes you need a real and stable COM port to get your work done.


Follow these steps to reconfigure address or IRQ settings in Windows to match the actual COM port device you are using—a physical port or a virtual one such as a USB-to-serial adapter:

  1. Right-click My Computer and select Properties.

  2. Select the Hardware tab, then click the Device Manager button.

  3. In Device Manager click on the plus (+) sign to the left of Ports (COM & LPT).

  4. Right-click the COM port entry and then select Properties.

  5. Select the Resources tab.

  6. Unselect the "Use automatic settings" checkbox.

  7. Double-click either I/O Range or IRQ to make changes to these values, then click OK.

  8. Select the Port Settings tab, then click the Advanced button to access the COM Port Number setting if you need to change the logical port number to suit the software you are using.

  9. Click OK to exit the dialogs, restart your PC, and your port is ready to go.

    Previous Section  < Day Day Up >  Next Section