Archive for the 'Tips' Category

02
Oct
08

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.



Del.icio.us Links

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Follow me on Twitter

Blog Stats

  • 1,744 hits

Follow

Get every new post delivered to your Inbox.