Home > Code Dump > OPEN COM QuickBasic DTR Fix

OPEN COM QuickBasic DTR Fix

Avoid that annoying DTR check when opening a COM port
By 28/12/10 [Last Edited by Joseph 29/12/10]
BOOKMARK
LOGIN
REGISTER
Maybe it was the hardware I was using, but I could never seem to open a COM port through QuickBasic 4.5 for MS-DOS (an error was thrown) unless the DTR (Data Terminal Ready) pin was high. This wasn't always very practical, especially when interfacing my multimeter which used just three of the pins (RxD, TxD, GND). I experimented and found a nice little way to directly communicate with the serial port control register, and trick it into thinking DTR was high!

OUT &H3FC, 9

Change &H3FC with the hexadecimal base address of the COM port you wish to manipulate. In this example, I am targeting COM1 on my machine.

Important Note

This method will probably render your software inoperable under Windows NT, as direct hardware calls cannot be made from within NTVDM.