关于VB串口接收温湿度数据的问题 10
图为DTH11湿度传感器串口通信部分的C程序我用VB写了一个串口接收此传感器温湿度数据的界面,但是好像接收不到数据总是没能在listbox中显示出数据来,希望各位高手大神...
图为DTH11湿度传感器串口通信部分的C程序
我用VB写了一个串口接收此传感器温湿度数据的界面,但是好像接收不到数据总是没能在listbox中显示出数据来,希望各位高手大神能帮我指点一下哪里有问题
其中串口事件如下:
Private Sub MSComm1_OnComm() Dim recv() As Byte Dim recv_data As String Dim recv_buf As String Dim n As Integer Dim stmCon As New Stream Dim j As Integer counter = counter + 1 Text2.Text = CStr(counter) Select Case MSComm1.CommEvent Case comEvReceive MSComm1.RThreshold = 0 n = MSComm1.InBufferCount ReDim recv(n) MSComm1.InputLen = n recv = MSComm1.Input For i = 0 To n - 1 recv_buf = Hex(recv(i)) recv_data = recv_data + recv_buf Next i recv_buf = "" recv_buf = CStr(Time) + "的温度是" + Left(recv_data, 3) + "." + Right(recv_data, 1) + "℃" List1.AddItem recv_buf Case comEventRxOver List1.Clear Text2.Text = "" Case comEventTxFull List1.Clear Text2.Text = "" End Select MSComm1.RThreshold = 1End Sub 展开
我用VB写了一个串口接收此传感器温湿度数据的界面,但是好像接收不到数据总是没能在listbox中显示出数据来,希望各位高手大神能帮我指点一下哪里有问题
其中串口事件如下:
Private Sub MSComm1_OnComm() Dim recv() As Byte Dim recv_data As String Dim recv_buf As String Dim n As Integer Dim stmCon As New Stream Dim j As Integer counter = counter + 1 Text2.Text = CStr(counter) Select Case MSComm1.CommEvent Case comEvReceive MSComm1.RThreshold = 0 n = MSComm1.InBufferCount ReDim recv(n) MSComm1.InputLen = n recv = MSComm1.Input For i = 0 To n - 1 recv_buf = Hex(recv(i)) recv_data = recv_data + recv_buf Next i recv_buf = "" recv_buf = CStr(Time) + "的温度是" + Left(recv_data, 3) + "." + Right(recv_data, 1) + "℃" List1.AddItem recv_buf Case comEventRxOver List1.Clear Text2.Text = "" Case comEventTxFull List1.Clear Text2.Text = "" End Select MSComm1.RThreshold = 1End Sub 展开
1个回答
2015-03-09
上海巴鲁图工程机械科技有限公司_
2022-05-15 广告
2022-05-15 广告
绝对脉冲编码器编码器两者一般都应用于速度控制或位置控制系统的检测元件. 旋转编码器是用来测量转速的装置。它分为单路输出和双路输出两种。技术参数主要有每转脉冲数(几十个到几千个都有),和供电压等。单路输出是指旋转编码器的输出是一组脉冲,而双路...
点击进入详情页
本回答由上海巴鲁图工程机械科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询