Jump to content
  • Advertisement
Sign in to follow this  
Samurai Jack

Serial Port (Com Port) C++ on Event...

This topic is 4756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings! I am writing an application with a touch pad connected to a com port (Serial Port RS232) in C++. The thing is, I would like an endless loop (inerrupted by kbhit), but I would like to know when signals come through start reading, not like now, I am constantly reading buffer from Com prot and if there are non zero values, we have transfer. Souch function works, but i can believe there isn't any function out there which would tell me i got transfer? I tried WaitCommEnvet and nothing happnes... Current stage: <code> while(1) { memset(Read_Buffer, 0, 4096); ReadFile(hCom, Read_Buffer, 1, &dwBytesRead, NULL); if (Read_Buffer[0] != 0) printf("Com event!\n"); if (kbhit()) break; } </code> I would like something like this: <code> while (1) { If (WaitCommEvent(hCom, 0, 0)) { printf("Com event!\n"); memset(Read_Buffer, 0, 4096); ReadFile(hCom, Read_Buffer, 4096, &dwBytesRead, NULL); } if (kbhit()) break; } </code> Thank you in advance!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!