我想使用SetCommBreak and ClearCommBreak操作串口实现一个中断信号(在频谱仪上可以看到Txd产生约800毫秒的中断),这样才能连结到我的设备上(在超级终端上是按ctrl+break实现的,我通过测量在按ctrl+break时,txd上产生了800毫秒中断)。真的是很急,请哪位英雄帮帮忙

解决方案 »

  1.   

    引用Microsoft Comm Control 控件,然后这样试试看Option ExplicitPrivate Sub cmdSendBreak_Click()
        With MSComm1
            .CommPort = 1
            .PortOpen = True
        End With
        
        Timer1.Enabled = True
        
        MSComm1.Break = True
    End SubPrivate Sub Form_Load()
        Timer1.Enabled = False
        Timer1.Interval = 800 '800ms
    End SubPrivate Sub Timer1_Timer()
        MSComm1.Break = False
        Timer1.Enabled = False
    End Sub
      

  2.   

    我原来也是这样做的,但是mscomm1.input没有任何输入,而我用超级终端执行ctrl+break后点一下空格,或回车就能出现设备选项,我在time1里,设Interval=100
           x = x + 1
           If x = 8 Then
           MSComm1.Break = False
           Timer1.Enabled = False
           End If
           
           If x = 10 Then MSComm1.Output = Chr(13)然后text1_change()中
    text1.text=mscomm1.input丝毫没有反应阿,
    忘老哥再给点指引
      

  3.   

    改If x >= 8 Then,然后你再用个Interval为1的Timer来读取mscomm1.input看看偶这边没有什么设备所以只能这样瞎猜了
      

  4.   

    我把timer1改为:
    Private Sub Timer1_Timer()
           
           x = x + 1
           If x > 8 Then
           MSComm1.Break = False
           MSComm1.Output = " " & Chr(13)
           Text1.Text = MSComm1.Input
           Timer1.Enabled = False
           End If
           
    End Sub我在output下边添加监视,显示属性只写
    监视input,为“”
    :(
      

  5.   

    呵呵,偶是有点无能为力了,你的x是全局变量?
    另外,你可以google一下SetCommBreak的VB代码,应该有的吧
      

  6.   

    楼主 问题解决了么,我也有一样的问题  更麻烦的事,我在超级终端上是按ctrl+break,仪器没有反应。