在向控制器发送字节之间添加5ms的延迟 [英] Adding a 5ms delay in between sending bytes to a controller

查看:84
本文介绍了在向控制器发送字节之间添加5ms的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在发送到控制器的字节之间添加5ms的延迟?

我必须总共发送6个字节但是在每个字节之间我需要

有5ms的延迟。

解决方案

cmdolcet69写道:


如何在发送到控制器的字节之间添加5ms的延迟?

我必须总共发送6个字节但是在每个字节之间我需要

有一个5ms延迟。



我想你可以使用Thread.Sleep(5)。


所以你是代码看起来像是:


SendByteOne()

Thread.Sleep(5)

SendByteTwo()

Thread.Sleep(5)

SendByteThree()

Thread.Sleep(5)


等...


参见
http://msdn2.microsoft.com/en-us/lib ... ead.sleep.aspx


干杯,


RB。


< blockquote> 9月20日上午10:55,RB< owmdkbqziki ... @ mailinator.comwrote:


cmdolcet69写道:


如何在发送到控制器的字节之间添加5ms的延迟?

我必须总共发送6个字节但是在每个字节之间我需要

有5毫秒的延迟。



我认为你可以使用Thread.Sleep(5)。


所以你的代码看起来像:


SendByteOne()

Thread.Sleep(5)

SendByteTwo()

线程.Sleep(5)

SendByteThree()

Thread.Sleep(5)


等...


Seehttp://msdn2.microsoft.com/en-us/library/system.threading.thread.slee ...


干杯,


RB。



RB,我正在思考正确的道路。我一直在阅读

,它可能是草率的编码.....反正....我怎么能写它是我

使用这个延迟与每个字节我从com.ouput命令发送对象


示例:com.output =(byte(1)+ thead.sleep(5)+ byte(2)+ ..... ..


?????


cmdolcet69写道:


9月20日上午10:55,RB< owmdkbqziki ... @ mailinator.comwrote:


> cmdolcet69写道:


>>如何在发送到控制器的字节之间添加5ms的延迟?
我必须总共发送6个字节我需要每个字节延迟5ms。


我认为你可以使用Thread.Sleep(5)。

所以你' '代码看起来像:

SendByteOne()
Thread.Sleep(5)
SendByteTwo()
Thread.Sleep(5)
SendByteThree ()
Threa d.Sleep(5)

等......

Seehttp://msdn2.microsoft.com/en-us/library/system.threading.thread.slee。 ..

干杯,

RB。



RB,我正在思考正确的道路。我一直在阅读

,它可能是草率的编码.....反正....我怎么能写它是我

使用这个延迟与每个字节我从com.ouput命令发送对象


示例:com.output =(byte(1)+ thead.sleep(5)+ byte(2)+ ..... ..


?????



您可以使用类似的东西:


Dim i as integer

For i = 1 to 6

com.output = byte(i)

Thread.Sleep( 5)

下一页我想知道这会导致每个字节发送至少5 ms延迟。

may更长 - 这会导致问题吗?


干杯,


RB。


How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.

解决方案

cmdolcet69 wrote:

How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.

I think you can just use Thread.Sleep (5).

So you''re code would look like:

SendByteOne()
Thread.Sleep (5)
SendByteTwo()
Thread.Sleep (5)
SendByteThree()
Thread.Sleep (5)

etc...

See
http://msdn2.microsoft.com/en-us/lib...ead.sleep.aspx

Cheers,

RB.


On Sep 20, 10:55 am, RB <owmdkbqziki...@mailinator.comwrote:

cmdolcet69 wrote:

How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.


I think you can just use Thread.Sleep (5).

So you''re code would look like:

SendByteOne()
Thread.Sleep (5)
SendByteTwo()
Thread.Sleep (5)
SendByteThree()
Thread.Sleep (5)

etc...

Seehttp://msdn2.microsoft.com/en-us/library/system.threading.thread.slee...

Cheers,

RB.

RB, I was on the right path in thinking. I have been reading however
that it may be sloppy coding.....anyways.... how can i write it were i
use this delay with each byte i send across from a com.ouput command

example: com.output= (byte(1) + thead.sleep(5) + byte(2)+.......

?????


cmdolcet69 wrote:

On Sep 20, 10:55 am, RB <owmdkbqziki...@mailinator.comwrote:

>cmdolcet69 wrote:

>>How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.

I think you can just use Thread.Sleep (5).

So you''re code would look like:

SendByteOne()
Thread.Sleep (5)
SendByteTwo()
Thread.Sleep (5)
SendByteThree()
Thread.Sleep (5)

etc...

Seehttp://msdn2.microsoft.com/en-us/library/system.threading.thread.slee...

Cheers,

RB.


RB, I was on the right path in thinking. I have been reading however
that it may be sloppy coding.....anyways.... how can i write it were i
use this delay with each byte i send across from a com.ouput command

example: com.output= (byte(1) + thead.sleep(5) + byte(2)+.......

?????


You could use something similar to :

Dim i as integer
For i = 1 to 6
com.output = byte(i)
Thread.Sleep(5)
Next i

Be aware that this will cause AT LEAST a 5 ms delay per byte sending. It
may be longer - would this cause an issue?

Cheers,

RB.


这篇关于在向控制器发送字节之间添加5ms的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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