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. Problems with ClearCommError

Problems with ClearCommError

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++tutorial
1 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.
  • D Offline
    D Offline
    Demian Panello
    wrote on last edited by
    #1

    Hi. I have developed an aplication that it read and write bytes through the serial ports. The program works fine, except for some PCs, (very few ones). While is reading the data, sometimes it ends the communication suddenly. I found that it happend because ClearCommError fails, I have the following code: ... // the following loop try to send a command and read the answer while( retry> 0 ) { // the problem is here, when that function fails if( !ClearCommError( idCommDev, &dwError,&comstatInfo )) { lResult = 116; dwLasError = GetLastError(); // I call GetLastError() but I get -1. ??????? return lResult; } if( !PurgeComm( idCommDev, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR )) { lResult = 115; return lResult; } // Send a command lResult = TXPacket(dataTX, 250); if( lResult!= 0 ) return lResult; // Read the answer lResult = RXPacket(dataRX, timeout); .... This is my problem. In some PC, (I don't know why), the function ClearCommError() fail with no error code available with GetLastError(), so I can't figure out what is happened. Thank you.

    Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

    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