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. managing serial port interrupt

managing serial port interrupt

Scheduled Pinned Locked Moved C / C++ / MFC
question
10 Posts 4 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.
  • M Offline
    M Offline
    misturas
    wrote on last edited by
    #1

    Hi to all, I made a deep search in this and other sites about serial communications management in Win32 (Win9X,2000,XP) All the results leads to using ReadFile and the other file-style functions But is any way to use interrupts (int of received char) on Windows?Must I create a device drivers? Thanks to all Cristian

    R C I 4 Replies Last reply
    0
    • M misturas

      Hi to all, I made a deep search in this and other sites about serial communications management in Win32 (Win9X,2000,XP) All the results leads to using ReadFile and the other file-style functions But is any way to use interrupts (int of received char) on Windows?Must I create a device drivers? Thanks to all Cristian

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      misturas wrote:

      ReadFile

      Mmmh .. .really ? What are you trying to achieve exactely ? ~RaGE();

      C 1 Reply Last reply
      0
      • M misturas

        Hi to all, I made a deep search in this and other sites about serial communications management in Win32 (Win9X,2000,XP) All the results leads to using ReadFile and the other file-style functions But is any way to use interrupts (int of received char) on Windows?Must I create a device drivers? Thanks to all Cristian

        R Offline
        R Offline
        Rage
        wrote on last edited by
        #3

        Ever considered using this: http://www.codeproject.com/system/cserialport.asp[^] ~RaGE();

        M 1 Reply Last reply
        0
        • R Rage

          Ever considered using this: http://www.codeproject.com/system/cserialport.asp[^] ~RaGE();

          M Offline
          M Offline
          misturas
          wrote on last edited by
          #4

          I use Visual C++ 6.0 and I studied the article "Serial Communications in Win32" of msdn My question is a question my boss made me I know it's not very easy to interact with hardware at low level on Windows and all the articles I found uses overlapped operation and ReadFile/WriteFile to read/write COM ports Now in Italy is 6 p.m., so I have to leave office ;P Sorry if I don't reply immediately Thanks in advance ;)

          R 1 Reply Last reply
          0
          • M misturas

            I use Visual C++ 6.0 and I studied the article "Serial Communications in Win32" of msdn My question is a question my boss made me I know it's not very easy to interact with hardware at low level on Windows and all the articles I found uses overlapped operation and ReadFile/WriteFile to read/write COM ports Now in Italy is 6 p.m., so I have to leave office ;P Sorry if I don't reply immediately Thanks in advance ;)

            R Offline
            R Offline
            Rage
            wrote on last edited by
            #5

            misturas wrote:

            Now in Italy is 6 p.m

            :doh: Really ? I am sitting in Germany, and it is still 5 p.m. Did not know that Germany had a different time than Italy. As for serial communication, there are lots of wrappers that consider the serial port as a file with read/write operation. This is very handy for serial communication, but not for your purposes. I think what you are looking for is a way to get the hand when a serial interrupt is called (as we used to do under DOS or on microcontrollers). I think this should be feasible with the API I have provided you with, in this case you must get a Windows message as soon as something lands on the serial buffer. ~RaGE();

            1 Reply Last reply
            0
            • R Rage

              misturas wrote:

              ReadFile

              Mmmh .. .really ? What are you trying to achieve exactely ? ~RaGE();

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              Yes, sure. What is the problem with that ? Reading and writing data on the serial port is done with ReadFile and WriteFile.

              R 1 Reply Last reply
              0
              • M misturas

                Hi to all, I made a deep search in this and other sites about serial communications management in Win32 (Win9X,2000,XP) All the results leads to using ReadFile and the other file-style functions But is any way to use interrupts (int of received char) on Windows?Must I create a device drivers? Thanks to all Cristian

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #7

                Maybe it would help a lot if you describe exactly what you want to achieve. In general, reading and writing to a serial port can be done by several ways (specifically for reading). You can use a loop with timeouts (in a separate thread for example), ... But if you want to really respond when there is an interuption, then you'll need to go for a device driver (and I suppose it must be tricky to do). Anyway, even inside your driver, you will still have the problems of the real-time behavior, which is that Windows is not a real time operating system, so everything you want to achieve under the resolution of 10 msec (it can vary) is unfeasible.

                1 Reply Last reply
                0
                • C Cedric Moonen

                  Yes, sure. What is the problem with that ? Reading and writing data on the serial port is done with ReadFile and WriteFile.

                  R Offline
                  R Offline
                  Rage
                  wrote on last edited by
                  #8

                  Hi Cedric, I was doubting the fact that ReadFile and WriteFile was the _only_ method provided to read/write data under Windows. Not that it does not work. ~RaGE();

                  1 Reply Last reply
                  0
                  • M misturas

                    Hi to all, I made a deep search in this and other sites about serial communications management in Win32 (Win9X,2000,XP) All the results leads to using ReadFile and the other file-style functions But is any way to use interrupts (int of received char) on Windows?Must I create a device drivers? Thanks to all Cristian

                    I Offline
                    I Offline
                    Iain Clarke Warrior Programmer
                    wrote on last edited by
                    #9

                    If you want to be notified on receipt of a char, you can use overlapped I/O with your read. That way an Event will be signalled any time you receive a character. You could put a receive loop in a separate thread, anf then post each characted received with a resgistered window message. The choices may not be endless, but they are several! Iain.

                    M 1 Reply Last reply
                    0
                    • I Iain Clarke Warrior Programmer

                      If you want to be notified on receipt of a char, you can use overlapped I/O with your read. That way an Event will be signalled any time you receive a character. You could put a receive loop in a separate thread, anf then post each characted received with a resgistered window message. The choices may not be endless, but they are several! Iain.

                      M Offline
                      M Offline
                      misturas
                      wrote on last edited by
                      #10

                      Ok, for rage, yes it was 5 p.m. I know the way ReadFile Overlapped IO etc. I was asking myself if there was a way of control interrupt the way dos/microcontroller do I think the only suitable way is creating a device driver It's better if re-study behavior of ReadFile,Events and Overlapped IO Thanks to all:)

                      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