C# SerialPort limitation

G

Guest

Is there a limitation to the baud rate that can be used when programming with
C# ?

If I run my C# code to interface with the port at 115200, the port will open
and operate fine. If I increase the baud rate to 921600, the open command
will always fail. I know the hardware can support these speeds, because if I
use C++, I am able to open the port and communicate correctly at the faster
speed.
I am working with .Net 2.0 .

Any ideas to get this to work. I am writing a dll to use C++, but I would
prefer a fix for C#.
 
G

Guest

Not sure if the internal library does or does not support faster that 115k
as most standard BSPs cut off at that speed. You could always try another
library that you have the source to and see if it work (and if not what the
reason for failure is). We have a free, open-source library that matches
the CF object model so it's easy to change between the two.

http://opennetcf.com/FreeSoftware/OpenNETCFIOSerial/tabid/252/Default.aspx


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
D

Dick Grier

Hi,

Are you completely sure that your hardware supports this speed (I see that
you say that it does...)? However, standard PC hardware is limited to
115200 bps. What specialized hardware are you using? Is this a Virtual or
Physical serial port?

AFAIK, the serial APIs that the SerialPort object use are identical to the
ones that you'd use in you C++ code.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
D

Dick Grier

BTW, since this is a Compact Framework group... Are you using CF? I haven't
seen any hardware that supports speeds higher than 115.2K bps.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
G

Guest

The hardware is a custom board using a PXA255 processor which will support
higher rates. The connection will actually be to a bluetooth module. This is
not a PC application. However, I did notice that the PC version of my
application also failed when trying to establish a connection at 921600bps
using .NET 2.0, C#.
 
G

Guest

And the driver is definitely set up to accept the higher rates already?
Again, the off-the-shelf driver supports up to 115.2k, so if the driver has
not yet been modified then it's quite possible that it's returning a failure
becasue it thinks the value you're using is invalid.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
G

Guest

I implemented the OpenNETCF code in both my PC application and the CE device,
and all seems to operate properly. I have established a serial connection at
921600bps and it runs fine.

But I am still curious about a possible fix for implementing the
System.IO.Ports provided in .NET 2.0. Does anyone have a solution for this
issue or know why there seems to be a limitation on the driver?
 
G

Guest

Sounds like the CF class has a hard-coded upper limit - likely due to the
origianl developer's lack of understanding that an OEM can in fact increase
the suppoted rate above 115.2k. I'd say it's a bug in the CF.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
D

Dick Grier

Well, I have no experience with (device) hardware that support these higher
speeds.

However, I note that you say that you are going to use this with a BT
module. Personally, I doubt that you can actually measure any performance
difference between 115200 bps and your higher speed.

You certainly can try the underlying APIs. I have VB code in my book for
this, and there is C# code available for the (similar) SerialPort object on
www.opennetcf.org.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
F

Fred

Dans : <ctacke/> disait :

Hello,
Sounds like the CF class has a hard-coded upper limit - likely due to
the origianl developer's lack of understanding that an OEM can in
fact increase the suppoted rate above 115.2k. I'd say it's a bug in
the CF.

I'm not sure because de Compact framework calls the GetCommProperties
API to set its max baud property.
 
D

David Hearn

Dick said:
BTW, since this is a Compact Framework group... Are you using CF? I haven't
seen any hardware that supports speeds higher than 115.2K bps.

Dick

The PXA255 and PXA270 both have at least one 921kbps UART, usually used
for Bluetooth.

D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top