如何通过AT命令发送短信? [英] how can send sms by AT Command?

查看:91
本文介绍了如何通过AT命令发送短信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

串口的asp.net有问题吗?

它的工作原理是在vb.net而不是asp.net

请我烦恼。

但是当我连接它时我有开放端口你可能会看到这个代码

is there problem in asp.net of serial port?
its works in vb.net not in asp.net
please i am troubling.
but i have open port when i connect it you may see this code

Try
            With SerialPort1
                .PortName = ComboBox1.Text
                .BaudRate = 9600
                .Parity = Parity.None
                .StopBits = StopBits.One
                .DataBits = 8
                .Handshake = Handshake.RequestToSend
                .DtrEnable = True
                .RtsEnable = True
                .NewLine = vbCrLf
                .Open()
               txtbox.text=("Connected")


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

        End Try



然后我在尝试发送短信时使用这个


then i use this when try to send sms

Try
            If SerialPort1.IsOpen Then
                With SerialPort1
                    .Write("AT" & vbCrLf)
                    .Write("AT+CMGF=1" & vbCrLf)
                    .Write("AT+CMGS=" & Chr(34) & TextBox1.Text & Chr(34) & vbCrLf)
                    .Write(RichTextBox1.Text & Chr(26))
                    MsgBox("sms Sent")

                End With
            Else
               txtbox.text=("ERROR MSG ON PORT")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try







i我遇到问题请帮助我,如果有人可以请

它在vb中炒作。 net应用程序但不能在带有vb.net的asp.net中帮助我

它就在这里

txtbox.text =(ERROR MSG ON PORT)




i am getting problem please help me if any one can please
it woks in vb.net Application but not in asp.net with vb.net please help me
it just goes here
txtbox.text=("ERROR MSG ON PORT")

推荐答案

您可能无法正确理解ASP.NET的工作原理 - 它与Windows应用程序非常不同。



因为你说你收到消息ERROR MSG ON PORT,这意味着它没有通过IsOpen测试 - 这意味着Open方法要么没有被调用,要么尝试打开n失败了。由于您在VB代码中使用MsgBox(在服务器上运行而不是客户端),用户根本不会看到任何错误消息!它们会显示在服务器上,可能会让你的网络主机管理员烦恼。



我怀疑你正在做第一块代码是与第二种方法不同的方法,当您第一次打开页面时,或者在完全不同的页面时调用它。使用可运行的Windows应用程序,因为应用程序在整个持续时间内都处于活动状态,用户可以看到表单。对于网站而言,情况并非如此,当处理页面事件时,您在页面中创建的数据在加载时将被丢弃,并且将再次关闭打开的串行端口。当用户输入他想要发送的号码和数据时,原始的串口实例不再可用,你得到一个未打开的新的。



试试这个:合并这两段代码,这样就是端口没有打开它试图立即执行,并将显示的MsgBox调用替换为txtbox.Text,这样用户就有机会看到任何错误。



这可能会在短期内解决您的问题,但从长远来看,这段代码可能无法正常运行:只有一个调制解调器可以发送消息,而且互联网同时涉及多个用户 - 你不能让调制解调器同时做两件事!
The chances are that you don't properly understand how ASP.NET works - it is very different to a Windows application.

Since you say you are getting the message "ERROR MSG ON PORT", that implies it is failing the IsOpen test - which implies that the Open method either hasn't been called, or the attempt to open failed. Since you are using MsgBox in your VB code - which runs on the Server, not the Client - the user will not see any error messages at all! They will show up on the server, and probably annoy the heck out of your web host administrator.

What I suspect is that you are doing the first chunk of code is a different method to the second, and that it is being called when you open the page for the first time, or with a different page altogether. With a Windows app that will work, because the application is alive for the entire duration that the user can see the forms. This is not the case with a web site, where the data you created in a page when it is loaded is thrown away when the page events have been handled, and an open serial port will be closed again. When you user enters the number and data he wants to send, the original serial port instance is not longer available and you get a new, unopened one.

Try this: amalgamate the two pieces of code, so that is the port is not open it tries to do it immediately, and replace the MsgBox calls with a display to txtbox.Text instead so the user stands a chance of seeing any errors.

It may fix your problem in the short term, but in the long term, this code probably is not going to work well: there is only one modem to send the messages, and the internet is all about multiple users at the same time - your can't make the modem do two things at the same time!


这篇关于如何通过AT命令发送短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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