Windows Serial Console Programing

  1. Windows Serial Console Programming Download

Environment:This article is meant to give you a jump start on doing serial communication in Windows (NT family). The article will provide a class called CSerialCommHelper that you can use directly to do serial communication in your application. The class that is provided here with this article does uses overlapped IO. You do not need to know much about serial communication or overlapped IO for this article. However, you need to know some about the synchronization objects such as Events and some Windows APIs like WaitForSingleObject and WaitForMultipleObject, and so forth. Also, some basic understanding of Windows threads is required—such as thread creation and termination.

ConsoleWindows serial console programming download

Windows Serial Console Programming Download

Yes, essentially you open a serial port device with a special name, such as COM1, and read and write to it much as you would a file. The pins used will (naturally) be the serial transmit and receive pins.If you want to control specific pins but not necessarily in a serial way, you might be better off working with a parallel port instead. The parallel port voltages are usually more friendly to TTL level logic and can often be driven directly.Update: If you just need to toggle one pin as per your comment, you may be able to use the DTR line for this. See the function documentation for how to do this. @user318811: Greg's right: for anything like this, you almost certainly want to use the parallel port. The pins on the serial port are driven almost entirely by the UART, and it does so mostly under a clock, so it's generally impossible to hold a line in a given state for longer than a given period of time (basically, the time to transmit one byte at whatever speed you pick). You can slow the serial port down (e.g., to 300 baud) to get it to hold a state longer, but that will also limit the maximum transition rate (e.g., to 300/second).–Mar 26 '11 at 4:16.