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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Overlapped IO or non overlapped?

Overlapped IO or non overlapped?

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarequestion
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.
  • G Offline
    G Offline
    generic_user_id
    wrote on last edited by
    #1

    Hello guru's around the world! I'm writing some software to handle some simple home-made hardware under windows2000. I need to use 2 input and 2 output channels, being: DSR, CTS, RTS, DTR. I open the serial port using CreateFile(..), non overlapped. Toggleing the output channels with EscapeCommFunction(..) works fine too. A worker tread is in an infinite loop (while(true)) in which it waits for a WaitCommEvent(..). When the DSR or the CTS lines change state, I get notified - just as it should be. But I want to keep polling with WaitCommEvent(..) and I want to use EscapeCommFunction(..) to toggle the output lines. To be more exact, I need to be able to give pulses to the DTR and watch what happens to the CTS (input). Unfortunatly, EscapeCommFunction(..) hangs if WaitCommEvent(..) is still waiting for an event. Do I NEED to use overlapped IO for this? Or is it possible to change the DTR status while polling the CTS? Thanks in advance, Regards, Griffith Sutherns


    Everything you say will be misquoted, ripped out of context and used against you.

    C 1 Reply Last reply
    0
    • G generic_user_id

      Hello guru's around the world! I'm writing some software to handle some simple home-made hardware under windows2000. I need to use 2 input and 2 output channels, being: DSR, CTS, RTS, DTR. I open the serial port using CreateFile(..), non overlapped. Toggleing the output channels with EscapeCommFunction(..) works fine too. A worker tread is in an infinite loop (while(true)) in which it waits for a WaitCommEvent(..). When the DSR or the CTS lines change state, I get notified - just as it should be. But I want to keep polling with WaitCommEvent(..) and I want to use EscapeCommFunction(..) to toggle the output lines. To be more exact, I need to be able to give pulses to the DTR and watch what happens to the CTS (input). Unfortunatly, EscapeCommFunction(..) hangs if WaitCommEvent(..) is still waiting for an event. Do I NEED to use overlapped IO for this? Or is it possible to change the DTR status while polling the CTS? Thanks in advance, Regards, Griffith Sutherns


      Everything you say will be misquoted, ripped out of context and used against you.

      C Offline
      C Offline
      Colin Urquhart
      wrote on last edited by
      #2

      In non-overlapped IO each call will block the IO resource. You will also run into problems when you try to exit from your thread because it will be stuck on WaitCommEvent. You have a couple of choices: 1. Don't use WaitCommEvent and instead poll the IO with GetCommModemStatus. Polling can be OK if done infrequently. 2. Use overlapped IO. A little more complicated but it won't block the IO resource. I'd go with overlapped IO. Col :-)

      G 1 Reply Last reply
      0
      • C Colin Urquhart

        In non-overlapped IO each call will block the IO resource. You will also run into problems when you try to exit from your thread because it will be stuck on WaitCommEvent. You have a couple of choices: 1. Don't use WaitCommEvent and instead poll the IO with GetCommModemStatus. Polling can be OK if done infrequently. 2. Use overlapped IO. A little more complicated but it won't block the IO resource. I'd go with overlapped IO. Col :-)

        G Offline
        G Offline
        generic_user_id
        wrote on last edited by
        #3

        Thanks a lot Colin! I'll look into GetCommModemStatus first, that might just be what I was looking for. Although I do need need to poll about 80 times in a few seconds, it might still work reliably. Once again, your help's greatly appriciated. Regards, Griffith


        Everything you say will be misquoted, ripped out of context and used against you.

        C 1 Reply Last reply
        0
        • G generic_user_id

          Thanks a lot Colin! I'll look into GetCommModemStatus first, that might just be what I was looking for. Although I do need need to poll about 80 times in a few seconds, it might still work reliably. Once again, your help's greatly appriciated. Regards, Griffith


          Everything you say will be misquoted, ripped out of context and used against you.

          C Offline
          C Offline
          Colin Urquhart
          wrote on last edited by
          #4

          BTW, Since you plan to poll you should do it at least double the maximum possible expected input frequency to ensure you do not miss a pulse. Col :-)

          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