在串口上反复发送数据 [英] Sending data repeatedly on serial port

查看:82
本文介绍了在串口上反复发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在指定的时间后将不同的数据包发送到串行端口.我现在可以发送和接收单个字符串.例如,让A,B,C为三个字符串.首先,我发送A,然后在时间"x"之后发送B,然后在时间"y"之后发送C,在时间"z"之后再次发送A .....依此类推. br/>
不使用睡眠怎么办?
另外SetTimer函数以固定间隔触发.如何像我的示例一样以不规则间隔触发呢?
任何帮助.

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.

推荐答案

您可以使用计时器

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

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


这将使您以1ms的分辨率设置持续时间(尽管通常不会接近该精度).

希望这对您有所帮助:thumbsup:
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:


这篇关于在串口上反复发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆