串口连接-Beginner需要帮助 [英] Serial port Connection -Beginner help needed

查看:46
本文介绍了串口连接-Beginner需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WIN CE的初学者,

我在以下环境中开发应用程序

获得CE 6.0版视觉基础
.net 2.0


我尝试创建一个与GSM调制解调器通信的应用程序,

SerialPort1.Open()
如果(SerialPort1 .IsOpen)然后

MsgBox(SerialPort1.PortName)
SerialPort1.WriteLine(" AT" + vbCrLf)

MsgBox(SerialPort1.ReadExisting())
SerialPort1.Close()
如果我已经添加了一个串口对象,当我尝试打开并写入一些AT命令时,该应用程序冻结,我有重启电路板
我无法从GSM调制解调器得到答复
请回复,恭谢

解决方案

在上面提到的方法中,您没有包含要打开的端口名称。<首先声明端口名称(例如"COM1"或"COM2")。等等)。然后打开它,然后发送你想要的at命令。假设您有名为SRPort的serialport组件,请执行以下操作:


SRPort.PortName =" COM2"    '假设您的GSM调制解调器连接到COM2端口。


SRPort.Open()


'端口现已打开。


现在您可以向调制解调器发送AT命令。


要了解有关AT命令的更多信息,请单击以下链接:


http://en.wikipedia.org/wiki/Hayes_command_set


 如果适合您,请分享您的结果。


Hi ,
iam a beginner in  WIN CE,

Iam developing Application in the following Environment

WIN CE 6.0
Visual basic
.net 2.0


Iam trying to create an Application which communicates with  a GSM modem,

 SerialPort1.Open()
        If (SerialPort1.IsOpen) Then

            MsgBox(SerialPort1.PortName)
            SerialPort1.WriteLine("AT" + vbCrLf)

            MsgBox(SerialPort1.ReadExisting())
            SerialPort1.Close()
End if

i have added a serial port object and when i try to open  and write some AT Commands
The Application freezes,I have to restart the Board
Iam not able to get the response from the GSM modem
Kindly Reply,
Thanks


解决方案

In the method mentioned above you have no where included the port name to be opened.

First declare the port name(e.g. "COM1" or "COM2" etc). then open it, and then send the at commands you want. Suppose you have serialport component named as SRPort then do it as follows:

SRPort.PortName="COM2"    ' Assuming that your GSM modem is connected to COM2 port.

SRPort.Open()

' The port is now open.

Now you can send AT commands to the modem.

To learn more about AT commands click the link below:

http://en.wikipedia.org/wiki/Hayes_command_set

 Please share your result if it works for you.


这篇关于串口连接-Beginner需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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