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 / C++ / MFC
  4. CSerialPort Class Problem and Error 87

CSerialPort Class Problem and Error 87

Scheduled Pinned Locked Moved C / C++ / MFC
helpphpcomtutorialquestion
2 Posts 1 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
    AnotherProgrammer
    wrote on last edited by
    #1

    Hello. First, I'd like you to take a look at this post from another forum: http://www.codeguru.com/forum/showthread.php?s=4f35cbebe00b8299d7c4f45da97051c1&threadid=193904 (it explains the problem with CSerialPort -- this should also be brought to the attention of the authors of the class) Anyway, I came across the exact same problem, except I was not using the class. I simply had WaitCommEvent and GetLastError() give me the same error 87 using this piece of code:

    if (WaitCommEvent(hCom, &event, &obj))
    {
    cout << "Character Detected! ";
    fsuccess = ReadFile (hCom, &data, 1, &transferred, &obj);
    if (fsuccess)
    cout << "Character Read! Here it is: " << data;
    getch();
    }
    else
    {
    if (GetLastError() == ERROR_IO_PENDING)
    cout << "Still waiting";
    else
    {
    cout << "Fatal error: " << GetLastError();
    getch();
    exit(1);
    }
    }

    As I said, the output for this program is Fatal error: 87. I should explain, this is after the COM1 port has been opened successfully for reading. Does anyone have any suggestions as to how to solve this? I will be very thankful if someone could help. Thanks..

    A 1 Reply Last reply
    0
    • A AnotherProgrammer

      Hello. First, I'd like you to take a look at this post from another forum: http://www.codeguru.com/forum/showthread.php?s=4f35cbebe00b8299d7c4f45da97051c1&threadid=193904 (it explains the problem with CSerialPort -- this should also be brought to the attention of the authors of the class) Anyway, I came across the exact same problem, except I was not using the class. I simply had WaitCommEvent and GetLastError() give me the same error 87 using this piece of code:

      if (WaitCommEvent(hCom, &event, &obj))
      {
      cout << "Character Detected! ";
      fsuccess = ReadFile (hCom, &data, 1, &transferred, &obj);
      if (fsuccess)
      cout << "Character Read! Here it is: " << data;
      getch();
      }
      else
      {
      if (GetLastError() == ERROR_IO_PENDING)
      cout << "Still waiting";
      else
      {
      cout << "Fatal error: " << GetLastError();
      getch();
      exit(1);
      }
      }

      As I said, the output for this program is Fatal error: 87. I should explain, this is after the COM1 port has been opened successfully for reading. Does anyone have any suggestions as to how to solve this? I will be very thankful if someone could help. Thanks..

      A Offline
      A Offline
      AnotherProgrammer
      wrote on last edited by
      #2

      Sorry, messed up the HTML tags. Here's the link to that other post containing the CSerialPort class problems: Link to CodeGuru post about CSerialPort class problem

      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