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. how to read data from com port

how to read data from com port

Scheduled Pinned Locked Moved C / C++ / MFC
comhelptutorial
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.
  • M Offline
    M Offline
    manju23reddy
    wrote on last edited by
    #1

    i have a program to connect the system with mobile via bluetooth serial connection and when it comes to read method it just stops. and the read methos is bool ReadPort() { long int dwSize = 0; bool hResult = false; std::string sb = ""; DWORD dwEventMask; if(!SetCommMask(hComm, EV_RXCHAR)) /* Setting Event Type */ { return hResult; } if(WaitCommEvent(hComm, &dwEventMask, NULL)) /* Waiting For Event to Occur */ { char szBuf[1024]; DWORD dwIncommingReadSize; do { if(ReadFile(hComm, &szBuf, 1024, &dwIncommingReadSize, NULL) != 0) { if(dwIncommingReadSize > 0) { dwSize += dwIncommingReadSize; sb.append(szBuf); } hResult = true; } else { unsigned long error = ::GetLastError(); hResult = false; printf("the error while reading error is %dl\n", error); break; } } while(dwIncommingReadSize > 0); *readData = new char[dwSize]; strcpy(*readData, sb.c_str()); return hResult; } else { return hResult; } } the program just goes to wait mode in the WaitCommEvent function, even when i send a file via bluetooth from my mobile it does'nt reads and while iam sending the file the bluetooth pops the message that PIM transfer is happining, how to send file serial so that my read function should read the data and store in a file......

    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