Sign in to follow this  

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

This topic is 4593 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

This topic is 4593 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this