开发者

Is there a way to use a serial port at 2-3 mbps?

开发者 https://www.devze.com 2023-03-13 11:07 出处:网络
I need to stream serial data to and from a C# Windows PC application at 2-3 mbps. C# winforms doesn\'t seem very happy with it.

I need to stream serial data to and from a C# Windows PC application at 2-3 mbps. C# winforms doesn't seem very happy with it.

openFileDialog.Filter =
    @"Image Files(*.bmp;*.jpg;*.jpeg;*.gif)|*.bmp;*.jpg;*.jpeg;*.gif|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() != DialogResult.OK) return;
var image = Image.FromFile(openFileDialog.FileName);
serialPort1.Open();
// Now send the image at 2-3 mbps
...

开发者_开发知识库BaudRate = 115200 works. BaudRate = 230400 causes System.IO.IOException.

Is there a way to use a serial port at 2-3 mbps?


Open up device manager and expand out "ports".

Is there a way to use a serial port at 2-3 mbps?

double click on COM1 and go to the "Port Settings" tab

Is there a way to use a serial port at 2-3 mbps?

Under "Bits per second" lists values you can enter in the proprieties field for your com port. If you want higher than what your hardware allows you need other hardware or use something other than a serial port to transfer between the two devices.

If you would post in the comments what is the other device you are connecting to, we may be able to suggest a better way.


This post is 4 years old, so for those stumbling upon it:

1st, the serial port hardware needs to support the datarate. 2nd, the driver needs to let you choose the desired baudrate. Some drivers or chips may require tweaking to let you select non-standard (or higher than 115200) baudrates. The max baudrate of a few USB to serial chips I've come across:

  • Silicon Labs CP2102 & CP2109: 921.6 kbps
  • FTDI FT232R: 3 Mbps
  • Prolific PL-2303HX & PL-2303HXD: 12Mbps

I'm currently using the FT232R @ 1Mbps

Regarding the use of C# and .NET: .NET seems to suck at serial ports. See http://www.sparxeng.com/blog/software/must-use-net-system-io-ports-serialport (which references this thread and is how I got here).

A coworker made a c# .NET program for me to communicate at 1Mbps using the FT232R with .NET 3.5. It worked on his PC and a Notebook, but would instead be stuck at 9600bps on my PC. Tried several things including driver uninstalling, rebooting, cold start and manual driver installation to no avail. He then recompiled it for .NET 4 and voilá, it worked. The funny thing is right after that he handed me a minor modification but mistakingly compiled it for .NET 3.5, but it worked.


If your hardware supports those speeds, then Windows does as well. The .NET SerialPort class may or may not allow you to set the baud rate that high, if not then try calling SetCommState.


No. That is a limitation of the hardware. forom looking at the internals, it looks like windows has a max.

http://msdn.microsoft.com/en-us/library/aa363189(v=vs.85).aspx


I have used BlueTooth serial ports that ran at 1Mbps, and it seemed like it didn't care what speed was set.


Serial ports generally supports speeds up to 115200 bps, or just over 14 KBps. Some devices support higher baud rates, but you're a long way from 2-3 mbps.

Is there a particular reason you're choosing to use a serial port? While still used, it's widely deprecated in favor of more modern approaches. If you're transferring between processes on one machine, a named pipe or just using the filesystem might be better. If you're transferring between two computers, consider using TCP/IP networking.

This link on MSDN talks about the different transports that WCF recommends and supports, and might be a good place to start looking. http://msdn.microsoft.com/en-us/library/ms733769.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号