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. ReadFile Return Value

ReadFile Return Value

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

    Hi. Can i know the return value of ReadFile when a timeout occurs, if the commtimeout structure was previously set? I am writing a simple program that reads the serial port for characters arriving. Anyone can recommend a better option than the one i use? Target device is WindowCE, using embedded Visual C++ 3.0 bool WaitForChar(unsigned char character,DWORD dwTimeout) { DWORD dwTimeStart,dwRead; BYTE in[2]; dwTimeStart = GetTickCount(); while((GetTickCount() - dwTimeStart) < dwTimeout) { if(ReadFile(hPort,in,1,&dwRead,NULL)) { if(dwRead != 0) { if(in == character) return TRUE; } } else return FALSE; } return FALSE; }

    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