Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to different data packets to serial port after specified amounts of time. I can send and receive a single string presently. For example let A, B, C be three strings. First I send A, then after time 'x' I send B, then after time 'y' I send C, after time 'z' I again send A..... and so on.

How can I do this without using Sleep?
Also SetTimer function is triggered in regular intervals.how do i make it trigger at irregular intervals as in the case of my example??
Any help plz.
Posted
Updated 23-Jun-10 18:58pm
v4

1 solution

You can use a Timer

See SetTimer:-
http://msdn.microsoft.com/en-us/library/49313fdf(VS.80).aspx[^]

and OnTimer:-
http://msdn.microsoft.com/en-us/library/fy1hkbdk(VS.80).aspx[^]


This will allow you set durations with a resolution of 1ms (although it will generally not be anywhere near that accurate).

Hope this helps :thumbsup:
 
Share this answer
 
Comments
Gautam Raiker 23-Jun-10 23:59pm    
How can i make SetTimer to trigger just once?
LittleYellowBird 24-Jun-10 4:55am    
When the Timer completes (ie OnTimer) use KillTimer to stop it. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900