-
Trouble with timer
Hi everybody !
The purpose is to manage serial communication with a pedal.
I wrote a class pedal that allows to search for the serial port on which the pedal is connected. Therefore I send a request to the pedal and set up a timer event of 20 ms. If no reply, I search for the next serial port.
When found I send configuration to the pedal and set another timer event of 200 ms that requests for pedal state.
It runs fine.
Now if the pedal is disconnected then connected again I would like it to run again.
Therefore I set another timer event every 2s that launches all what I described above.
The trouble comes because the 20 ms timer event doesn't run and I do not understand why.
Thanks.
-
Re: Trouble with timer
You'll probably get more/better help if you post the code of a minimally complete example that shows your problem.
-
Re: Trouble with timer
Please see the code written on the thread with same title below
-
Re: Trouble with timer
If you are talking about WM_TIMER type timers.
1) The time you specify only guarantees that you will get a timer message NO SOONER THAN the interval you specify, there is no guarantee of actual interval precision.
2) The system does not actually generate timer messages, it merely sets a flag. Your application needs to process messages via the PeekMessage/GetMessage type functions to actually generate a WM_TIMER message (this is similar to how WM_PAINT's arrive in your application).
3) Even if you use the callback function variant of the timer, your application needs to be processing messages to receive the callbacks.