单片机控制GPS/GSM原理(虚拟串口)
SMSdeal Instring
Sleep (100)
If InStr(Instring, "OK") Then
MsgBox "成功读取第" + index.Text + "条信息!", vbOKOnly, "系统提示"
Else
MsgBox "该信息为空!", vbOKOnly, "系统提示"
End If
Instring = ""
End If
If Mobcomm.PortOpen = True Then
Mobcomm.PortOpen = False
myActiveX.Active = True
End If
End Sub
Private Function SMSdeal(SMS As String)
On Error Resume Next
Dim SM As String
Dim SN As String
Dim STIME As String
Dim SMG As String
Dim SLONG, N As Integer
If InStr(SMS, "0891") Then
SM = Mid(SMS, InStr(SMS, "0891"))
SN = ConTelc(Mid(SM, 25, 14))
STIME = ConTimec(Mid(SM, 43, 14))
SLONG = CInt(Mid(SM, 57, 2))
N = SLONG * 4
SMG = Unicode2AscII(Mid(SM, 59, N))
rmsg.Text = " 短信类型: " + "已读信息" + vbCr + vbLf + " 对方号码: " + SN + vbCr
+ vbLf + " 发送时间: " _
+ STIME + vbCr + vbLf + " 短信长度: " + Str(SLONG / 2) + "字节" + vbCr +
vbLf + " 信息内容:" + SMG + vbCr + vbLf
ElseIf InStr(SMS, "018") Then
SM = Mid(SMS, InStr(SMS, "018"))
SLONG = CInt(Mid(SM, 17, 2))
N = SLONG * 4
SMG = Unicode2AscII(Mid(SM, 19, N))
rmsg.Text = " 短信类型: " + "存储信息" + vbCr + vbLf + " 信息内容:" + SMG + vbCr
+ vbLf
End If
End Function
Private Sub rpb_Click()
myActiveX.ReadPhoneBook "1", myActiveX.PhoneBookCount
End Sub
Private Sub Timer1_Timer()
Dim buf As String
If Mobcomm.InBufferCount > 0 Then
Timer1.Enabled = False
Mobcomm.InputLen = 0
buf = Mobcomm.Input
If InStr(buf, "OK") = 0 Then
MsgBox "端口打开有误!" & tl
End If
End If
End Sub
Private Sub Timer2_Timer()
If Mobcomm.InBufferCount > 0 Then
MsgBox "你有新的信息,请查收!"
If IntChk$ = vbOK Then
Mobcomm.InputLen = 0
buf$ = Mobcomm.Input
Timer2.Enabled = False
remsg$ = StrConv(buf, vbFromUnicode)
DebugText remsg 信息显示函数
End If
End If
End Sub
Private Sub DebugText(Str) 设定输出格式
rmsg.Text = rmsg.Text + Str + Chr(13) + Chr(10) 输出消息
SendMessage rmsg.hwnd, EM_LINESCROLL, 0, 1 向下卷行
End Sub
Private Sub myActiveX_OnNewSMS(ByVal ReadState As String, ByVal sDateTime
As String, ByVal sNum As String, ByVal sText As String, ByVal sSCA As
String)
收到新消息
DebugText "================= 收到新消息 ==================="
DebugText "时间日期: " + sDateTime
DebugText "电话号码: " + sNum
DebugText "消息内容: " + sText
DebugText "================================================"
MsgBox "收到新消息:" + sNum
End Sub
Private Sub myActiveX_OnPhoneBookList(ByVal PhoneBook As String)
phbook.Text = PhoneBook 显示电话本内容
End Sub
Private Sub Portopen_Test() 打开端口并测试
If Mobcomm.PortOpen = False Then
Mobcomm.CommPort = True
End If
Mobcomm.Output = "AT" + vbCr
Timer1.Enabled = True
End Sub
单片机控制GPSGSM虚拟串 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)
