操作系统  办公  实用知识  设计  开发  WEB开发  移动开发  数据库  软件工程  网管  安全  管理  信息化  答疑  渠道 

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

2006-9-20 网友评论 0 条 点击进入论坛

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)

已有 0 位对此文章感兴趣的网友发布了看法    
我来评两句 用户名: 密码:
  匿名发表
今日推荐
技术文库(共有 46294 篇文章)
操作系统
办公软件
实用知识
网络管理
软件开发
WEB开发
软件工程
数据库
设计在线
信息安全
行业信息化
管理信息化
移动开发
重点推荐
电子杂志订阅
点击电子杂志名称查看样刊
输入E-mail地址即可订阅
E-mail