Thursday, October 2, 2008

Serial Communication

To start things of, I need a C++ library that enables me to establish a serial communication between the computer COM port to an external device. Since I am going to be doing some windows programming, I will need to write a wrapper over the Win32 API functions that enable me to communicate serially.

In Windows, I can not access hardware COM ports directly, this access has been restricted because a lot of guys have used this to write viruses. COM Ports are now viewed as regular Files, and the same functions that open, read, write into files also work with COM ports.

In order to test this library I need to build myself a RS232 Loopback connector, which is essentially a regular DB9 RS232 connector with the transmit and receive lines interconnected. Here is a picture depicting the specific lines and necessary connections that have to be made.




I used a couple of wires to make the connection. I tested the functionality of my connector with Hyper Terminal from Windows, hooked up the connector to a spare serial male connector of my PC (usually COM1) opened a connection in Hyper Terminal with COM1 and started typing random characters. These characters were showing in my window as received data into COM1. So it was working, the data I was sending through COM1 was being received and displayed on the screen.

2 comments:

Mihai said...

Here is a good paper on serial communication.

www.beyondlogic.org/serial/serial.pdf

Hope this help. Cheers!

Ovidiu said...

Thanks. It will prove helpful when I write my paper for my diploma project. The library I have written about in the post is almost complete, I am reluctant to post any code here because I may use this project for my diploma.