We've made a number of bugfixes in the System.IO.Ports.SerialPort implementation.
Download Links for current pre-release (v4.1.1 alpha 5) firmware:
We had three goals:
1. Fix outstanding serial port bugs that are affecting users
2. Bring behavior in line with SerialPort from desktop .NET framework
3. Avoid breaking existing user code where possible
Changes to SerialPort.DataReceived event:
1. Previously, wiring up the DataReceived event before calling SerialPort.Open could result in intermittent functioning of the DataReceived event. Usually, it would work while debugging...but not in the field. This is hopefully now fixed.
2. The DataReceived event previously only fired when data was first received...and then after the user read partial data from the buffer. It was not fired when new data was subsequently received. Its behavior has now been fixed, and should be reasonably identical to the behavior of the desktop .NET Framework.
Changes to SerialPort.ReadTimeout and SerialPort.WriteTimeout properties:
3. Read and Write functions were returning after the timeout period but were not throwing timeout exceptions. These are traditionally thrown in part to indicate that a timeout has occured (rather than the port being closed). The behavior is now in line with the behavior of the desktop .NET Framework.
Changes to SerialPort.Read(...) function:
4. SerialPort.Read(...) previously waited until "count" bytes were received or until timeout occurred. The workaround was to call SerialPort.BytesToRead and then pass that value as "count". The behavior has been modified to return "up to count" bytes of data, up to the full read buffer. This is identical to the behavior of the .NET Framework and should make creating cross-platform applications easier. And enhance the performance of serial receivers/parsers.
We have made these bugfixes in the v4.1.1 alpha 5 firmware and will be contributing them back to the .NET MF core for possible inclusion in .NET MF 4.2. These bugfixes have been made very carefully to ensure the highest code compatibility...but if you have created a GPS parser or other serial-heavy program you may want to test against this alpha release.
If you would like to share any feedback on these bugfixes, please let us know here...
Bugfixes in SerialPort implementation
1 reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users