上端位VB编程实现和下位机FPGA的串口通信问题
FUSION系列FPGA有32个通道,现有2种通信协议:一是指定哪个通道发送数据就哪个通道发送,二是按通道的顺序循环发送数据,发送的间隔为100MS。要做的事情是先用VB做一个界面,然后编程实现上面的协议,请求高手相助~!
[解决办法]
第一个问题,按Byte(字节)流发送2进制数据。
第二个问题,用Timer控件控制发送间隔。
Option Explicit Dim bytSj(0) As Byte Dim i As IntegerPrivate Sub Command1_Click() Timer1.Enabled = TrueEnd SubPrivate Sub Form_Load() MSComm1.CommPort = 1 MSComm1.Settings = "9600,n,8,1" MSComm1.PortOpen = True Timer1.Enabled = False Timer1.Interval = 100End SubPrivate Sub Timer1_Timer() i = i + 1 If i = 1 Then bytSj(0) = &H80 MSComm1.Output = bytSj ElseIf i = 2 Then bytSj(0) = &H88 MSComm1.Output = bytSj ElseIf i >= 3 Then bytSj(0) = &H8 MSComm1.Output = bytSj i = i - 3 Timer1.Enabled = False End IfEnd Sub