通过诺基亚手机的短信通过串口 [英] Sms via a nokia phone over a serial port

查看:231
本文介绍了通过诺基亚手机的短信通过串口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过诺基亚手机通过串行这是通过腻子很容易发送短信。从诺基亚文档工作正常。

I'm trying to send a sms via a Nokia phone over serial which is easy enough via putty. The commands from the nokia documentation works fine.

不过,试图从C#应用程序发送相同的命令惨遭失败。我已经运行的Sysinternals PortMon,可以查看相应的命令来通过OK,我能看到的唯一的区别是它的方式连接,但我无法找到这将化解这些分歧的命令。

However, trying to send the same commands from a c# application fails miserably. I've run Sysinternals PortMon and can see the commands come through OK, the only difference I can see is in the way it connects but I am having trouble finding the commands that would iron out those differences.

我跑的代码看起来有点像这样

The code I'm running looks a little bit like this

using (SerialPort port = new SerialPort(comPort, 9600, Parity.None, 8, StopBits.One))
    		{
    			port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
    			port.ErrorReceived += new SerialErrorReceivedEventHandler(port_ErrorReceived);

    			//port.ReceivedBytesThreshold = 1;
    			port.DtrEnable = true;
    			port.RtsEnable = true;
    			port.ReadTimeout = 1;
    			port.Handshake = Handshake.XOnXOff;


    			try
    			{
    				port.Open();

    				port.WriteLine("AT");

    				port.WriteLine("AT+CMGF=1");

    				port.WriteLine("AT+CMGS=\"" + number + "\"");

    				port.WriteLine(message);

    				port.Write(new byte[] { (byte)26 }, 0, 1);
    			}
    			finally
    			{
    				if (port.IsOpen)
    				{
    					port.Close();
    				}
    			}



我在跟踪从看到的差异串行端口的

The differences I'm seeing in the trace from the serial port are

在启动

0.00001844  aspnet_wp.exe	IOCTL_SERIAL_SET_HANDFLOW	USBSER001	SUCCESS	Shake:1 Replace:43 XonLimit:4096 XoffLimit:4096

和在最后

0.00061153  aspnet_wp.exe	IOCTL_SERIAL_PURGE	USBSER001	SUCCESS	Purge: RXABORT RXCLEAR	
0.00004442  aspnet_wp.exe	IOCTL_SERIAL_PURGE	USBSER001	SUCCESS	Purge: TXABORT TXCLEAR

有没有人有关于如何化解这些问题的任何提示?我也注意到,当我发出一个命令,所以我怀疑问题是与连接,最后不是那些信息的电话未与任何确认响应返回给应用程序。

Has anyone got any tips on how to iron out these issues? I also notice that the phone is not responding back to the application with any acknowledgement when I issue a command so I suspect the problem is with the connection, not those messages at the end.

推荐答案

您需要等待>写出了消息之前。另外,不要终止与CR / LF(的WriteLine)消息。

You need to wait for the ">" before writing out the message. Also, don't terminate the message with a CR/LF (WriteLine).

这篇关于通过诺基亚手机的短信通过串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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