10-05-2011 07:41 AM
Hi,
We have a problem with 1 channel USB-RS485 module.
According to data sheet, the module supports up to 460.8kbps.
We wrote a short C# code which is attached.
There appears an exception saying " The maximum baud rate for this device is 131072" (this exception is also attached)
How can we use this module with C# at 460.8 kbps?
Thanks.
10-05-2011 08:59 PM - edited 10-05-2011 09:00 PM
It looks like you have identified a bug in our USB serial driver. There are two ways an application can determine if a given baud rate will be supported by a serial port. They can ask the driver what the max rate is, or they can just try setting the desired baud rate and see if it returns an error.
Most applications just try to use the baud rate, and never ask the driver for the maximum value. The reason for this is that drivers can only return up to 128K (131072), or a special value meaning "other." In the "other" case, you have to try setting the baud rate anyway. It appears that the C# class actually queries the maximum baud rate first, and our driver is incorrectly returning 128K (131072), instead of "other".
I have recorded the issue to be resolved in a future driver release, but I cannot currently estimate when that will happen. I have two ideas you could try, to attempt to get around the limitation for now:
1. Try opening the port with a baud rate of 115200, then change the BaudRate property to 460800. It is possible that the check is performed in the constructor, rather than in the property, so it is worth trying.
2. NI-VISA is certainly able to use 460800 with this hardware, so you could opt to use NI-VISA for your serial communication in C#, rather than the SerialPort class. Please let us know if #1 works, and if #2 may be an option for your application.
-Jason S.
10-11-2011 03:53 AM
Hi Jason,
We tried #1 but it didn't work.
For #2, the baudrate of the module can be changed from NI -VISA but the functions that we need are in SerialPort Class.
Therefore, we need the new NI-Serial driver.
10-11-2011 06:42 AM
10-11-2011 06:52 AM
We use both XP and 7