序列问题 [英] Serial problems

查看:60
本文介绍了序列问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想编写一个简单的程序,该程序从文本框中获取AT指令(用于调制解调器和手机的那些指令),然后将其告诉我的手机. m使用与蓝牙连接.如果我使用超级终端,则当我键入ATDxxxxxxxx
时,电话会拨打该号码xxxxxxxx.

这与我的代码不兼容,我在这里写:

SerialPort myPort =新的SerialPort("COM6",9600,Parity.None,8,StopBits.One);

myPort.Open();//此时,我的手机请求连接,我接受

myPort.WriteLine(textbox.Text);
//在此行之后(如果命令为ATDxx),电话应拨打xx,为什么不拨打?为什么?

//在这一点上,如果命令需要答案,我应该收到它.我什么也没收到
//如果在这里写myPort.ReadLine()我得到一个错误,如果我使用ReadExisting()
///readbuffer中没有数据

myPort .Close();


我是通过串行链接还是仅在写缓冲区中编写命令?看来我的命令没有进入链接!

请帮助我!

谢谢

Hi there, I'd like to make a simple program that takes an AT Command (those command for modems and cell phones) from a textbox and then tell it to my mobile.

The cellphone I'm using is connected with bluetooth. If i use HyperTerminal, when i type ATDxxxxxxxx
the phone makes a call to the number xxxxxxxx.

This doesn't work with my code, that i write here:

SerialPort myPort = new SerialPort ("COM6", 9600, Parity.None, 8, StopBits.One);

myPort.Open();
// at this point my cellphone asks for a connection and I accept

myPort.WriteLine(textbox.Text);
// after this line (if the command is ATDxx) the phone should make a call to xx, why doesn't it??

// in this point, if the command needs an answer, I should receive it. I don't receive anything
// if I write here myPort.ReadLine() I get an error, if I use ReadExisting()
// there is no data in the readbuffer

myPort.Close();


Am I writing the command through the serial link or in the write buffer only? It seems like my commands don't go in the link!!

please HELP ME!!!

thank you

推荐答案

如果我回想起使用1200波特调制解调器的日子,在调制解调器获得线路终止符(CR或CR/LF,不确定是哪一个)之前,不会执行AT命令.

If I remember back from my days using 1200 baud modems, AT commands are not executed until the modem gets a line terminator (CR, or CR/LF, not sure which).

现在,您正在使用WriteLine,它应该发出新的换行符.但是,我进行了一些查找,默认情况下,换行符似乎仅是换行符.我确定这不是正确的终止符.如果你 按下超级终端上的回车键,我确定您得到的是CR或CR/LF,这可以解释为什么它不起作用.

Now you are using WriteLine which SHOULD issue a new line character.  However, I did some poking around and it seems that the newline character, by default, is a linefeed only.  I am certain that this is NOT the correct terminator.  If you hit the return key on hyperterminal, I'm sure you either get a CR or CR/LF which would explain why this is not working.

使用Write方法代替尝试以下操作:

Using the Write method instead try the following:

myPort.Write(textbox.Text +"\ r");

myPort.Write(textbox.Text + "\r");

或者,尝试:

myPort.Write(textbox.Text +"\ r \ n");

myPort.Write(textbox.Text + "\r\n");

希望这会有所帮助.


这篇关于序列问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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