如何接收命令的输出 [英] How to received output of at command

查看:84
本文介绍了如何接收命令的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友..

如何收到at命令的输出。



这是我的表格< a href => http://prntscr.com/2tkrzz [ ^ ]



这是我的代码



hi friends..
How to received output of at command.

this my form http://prntscr.com/2tkrzz[^]

this my code

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, btnRefresh.Click
        PortList.Items.Clear()

        For Each a As String In My.Computer.Ports.SerialPortNames 'collecting available port
            PortList.Items.Add(a)
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        If btnConnect.Text = "CONNECT" Then 'opeing port
            If SerialPort1.IsOpen Then
                SerialPort1.Close()
            End If
            Try
                With SerialPort1
                    .PortName = PortList.Text
                    .BaudRate = 115200
                    .ReadBufferSize = 500
                    .Parity = IO.Ports.Parity.None
                    .DataBits = 8
                    .StopBits = IO.Ports.StopBits.One
                    .Handshake = IO.Ports.Handshake.None
                End With
                SerialPort1.Open()
                btnConnect.Text = "DISCONNECT"
                PortList.Enabled = False
                With lblStatus
                    .Text = "Connected"
                    .ForeColor = Color.Green
                End With
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else 'closing port
            Try
                SerialPort1.Close()
                btnConnect.Text = "CONNECT"
                PortList.Enabled = True
                With lblStatus
                    .Text = "Not Connected"
                    .ForeColor = Color.Red
                End With
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If

    End Sub
    Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        Try
            SerialPort1.Close() 'closing serial port
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If UssdInput.Text.Length < 1 Then Exit Sub
        Try
            SerialPort1.WriteLine("AT+CUSD=1," & Chr(34) & UssdInput.Text & Chr(34) & ",15" & vbCrLf) 'send at command
        Catch ex As Exception
            MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

End Class

推荐答案

嗨Jhony,



您只需要在通过com端口写入命令后使用serialport obj调用Readexisting()方法。

例如在C#中: -

serialport1.readexisting();



欲了解更多信息,请查看上述方法。





Warm Reagrds,

热情的编码器。
Hi Jhony,

You just need to call the Readexisting() method with your serialport obj after writing command over com port.
e.g. IN C# :-
serialport1.readexisting();

For more info have a look over the above method.


Warm Reagrds,
passionate coder.


这篇关于如何接收命令的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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