Replacing ONCF's Serial with Microsoft's SerialPort

Last post 07-28-2009 10:55 by ctacke. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-28-2009 9:34

    • Robsta
    • Top 50 Contributor
    • Joined on 07-28-2009
    • Southampton, England
    • Posts 10

    Replacing ONCF's Serial with Microsoft's SerialPort

    Before I start, I'll let you know a little background about this question. Basically, we are (finally) making the leap from NetCF 1.0 to NetCF 3.5, with which a HELLUVA LOT of the OpenNetCF bases have been covered by Microsoft's traditional framework. On an initial upgrade and compile, the solution (6 projects) is wielding 79 errors compiling (and loads more to follow these no doubt).

    So I've got work ahead of me with removing all of these errors, and thought I'd start off with our IrDA class (top of the list of errors). Existingly, under NetCF 1.0, we were using OpenNetCF.IO.Serial to fill the void, which has been depricated by System.IO.Ports.SerialPort.

    What I'm attempting is to replace Serial.Input but see that the documentation on this site has (perhaps correctly) been replaced to represent the lack of this class in the latest SDF. However, the SerialPort class does not include this as an option. It also lacks the IREnable bool, but unsure of what relevance this has.

     Could any of you clever minds figure out how I could read from the SerialPort buffer (over IrDA) to a byte[]?

     Many thanx in advance.

    Live Fast, Die Young.
  • 07-28-2009 10:13 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 2,254

    Re: Replacing ONCF's Serial with Microsoft's SerialPort

    The first thing I'd ask is "does the application work using OpenNETCF's Serial implementation?"  If it does, why change it?  Seriously.  If you have working code, changing it does nothing but introduce the chance of new bugs and takes development time that could be used for other tasks.  Add to that the fact that the MS implementation actually doesn't work so well for certain scenarios anyway.

    The Serial stuff was removed from the SDF (due to functional overlap), but is still widely used and therefore is still available on CodePlex.

  • 07-28-2009 10:41 In reply to

    • Robsta
    • Top 50 Contributor
    • Joined on 07-28-2009
    • Southampton, England
    • Posts 10

    Re: Replacing ONCF's Serial with Microsoft's SerialPort

    Thanx for the swift respone. I've downloaded and built the project, releasing the required library.

    The powers that be wish for as much of our code as possible to be MS code, due to the fact that OpenNetCF's wonders can be deprecated. In this instance, how would one go about using the SerialPort (MS object?)

     Can I ask under which circumstances you have experienced problems?

    Also, what does the IREnable flag actually do? I take it the raw bytes are still pushed and pulled down the 'pipe' the same way from a standard serial connection over an IrDA one? I can see the following in the source, but what is the physical difference here?

    m_CommAPI.EscapeCommFunction(hPort, CommEscapes.SETIR) (and the CLRIR)

    Thanx in advance.

    R.

    Live Fast, Die Young.
  • 07-28-2009 10:55 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 2,254

    Re: Replacing ONCF's Serial with Microsoft's SerialPort

    Moving to the MS Serial stuff requires porting the code.  The logic on how the two work is somewhat different, so you'll have to adjust the logic of your app.

    The MS Serial Port stuff has weirdness when trying to use ReadLine that often leads to data loss.  I sinmply don't use it becasue it's a black box.  With our library you can trace calls all the way to the driver, so you know exacly what is going on.

    IREnable typically puts an IR port into "raw' mode (instead of IRDA) but the exact behavior is dependent on the device serial port driver.

Page 1 of 1 (4 items)