Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. .NET 2.0 Serial Ports

.NET 2.0 Serial Ports

Scheduled Pinned Locked Moved C#
csharpperformancehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Staton
    wrote on last edited by
    #1

    I am trying to send serial data at a very high rate (18 bytes every 5 msec). I am using a multimedia timer to get the 5msec and the built in Serial port object in the .NET 2.0 framework. I am using the begin and end write calls to do asyncronous writes in order to keep up. This seems to be working, but when I look at the memory usage for my program it is gradually going up and when I run for over 5 hrs I use all of the system memory and my program crashes. Does anyone know if there are known issues with the Serial Port object or of any way to do this without causing the memory to go up? Any help with this would be great, thanks.

    C 1 Reply Last reply
    0
    • A Alan Staton

      I am trying to send serial data at a very high rate (18 bytes every 5 msec). I am using a multimedia timer to get the 5msec and the built in Serial port object in the .NET 2.0 framework. I am using the begin and end write calls to do asyncronous writes in order to keep up. This seems to be working, but when I look at the memory usage for my program it is gradually going up and when I run for over 5 hrs I use all of the system memory and my program crashes. Does anyone know if there are known issues with the Serial Port object or of any way to do this without causing the memory to go up? Any help with this would be great, thanks.

      C Offline
      C Offline
      c guy3811
      wrote on last edited by
      #2

      my bet would be more on your code design with the Async calls than a flaw in the framework. Make sure you arent starting multiple async receives for the same operation and you are accepting all your callbacks. c#guy

      A 1 Reply Last reply
      0
      • C c guy3811

        my bet would be more on your code design with the Async calls than a flaw in the framework. Make sure you arent starting multiple async receives for the same operation and you are accepting all your callbacks. c#guy

        A Offline
        A Offline
        Alan Staton
        wrote on last edited by
        #3

        Thanks for the response, I will look into it.

        A 1 Reply Last reply
        0
        • A Alan Staton

          Thanks for the response, I will look into it.

          A Offline
          A Offline
          Alan Staton
          wrote on last edited by
          #4

          I am still not able to fix this problem. Here is the call to write the data to the serial port serialPorts[3].BaseStream.BeginWrite(attArray, 0, 18,new AsyncCallback (myWriteCallBack),serialPorts[3].BaseStream); myWriteCallBack is declared as public static void myWriteCallBack(IAsyncResult ar) { System.IO.Stream mySerialStream = (System.IO.Stream)ar.AsyncState; mySerialStream.EndWrite(ar); } Any help would be great! Thanks.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups