I am using the Serial Port class for serial communications, It is very easy
to use but there is one thing I want to do and can't figure out how.
SerialPort.GetPortNames() gives me a list of all the Serial Ports on the
system. I let the end user select one from the list. I also want to give the
user the ability to specify the baud rate for the selected port. However, I
could not find an interface that will list all the baud rates for a given
port. I looked in the registry and the values did not seem to be there.

Anyone know how I can get the supported baud rates for any serial port?

Thanks in Advance,

Bob Costello

Re: Serial Communications - baud rate by Matt

Matt
Thu Jul 19 09:10:52 CDT 2007

On 17 Jul, 20:50, Bob Costello <BobCoste...@discussions.microsoft.com>
wrote:
> I am using the Serial Port class for serial communications, It is very easy
> to use but there is one thing I want to do and can't figure out how.
> SerialPort.GetPortNames() gives me a list of all the Serial Ports on the
> system. I let the end user select one from the list. I also want to give the
> user the ability to specify the baud rate for the selected port. However, I
> could not find an interface that will list all the baud rates for a given
> port. I looked in the registry and the values did not seem to be there.
>
> Anyone know how I can get the supported baud rates for any serial port?
>
> Thanks in Advance,
>
> Bob Costello

There isn't a managed calls for this in the framework (yet - we live
in hope)

This information is available through the API function:
GetCommProperties - http://msdn2.microsoft.com/En-US/library/aa363259.aspx

For an example on pinvoking it see:
http://pinvoke.net/default.aspx/kernel32/GetCommProperties.html
or
http://www.webtropy.com/articles/art9-1.asp?f=GetCommProperties

Alternatively, have a look at http://www.codeproject.com/dotnet/DotNetComPorts.asp
where a lot of the work is done for you.


Re: Serial Communications - baud rate by BobCostello

BobCostello
Fri Jul 20 09:42:05 CDT 2007

Matt,

Thanks. I did spot the GetCommProperties after I posted my questions. In
fact, I got it from the following link, which gives the gives the C#
declarations for hundreds of win API functions:

http://www.webtropy.com/articles/Win32-API-DllImport-art9.asp?Windows+API

I will check out the CodeProject example.

Thanks


"Matt Lacey" wrote:

> On 17 Jul, 20:50, Bob Costello <BobCoste...@discussions.microsoft.com>
> wrote:
> > I am using the Serial Port class for serial communications, It is very easy
> > to use but there is one thing I want to do and can't figure out how.
> > SerialPort.GetPortNames() gives me a list of all the Serial Ports on the
> > system. I let the end user select one from the list. I also want to give the
> > user the ability to specify the baud rate for the selected port. However, I
> > could not find an interface that will list all the baud rates for a given
> > port. I looked in the registry and the values did not seem to be there.
> >
> > Anyone know how I can get the supported baud rates for any serial port?
> >
> > Thanks in Advance,
> >
> > Bob Costello
>
> There isn't a managed calls for this in the framework (yet - we live
> in hope)
>
> This information is available through the API function:
> GetCommProperties - http://msdn2.microsoft.com/En-US/library/aa363259.aspx
>
> For an example on pinvoking it see:
> http://pinvoke.net/default.aspx/kernel32/GetCommProperties.html
> or
> http://www.webtropy.com/articles/art9-1.asp?f=GetCommProperties
>
> Alternatively, have a look at http://www.codeproject.com/dotnet/DotNetComPorts.asp
> where a lot of the work is done for you.
>
>