如何用Mscomm控件检测(联接、挂断)

1、怎么用mscomm控件检测modem是否与计算机联接正确?
 
2、如何用mscomm挂断modem与别的电话机间的连接?(已接通)
3、怎么用mscomm控件检测modem是否与计算机联接正确?

4、如何用mscomm挂断modem与别的电话机间的连接?(已接通)

连接


我记得MODEN连接好了可以接受串口的信号,比如,你发送AT,应该返回OK,有的时候则返回AT,说明是连上了的

Function ModenSeach(com As Integer, Default As String) As String
Dim a As String
On Error GoTo aa:
MSComm.CommPort = com
MSComm.InputMode = comInputModeBinary
MSComm.Settings = "9600,n,8,1"
If MSComm.PortOpen = True Then
MSComm.PortOpen = False
End If
MSComm.DTREnable = True
MSComm.EOFEnable = True
MSComm.RTSEnable = True
MSComm.PortOpen = True
MSComm.Output = "at"
a = EcrReadOne(2): a = LCase(a)
If InStr(a, "at") <> 0 Or InStr(a, "ok") <> 0 Then
ModenSeach = "Moden"
Else
ModenSeach = Default
End If
Exit Function
aa:
ModenSeach = Default
'EndTransmit
End Function

Function EcrReadOne(number As Integer) As String
Dim out() As Byte, i As Integer, data As String

data = "": i = 1
Do
DoEvents: i = i + 1
Debug.Print MSComm.InBufferCount
Loop Until (MSComm.InBufferCount >= number Or i >= 800) ' one plu item read
If i >= 800 Then
EcrReadOne = ""
Exit Function
End If
out() = MSComm.Input
For i = 1 To number
data = data + Chr(out(i))
Next
EcrReadOne = Trim(data)
End Function

posted @ 2007-02-25 01:32  么么茶.NET  阅读(607)  评论(2编辑  收藏  举报