.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

.NET Serial/COM Port Communication over Terminal Services

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :.NET Framework


I hope I'll be able to clearly formulate my question.

Scenario: we have an application that integrates with several type of scanners (i.e. credit card, barcode, passport) using serial port interface.
It's the desktop application and can be deployed to run either in stand-alone environment or can be published over terminal services layer (citrix, TS, etc).
In the preferences of the application users are able to specify which scanner is assigned to which COM port.
For example: bar code scanner = COM1, credit card scanner = COM5.
To a user, names of the COM ports don't really make much sense and they won't know that the bar code scanner needs to be assigned to COM1 unless they go to Device Manager and look up the device name associated with the COM port under Ports (COM & LPT) section.

SerialPort class in .NET Framework has the function GetPortNames that returns the list of available COM ports: COM1, COM3, COM5, COM6, etc.
After doing a little research I found a way to get the descriptive names of each COM port device using WMI.

Here is the code for this:

  Public Shared Function GetAvailableSerialPorts(

View Complete Post

More Related Resource Links

Serial Port Communication Read and Write using C#.net

In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
using System.IO.Ports

Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

Robotics: Writing and Testing VPL Services for Serial Communication


VPL, part of Robotics Developer Studio is intended for novice programmers, but is also useful for testing and prototyping. We write a simple serial port service that allows you to send and receive data.

Trevor Taylor

MSDN Magazine February 2010

Serial Port with portable data terminal

Hi,I am making application with portable data terminal which connected to serial port. User will go with portable data terminal and scan data with it than we will connect it to PC and read all the data from it. Kindly somebody help me how to do that.Thanx

Serial Communication with the .NET Compact Framework

Learn how to make your applications communicate over a serial port and how to handle common issues when implementing serial solutions. After a general discussion about serial communication and a common serial communication standard, this article demonstrates a practical use of the technologies through sample source code written in C#.

bluetooth print via serial port PDA

Print via BlueTooth using PDA

Foundations: Workflow Services for Local Communication


This month's column describes how to use WCF for communication between a workflow and a host application in Windows Workflow Foundation 3. This knowledge should help developers with their efforts using WF3 and prepare them for WF4, where WCF is the only abstraction over queues (referred to as "bookmarks" in WF4) that ships with the framework.

Matthew Milner

MSDN Magazine November 2009

Contract-First Web Services: Schema-based Development with Windows Communication Foundation


Schema- first contract-first modeling of Web Services gives you the ability to model your contracts with an XML-centric mindset. This process keeps you focused on universally acceptable types and the hierarchical data structures that can be represented in XML.

Christian Weyer, Buddhike de Silva

MSDN Magazine October 2009

How to wait for a Serial Port to respond

Hi Is it to possible to wait for a serialPort component to complete it's response?  I have a device connected to the serial port of my PC. I use the serialPort component in order to communicate with the device. I have to send 2 different strings of data to the serial port but the trick is that after sending the first string of data I have to wait for the serial port to respond. Then I have to check the response and decide whether I must send the second string or not. Also after sending the second string, I have to check also the response of the serial port. I tried to use an arbitrary amount of wait time between the sending of the two strings. Something like SerialPort.Write(...) ; Thread.Sleep(2000); SerialPort.Write(...); But the software failed when I tried it in a slower PC. So is there a way to replace the Thread.Sleep(2000) with a command that will wait until the serial port complete its response? Although, the response of the serial port is different between the two sending strings, I do know that the first response is only one byte and I know the ending byte of the second response. Also, the second response is no more than 30 bytes in length. Regards Dimitris

DataReceived event not triggered in vb.Net until serial port is closed & opened again

I am developing an application which sends multiple AT commands to a modem in VB.Net. After writing an AT command to the modem, I see the dataReceived event is not getting triggered until I close the port & open it again & write the next AT command. This behavior is consistent. As soon as I write the next AT command the response of previous AT command is read. Even adding a delay between the two write operations does not work. I also added a readData between the two writes so that data is read if it exist in buffer or stream but is not triggering datareceived event because bytestoread is non-zero, but that does not hep too. Because of insufficient read operations the data in readbuffer grows(accumulating) & after sometime the modem stops receiving the AT commands. Please suggest a solution code for data received handler & read data function   While comPort.BytesToRead > 0     Dim msgCharArray(255) As Char       If comPort.BytesToRead >= 256 Then     comPort.Read(msgCharArray, 0, 256)   Else    comPort.Read(msgCharArray, 0, comPort.BytesToRead)   End If   End While

Serial Port Conflict

Hi.... I have an issue related to serial port opening. when i run my software it gives me an error "serial port does not exit or already opened". I have two questions. 1.can i check which program is using com port. And how can i close serial port that is already being used.Using Windows7  

Full duplex pc to half duplex serial communication with SerialPort class in C++ (but any language wi


Hello.  I am a bit new to the .NET environment, and though I feel I was able to get a good handle on most of the basics of .NET, I believe I've encountered a problem beyond the basics.  I am trying to talk with a device called a ColorPAL that uses asynchronous serial communication, but it is half-duplex instead of full-duplex.  I am able to send it the hex string commands that it wants just fine with the TX line.  However, I find myself unable to read because the RX isn't connected to anything.  Basically what I want to do is that I want to be able to swap the TX line to become a RX line so that I can then read line of the half-duplex.  I read that there is a PinChanged event, so it lead me to believe there is a way to change pins??   If the RX line is very high impedance I could connect it to the TX line, but I have no idea about that.


How can I get a full duplex to read a half-duplex using the visual studio software?


Here is the code I'm using, in case that helps.

#include "stdafx.h"
#include <Windows.h>

using namespace System;
using namespace 

Getting the name of the process that is using a serial port or file


Sometimes it happens that opening one file or serial port fails because it is used by another process.

Is there a way to get the name of the process that is using it ? 

Thank you

Serial Port plug/unplug detection with callback


Is there a way to register a callback or delegate that gets invoked by the system every time a new virtual COM port is connected to a USB interface ?

This function would be very useful to keep serial port enumeration up to date without polling.

Thank you



I have implemented a Windows Server 2008 running Terminal Services.  I have successfully set up 5 clients to log on to the terminal server.  Everything on those clients seems to work fine.

I just set up a new computer at the same remote location as the other clients.  The new client is able to do everything except print locally.  The new client is running Vista Business (sp1 I think).  The local printer is an HP Laser Jet M1120MFP printer.  When logged on to a TS session, the M1120 shows up as a redirected printer as I would expect.  When I try to print to it while in the TS session, however, it does not print.  Printing a a Notepad document gives me the error "the parameter is incorrect."  Trying to print a test page from the printer properties page does not work either.

I'm pretty sure that Vista sp1 already includes RDP 6.1, and I also installed .NET 3.5 framework.  Does anyone have any other suggestions?


Serial Port Application Leaks Handle After Exit Forcing Reboot to Clear


The application (C# .Net 3.5) available at www.redondowa.com/porttest demonstrates a problem encountered with a Sony VAIO multimedia laptop related to use of its serial modem port.  A discussion with MS support is included in a doc with the VS solution.

If the base stream or port is not closed before nulling the port, the port cannot be recreated and the application leaves the port inaccessible.  The machine requires a reboot to clear the error.  Other machines clear the error without requiring a reboot.

<!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:134; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch

USB Serial Port, baude rate limited by Overrun errors



I need to dump a huge number of characters per second to a PC from a simple micro controlled device rs232 port at the least for debugging purposes.

I can select and sucesfully transmit/receive at speeds up to 3M baud without significant data coruption on short packets, however for sustained data I get too many overrun errors for it to be usefull, even at 230K buad it is too much.

I am using a usb serial cable, on windows 7 (64) on an I7 system, so it should have plenty of cpu power to keep up. it only needs to service it twice per millisecond at 230kBaud to keep up.

I am programming with C# and have 3 threads, one for the UI, one for the port, and one for decoding the data.

I have a large data buffer, and I am calling read fast enough so that I get about 100 characters on average, the SerialPort object port buffer is set to "very big" (64k), with byte threshold set to 100, setting it to 1 makes no difference.

The 16 byte Fifo on the usb serial cable is set to 1, but this makes little diference.

From what I have read it is the device driver not reading the usb port fast enough, and the usb serial cable "chip" runs out of buffer.

I have tried different usb serial cables, but they have the same 16 byte buffer and the same problem.

Is there any way I can speed this up ? I would of th

Serial port



I'm try to read a RFID tag ID with a RFID reader.

I want to see ID tag in a text box.

1-Reader, once every 1 second read tag, Therefore I want to see ID tag in a text box Continuous.

2-Reader send a hex/string code to serial port such as    (␠b%) , however I should see  E2 00 90 20 14 19 01 62 25 00 18 1F

would you please help me ; how I can develop a C# code in windows application?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend