473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Serial Ports

i have written an application that utilizes serail ports. In order not to
have to reinvent code, I decided to use John Hind's sample code that he
presented in MSDN magazine last year (Serial Comm: Use P/Invoke to Develop a
..NET Base Class Library for Serial Device Communications John Hind - MSDN
Magazine - October 2002)

it works fine except for one problem. i cannot address any port higher than
COM9. I am using an equinox multi-serial card that addes 16 serial ports, so
there are a total of 18 valid com ports. However when i try to open anything
over COM9: i get an error that says that it is an invalid name.

i llooked thruogh his code but was unable to find any reason why this would
fail.
does anyone have any explanations as to why it would fail or suggestions as
to how to fix this?

i appreciate your help
m
Nov 15 '05 #1
4 7427

Hi m,

Thanks for posting in this group.
Based on my understanding, when you use the code of (Serial Comm: Use
P/Invoke to Develop a .NET Base Class Library for Serial Device
Communications John Hind - MSDN Magazine - October 2002), you can not
address any port higher than COM9.
I think first, you should confirm the problem is generated in win32 layer
or in the P/invoke layer between .Net and win32 API, so you can use the
link below to have a test:
http://msdn.microsoft.com/library/de...us/dnfiles/htm
l/msdn_serial.asp

Once you have find the cause layer, please feel free to feedback to me, I
will work with you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2
I ran into this when I wrote my own serial driver for .NET

For COM ports greater than 9 you have to use a special syntax when calling
CreateFile (which also works for 1 through 9).

the name should be \\.\COM10 - if using C# you need to escape those slashes
or use the literal prefix (the @)

Note the lack of a trailing colon as well. In my driver I had the user pass
in the COM #, which I converted to the appropriate string syntax.

e.g.

either
string port="\\\\.\\COM10";
or
string port= @"\\.\COM10";

See this link for the article (Q115831)

http://support.microsoft.com/default.aspx?scid=kb;[LN];115831

I have successfully opened ports to COM16 using this.

That should do it
Tom
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:$I**************@cpmsftngxa07.phx.gbl...

Hi m,

Thanks for posting in this group.
Based on my understanding, when you use the code of (Serial Comm: Use
P/Invoke to Develop a .NET Base Class Library for Serial Device
Communications John Hind - MSDN Magazine - October 2002), you can not
address any port higher than COM9.
I think first, you should confirm the problem is generated in win32 layer
or in the P/invoke layer between .Net and win32 API, so you can use the
link below to have a test:
http://msdn.microsoft.com/library/de...us/dnfiles/htm l/msdn_serial.asp

Once you have find the cause layer, please feel free to feedback to me, I
will work with you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3
Yes. this is the answer i also came up with while researching the problem. I
tried it and it works
Thanks for your help
m

"Tom Hall" <no****@harmonyit.com> wrote in message
news:uS**************@TK2MSFTNGP09.phx.gbl...
I ran into this when I wrote my own serial driver for .NET

For COM ports greater than 9 you have to use a special syntax when calling
CreateFile (which also works for 1 through 9).

the name should be \\.\COM10 - if using C# you need to escape those slashes or use the literal prefix (the @)

Note the lack of a trailing colon as well. In my driver I had the user pass in the COM #, which I converted to the appropriate string syntax.

e.g.

either
string port="\\\\.\\COM10";
or
string port= @"\\.\COM10";

See this link for the article (Q115831)

http://support.microsoft.com/default.aspx?scid=kb;[LN];115831

I have successfully opened ports to COM16 using this.

That should do it
Tom
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:$I**************@cpmsftngxa07.phx.gbl...

Hi m,

Thanks for posting in this group.
Based on my understanding, when you use the code of (Serial Comm: Use
P/Invoke to Develop a .NET Base Class Library for Serial Device
Communications John Hind - MSDN Magazine - October 2002), you can not
address any port higher than COM9.
I think first, you should confirm the problem is generated in win32 layer or in the P/invoke layer between .Net and win32 API, so you can use the
link below to have a test:

http://msdn.microsoft.com/library/de...us/dnfiles/htm
l/msdn_serial.asp

Once you have find the cause layer, please feel free to feedback to me, I will work with you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 15 '05 #4
In the Windows API you use the CreateFile function to open COM ports
using the names "COMn" for the COM port that you want to open.
If the port number n is greater than 9, you have to use the format
"\\.\COMn"

You will need to find the code in the class that opens the port using
the CreateFile function and change it so that it adds the "\\.\" to
the beginning of the COM port names in order to open COM9 and above.

For more serial I/O tools, visit:
www.taltech.com


On Mon, 12 Jan 2004 17:36:17 -0500, "M. Raab" <ra**@biconix.com>
wrote:
i have written an application that utilizes serail ports. In order not to
have to reinvent code, I decided to use John Hind's sample code that he
presented in MSDN magazine last year (Serial Comm: Use P/Invoke to Develop a
.NET Base Class Library for Serial Device Communications John Hind - MSDN
Magazine - October 2002)

it works fine except for one problem. i cannot address any port higher than
COM9. I am using an equinox multi-serial card that addes 16 serial ports, so
there are a total of 18 valid com ports. However when i try to open anything
over COM9: i get an error that says that it is an invalid name.

i llooked thruogh his code but was unable to find any reason why this would
fail.
does anyone have any explanations as to why it would fail or suggestions as
to how to fix this?

i appreciate your help
m


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
1
by: David | last post by:
I have written an application in VB.NET 2003 that uses the SAX serial component for RS232 communications with hardware. The program sets up 2 serial ports so that it can talk to 2 different...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
3
by: Tom Brown | last post by:
Hey people, I've written a python app that r/w eight serial ports to control eight devices using eight threads. This all works very nicely in Linux. I even put a GUI on it using PyQt4. Still...
5
by: LongBow | last post by:
Hello, Is there a way, in .NET, to determine what are the avialable Serial (Communications) Ports on a Windows OS and is there a way to determine that port isn't being use other than attempting...
2
by: joaquimfpinto | last post by:
Dear All, I made an app in c# that uses several serial ports. For the serial ports I use a pnp Sunix board, some with 8 serial ports other with 4 or even 2 serial ports. Whenever I use the...
3
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to...
2
by: Nasif | last post by:
Currently I am writing a program which sends and receives messages through serial port to a device. I am using C# and Microsoft Visual studio 2005 for windows program. But my problem is when i try...
2
by: Dave Harry | last post by:
I'm using the following code to determine the available serial ports: ComboBoxPort.Items.Clear() For Each sp As String In My.Computer.Ports.SerialPortNames ComboBoxPort.Items.Add(sp) Next It...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.