Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Bugfixes in SerialPort implementation

  • Please log in to reply
1 reply to this topic

#1 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 03 January 2011 - 08:57 AM

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:
Netduino Plus
Netduino Mini

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...


#2 CW2


    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 03 January 2011 - 09:35 AM

Many thanks for those fixes (especially #4).

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.