在vb.net中写入超时错误到gsm modem send / rec sms apps sirs, [英] write timeout error in vb.net to gsm modem send/rec sms apps sirs,

查看:84
本文介绍了在vb.net中写入超时错误到gsm modem send / rec sms apps sirs,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

我按下此程序的发送按钮时遇到写入超时错误。请帮忙。其代码如下:

sirs,
i have a write timeout error encountered during i press the send button of this program. please help.here's the code:

Imports System
Imports System.IO.Ports
Imports System.Threading

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            Dim ports As String() = SerialPort.GetPortNames
            Dim port As String
            For Each port In ports
                CBCOMPORT.Items.Add(port)
            Next port
            CBCOMPORT.SelectedIndex = 0

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub BTNconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNconnect.Click
        Try
            With SerialPort1
                .PortName = CBCOMPORT.Text
                .BaudRate = 9600
                .Parity = Parity.None
                .StopBits = StopBits.One
                .Handshake = Handshake.RequestToSend
                .DataBits = 8
                .DtrEnable = True
                .RtsEnable = True
                .NewLine = vbCrLf
                .Open()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try

    End Sub

    Private Sub Btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSEND.Click
        Try

            If SerialPort1.IsOpen Then
                With SerialPort1

                    .Write("AT" & vbCrLf)
                    .Write("AT+CMGF=1" & vbCrLf)
                    .Write("AT+CMGS=" & Chr(34) & TBCPNUM.Text & Chr(34) & vbCrLf)
                    .Write(RTBMESSAGE.Text & Chr(26))
                    MsgBox("SENT MESSAGE")

                End With
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
      
    End Sub
End Class

推荐答案

华友世纪! !这是一个非常好的主意兄弟。但我建议您尝试阅读GSM MODEM制造商的文档,因为不同的MODEM解释AT命令(在您的情况下AT + CMGF = 1)不同。其次尝试使用预先安装了Windows XP的超级终端来尝试手动编写错误,然后移动那个(AT命令),它适用于您的VB.NET代码和BOOM,你就是这么做的。



很棒的工作!!!!!!!!!!!
Hurray!!! that was a very good idea bro. But i will advice that you try reading the documentation of your GSM MODEM manufacturer because different MODEM interpret AT command (That in your case AT+CMGF=1) differently. Secondly try using Hyper Terminal that comes pre-installed with windows XP to try and write the errors manually then move that (AT Commands) which works for you to your VB.NET code and BOOM you just did it.

Great Work!!!!!!!!!!!


这篇关于在vb.net中写入超时错误到gsm modem send / rec sms apps sirs,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆