在VC中怎么将一个数组中的数据通过串口发送?
一个数组中存储了一些数据,要求是每200ms左右发送数组中的5个数据,数据都是整形的,该怎么写程序啊,求教大神!...
一个数组中存储了一些数据,要求是每200ms左右发送数组中的5个数据,数据都是整形的,该怎么写程序啊,求教大神!
展开
2个回答
展开全部
转换成一个CString对象,操作串口发送就行了啊,200ms用定时器就行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim cycle(1 To 4) As String
Dim i As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
MSComm1.Settings = "9600,n,8,1"
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
cycle(1) = "#4p1900"
cycle(2) = "#4p1600"
cycle(3) = "#4p1800"
cycle(4) = "#4p1400"
End Sub
Private Sub Timer1_Timer()
i = i + 1
MSComm1.Output = cycle(i)
If i >= 4 Then
i = i - 4
End If
End Sub
Dim i As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
MSComm1.Settings = "9600,n,8,1"
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
cycle(1) = "#4p1900"
cycle(2) = "#4p1600"
cycle(3) = "#4p1800"
cycle(4) = "#4p1400"
End Sub
Private Sub Timer1_Timer()
i = i + 1
MSComm1.Output = cycle(i)
If i >= 4 Then
i = i - 4
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询