Private Sub lblDisplaySpeed_Click()
lblDisplaySpeed.Caption = "发送速率为:" & 9600 & "波特率"
Dim i%, Buf$
Buf = ""
InByte = MSComm1.Input
For i = LBound(InByte) To UBound(InByte)
Buf = Buf + InByte(i)
IF InByte(i) = 0x00 THEN
Timer1.Interval = 50
Timer1.Enabled = True
REPEAT
UNTIL (Timer1 > 50 OR New Byte Received)
Case 1 To 4: lblDisplaySpeed.Caption = "发送速率为:" & 600 & "波特率"
Case 5 To 10: lblDisplaySpeed.Caption = "发送速率为:" & 300 & "波特率"
Case 11 To 15: lblDisplaySpeed.Caption = "发送速率为:" & 150 & "波特率"
Case 16 To 22: lblDisplaySpeed.Caption = "发送速率为:" & 110 & "波特率"
Case 23 To 32: lblDisplaySpeed.Caption = "发送速率为:" & 75 & "波特率"
Case 33 To 49: lblDisplaySpeed.Caption = "发送速率为:" & 50 & "波特率"
Else: END CASE;
Else IF InByte(i) >= 0xF1 THEN
lblDisplaySpeed.Caption = "发送速率为:" & 19200 & "波特率"
Else
CASE Byte IN
0 x0D: 9600
0 xE6: 4800
0 x78: 2400
0xE0,0xF0: 1800
0 x80: 1200
ELSE: Line noise; reset
END CASE
END IF■End Sub这是我看到一篇文章上的 但是不知道哪里有错误。
lblDisplaySpeed.Caption = "发送速率为:" & 9600 & "波特率"
Dim i%, Buf$
Buf = ""
InByte = MSComm1.Input
For i = LBound(InByte) To UBound(InByte)
Buf = Buf + InByte(i)
IF InByte(i) = 0x00 THEN
Timer1.Interval = 50
Timer1.Enabled = True
REPEAT
UNTIL (Timer1 > 50 OR New Byte Received)
Case 1 To 4: lblDisplaySpeed.Caption = "发送速率为:" & 600 & "波特率"
Case 5 To 10: lblDisplaySpeed.Caption = "发送速率为:" & 300 & "波特率"
Case 11 To 15: lblDisplaySpeed.Caption = "发送速率为:" & 150 & "波特率"
Case 16 To 22: lblDisplaySpeed.Caption = "发送速率为:" & 110 & "波特率"
Case 23 To 32: lblDisplaySpeed.Caption = "发送速率为:" & 75 & "波特率"
Case 33 To 49: lblDisplaySpeed.Caption = "发送速率为:" & 50 & "波特率"
Else: END CASE;
Else IF InByte(i) >= 0xF1 THEN
lblDisplaySpeed.Caption = "发送速率为:" & 19200 & "波特率"
Else
CASE Byte IN
0 x0D: 9600
0 xE6: 4800
0 x78: 2400
0xE0,0xF0: 1800
0 x80: 1200
ELSE: Line noise; reset
END CASE
END IF■End Sub这是我看到一篇文章上的 但是不知道哪里有错误。
解决方案 »
- 请教一个关于删除元素的问题。
- 现在程序员转行都做什么啊?有没有成功的案例
- 扩展名是 img 的文件用VB是如何读取~~~读取格式是来是统一的~~~高手指点
- 前天写了个可以用来发送多彩色QQ信息的程序,帮帮忙测试一下啦,UP者有分
- 请教关于控件重载问题
- fpspread 控件中,知道列名,如何获取其列号?
- data控件问题(急,帮帮忙)
- 请问sql server97和sql server2000不能在win2000或win xp的professional版上运行吗?
- datareport报表的数据更新
- 小女子有个问题请教?
- 如何将报表打印到指定的打印机(activeReport 2.0)?
- 求一个使用mscomm控件实现串行通讯的程序代码以供参考
原来书上是这样说的各种波特率都可以通过回车符的发送和接收信息来测定,算法实现的伪 代码在本文的最后给出。应用实践证明了这种方法的有效性。
; Pseudo code to determine what baud rate a transmitter is at,on the b asis of a single; RETURN (0x0D) character received from it.Initialise receive baud rate to 9600
Wait for Byte to be received
IF Byte = 0x00 THEN
Start Timer
REPEAT
UNTIL (Timer > 50 ms OR New Byte Received)
CASE Timer IN
1 ms-4 ms: 600 Baud
5 ms-10 ms: 300 Baud
11 ms-15 ms: 150 Baud
16 ms-22 ms: 110 Baud
23 ms-32 ms: 75 Baud
33 ms-49 ms: 50 Baud
ELSE: Timed out; reset
END CASE;
ELSIF Byte >= 0xF1 THEN
19200 Baud
ELSE
CASE Byte IN
0x0D: 9600 Baud
0xE6: 4800 Baud
0x78: 2400 Baud
0xE0,0xF0: 1800 Baud
0x80: 1200 Baud
ELSE: Line noise; reset
END CASE
END IF■
这个Byte是什么类型呢?如果你测试出来了
能不能给个解释 谢谢!