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. I/O operation sytem error

I/O operation sytem error

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 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.
  • L Offline
    L Offline
    LCI
    wrote on last edited by
    #1

    I am in a loop, reading from an RS232 port. There are times when i receive an exception with a system message that says: "The I/O operation has been aborted because of either a thread exit or an application request" // read a byte from port while (!m_bExit) { // reset flag variables dwBytesRead = 0; // read bRC = ReadFile(m_hCommPort, pDataBuff, 20, &dwBytesRead, NULL); dwError = GetLastError(); if (!bRC) { if (ERROR_HANDLE_EOF != dwError || ERROR_TIMEOUT != dwError) { LPVOID SysMsg; // reterieve system message FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&SysMsg, 0, NULL ); // show system message ZeroMemory( m_szBuffer, sizeof(m_szBuffer) ); wsprintf(m_szBuffer, TEXT("ReadRS232Data() over %s: ReadFile(), %s"), m_Port, (LPCTSTR)SysMsg); LocalFree(SysMsg); return 0; } } Has anyone ever found a solution to this or know what would cause this error? Cause once this happens you cannot read from the port until it is out of this conditions which seems to just happen on its own. Thanks in advance for any help or direction.

    L 1 Reply Last reply
    0
    • L LCI

      I am in a loop, reading from an RS232 port. There are times when i receive an exception with a system message that says: "The I/O operation has been aborted because of either a thread exit or an application request" // read a byte from port while (!m_bExit) { // reset flag variables dwBytesRead = 0; // read bRC = ReadFile(m_hCommPort, pDataBuff, 20, &dwBytesRead, NULL); dwError = GetLastError(); if (!bRC) { if (ERROR_HANDLE_EOF != dwError || ERROR_TIMEOUT != dwError) { LPVOID SysMsg; // reterieve system message FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&SysMsg, 0, NULL ); // show system message ZeroMemory( m_szBuffer, sizeof(m_szBuffer) ); wsprintf(m_szBuffer, TEXT("ReadRS232Data() over %s: ReadFile(), %s"), m_Port, (LPCTSTR)SysMsg); LocalFree(SysMsg); return 0; } } Has anyone ever found a solution to this or know what would cause this error? Cause once this happens you cannot read from the port until it is out of this conditions which seems to just happen on its own. Thanks in advance for any help or direction.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      LCI wrote:

      I am in a loop

      That sounds uncomfortable.

      LCI wrote:

      or know what would cause this error

      What is the number returned from GetLastError?

      C L 2 Replies Last reply
      0
      • L led mike

        LCI wrote:

        I am in a loop

        That sounds uncomfortable.

        LCI wrote:

        or know what would cause this error

        What is the number returned from GetLastError?

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

        led mike wrote:

        That sounds uncomfortable.

        :laugh:

        Cédric Moonen Software developer
        Charting control [v1.5] OpenGL game tutorial in C++

        1 Reply Last reply
        0
        • L led mike

          LCI wrote:

          I am in a loop

          That sounds uncomfortable.

          LCI wrote:

          or know what would cause this error

          What is the number returned from GetLastError?

          L Offline
          L Offline
          LCI
          wrote on last edited by
          #4

          I do not log the number that returns, but the related message is : "The I/O operation has been aborted either because of a thread exit or an application request." BTW, i cannot reproduce. I just know when it happens.

          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