For the uninitiated: Framework 2.0 nowadays sports genuine Serialport communication (via an extra class/component called SerialPort) [MSDN link]. The class supports both blocking and non-blocking forms of communication.
A good way to test serial port communication (without the need of plugging hardware to your serial port, that is if you have one1) is by using a virtual serial port driver. A fairly good one is the (open-sourced) com0com driver, which you can find around this area. If you’re not used to poking around the registry, here a brief outline of how to install the driver under Windows XP (tested on both Home/Professional editions):
- Download the driver (you can also download the sources if you wish)
- Unzip the driver to the folder.
- Launch the ‘Add Hardware wizard’.
- ‘Have you already connected your bla-bla’ – Yes, Next.
- From the installed hardware list, scroll down and select ‘Add a new hardware device’.
- ‘Install the hardware that I manually select from a list’.
- ‘Select all devices’ (this takes a while)
- ‘Select Standard port types’ – ‘Communications Port’.
- Select ‘Have Disk’, go to folder and select the com0com.inf file.
- At this stage Windows will add to try 2 extra com ports CNCA0 and CNCB0. It will ask to install the hardware. FOLLOW THE INSTRUCTIONS AND DON’T PRESS CANCEL. Remember, two ports are supposed to be added.
- When done, it’s time to rename the ports. C# doesn’t like silly names for COM ports, so check your hardware list and find out which port numbers are still available. Add these ports to the registry (as described in the readme file). We at xsamplex made it easier for you, of course. You can copy and paste the following fragment to a file (save with .reg extension). Once again, choose the portnumber of your liking:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Services\\com0com\\Parameters] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Services\\com0com\\Parameters\\CNCA0] "PortName"="COM5" [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Services\\com0com\\Parameters\\CNCB0] "PortName"="COM6"
(Note: Remove extra line breaks after CurrentControlSet key)
- Restart your computer.
- Do a test using two Hyperterminals: connect one to COM 5 and the other to COM 6.
And that’s it!
1 Most laptops might not even come with a serial com port…