谁帮我编个程序,VB的仪表测量

来源:百度知道 编辑:UC知道 时间:2024/07/01 07:36:35
本协议适用于计算机与压力测量仪间的RS-232串口通讯,通信速率2400bps。
先接受计算机发出读取数据命令:55H,然后仪表发送数据, 本机发送格式如下:
AA(前导码,当作数据串的起始识别字节)+出口压力符号(1字节,等于0为正,等于1为负)+出口压力(五字节BCD码高字节在前)+07H(小数点位置)+进口压力符号(1字节,等于0为正,等于1为负)+进口压力数值(5字节BCD码高字节在前)+07H(小数点位置)+校验和(1字节)
所有数据均为16进制,共16字节。
举例说明:
如计算机接收到数据AA 00 00 01 23 45 67 07 01 00 01 23 45 67 07 BC
代表出口压力0.1234567兆帕,进口压力-0.1234567兆帕
如计算机受到数据AA 01 00 12 34 56 78 07 00 00 12 34 56 78 07 BC
代表出口压力:-1.2345678兆帕,进口压力:1.2345678兆帕
注意:计算机一次发送55h,如收不到可多发几次。

谁帮我编个程序~

代码未考虑校验和:
Option Explicit
Dim strdata As String
Dim bytInput() As Byte
Dim sj(1) As Double
Dim sjData(1) As String
Dim xswz As Integer
Dim xswz1 As Integer

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub MsComm1_OnComm()
Dim intInputLen As Integer
Select Case MSComm1.CommEvent
Case comEvReceive
'接收代码
While MSComm1.InBufferCount
intInputLen = MSComm1.InBufferCount
ReDim bytInput(intInputLen)
bytInput = MSComm1.Input
jieshou
'数据处理
If Mid(strdata, 1, 2) = "AA" And Len(strdata) = 32 Then
Dim j As Integer
Dim binsj As Integer
'For j = 1 To Len(strdata) - 2 Step 2
&