Serial Port

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thiago Guedes

    #1

    Serial Port

    Hi,
    how can I use Serial Port in C#, using a framework native
    code.
    I dont want to use P/Invoke.

    Tks,
    Thiago

  • news.microsoft.com

    #2
    Re: Serial Port

    CraptiveX is the only way at present intil 2004 when we get System.IO.Ports
    namespace





    "Thiago Guedes" <thiagosguedes@ hotmail.com> wrote in message
    news:002401c3a2 25$0f671790$a30 1280a@phx.gbl.. .[color=blue]
    > Hi,
    > how can I use Serial Port in C#, using a framework native
    > code.
    > I dont want to use P/Invoke.
    >
    > Tks,
    > Thiago
    >[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Serial Port

      Using an active X control still means that you will be using interop
      code of some sort, and it will actually take more instructions to call the
      COM code than it would to call the P/Invoke code.

      Even when the System.IO.Ports namespace is introduced, my bet is that it
      will just be a managed wrapper calling native code anyways, so you might
      want to do this yourself for now, and switch over when the namespace is
      introduced.

      Hope this helps.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "news.microsoft .com" <discussion@dis cussion.microso ft.com> wrote in message
      news:%23Uvu%23V ioDHA.2512@TK2M SFTNGP09.phx.gb l...[color=blue]
      > CraptiveX is the only way at present intil 2004 when we get[/color]
      System.IO.Ports[color=blue]
      > namespace
      >
      > http://longhorn.msdn.microsoft.com
      >
      >
      >
      > "Thiago Guedes" <thiagosguedes@ hotmail.com> wrote in message
      > news:002401c3a2 25$0f671790$a30 1280a@phx.gbl.. .[color=green]
      > > Hi,
      > > how can I use Serial Port in C#, using a framework native
      > > code.
      > > I dont want to use P/Invoke.
      > >
      > > Tks,
      > > Thiago
      > >[/color]
      >
      >[/color]


      Comment

      • Ed Sutton

        #4
        Re: Serial Port

        If you are going the MSComm COM interop route, simply add a reference in
        your C# project to MSCommLib. Click on the COM
        tab and browse to select your MSCOMM32.OCX .

        Then create an instance of it in your C# class:

        MSCommLib.MSCom m mscomm = new MSCommLib.MSCom mClass();

        The MSComm control has been working fine for me however I am still looking
        for a better .NET way to do it:

        Some alternatives to using the MSComm control in .NET

        C#

        0f9-1301-4cc6-ac14-dfe325097c69

        Managed C++


        VB .NET




        158-95b6-49a7-bb20-93391fc4c196

        C# ( This uses thread pooling that is not supported under Win98)

        0f9-1301-4cc6-ac14-dfe325097c69

        C#

        fc5-666e-4eb0-863f-0045b0c79ec7

        -Ed




        ---
        Outgoing mail is certified Virus Free.
        Checked by AVG anti-virus system (http://www.grisoft.com).
        Version: 6.0.532 / Virus Database: 326 - Release Date: 10/27/2003


        Comment

        • Alan Pretre

          #5
          Re: Serial Port

          "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
          message news:Owe7uYioDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
          > Even when the System.IO.Ports namespace is introduced, my bet is that[/color]
          it[color=blue]
          > will just be a managed wrapper calling native code anyways, so you might
          > want to do this yourself for now, and switch over when the namespace is
          > introduced.[/color]

          We use this MS source, haven't had any trouble with it. It looks a lot like
          Longhorn, so I expect trivial conversion later.



          -- Alan


          Comment

          • Ed Sutton

            #6
            Re: Serial Port

            > We use this MS source, haven't had any trouble with it. It looks a[color=blue]
            > lot like Longhorn, so I expect trivial conversion later.
            >
            >[/color]


            The above approach does not support Win98 or WinME. It uses
            BindIoCompletio nCallback and Windows 95/98/Me are *all* not supported. Of
            course .NET does not support Win95 at all.

            Also, some methods of the ThreadPool Class are not supported by Win98.

            -Ed


            ---
            Outgoing mail is certified Virus Free.
            Checked by AVG anti-virus system (http://www.grisoft.com).
            Version: 6.0.532 / Virus Database: 326 - Release Date: 10/28/2003


            Comment

            Working...