如何在C#中通过串行发送CTRL_Z? [英] How to send CTRL_Z through serial in C# ?
问题描述
大家好,
我正在一个项目中,使用GSM调制解调器从我的电脑向手机发送SMS消息.
iam working a project to send SMS messages from my pc to mobiles using GSM modem..
为此,我必须在超级终端中编写以下命令.
in order to do that i have to write the following commands in hyper terminal..
AT< cr>
AT <cr>
调制解调器的响应正常
AT + CMGF = 1
AT+CMGF=1
来自调制解调器的响应是可以的
responce from the modem is OK
AT + CMGS =我的手机号码"
AT+CMGS="my mobile number"
来自调制解调器的响应是>
responce from the modem is >
然后我编写消息,然后按CTRL_Z,然后按Enter
then i write the message and press CTRL_Z then Enter
调制解调器的响应正常
*************************************************** ******************************************
************************************************************************************
问题在于,尽管命令在超级终端中有效,但在C#中它没有发送消息.
The problem is that in C# it is not sending the message although the commands worked in Hyper terminal..
在C#中,当我发送CTRL_Z时显示[]符号,尽管在超级终端中它显示->箭头.
In C# when i send CTRL_Z in shows me [] symbol although in hyper terminal it shows -> an arrow..
如何在C#中正确发送ctrl Z.
how to send ctrl Z correctly in C#..
我尝试了以下操作,但没有成功
i tried the following and they didnt work
serialPort1.Write( " \ u001A; );
serialPort1.Write("\u001A");
serialPort1.Write(26 + "'' );
serialPort1.Write(26+"");
serialPort1.Write( " CTRL-Z; );
serialPort1.Write("CTRL-Z");
???
如果您有任何想法请帮助我
thnx
thnx
推荐答案
串行端口具有写入字符数组的功能,因此请尝试以下操作:
Hi,
Serial port has a function that writes an array of chars, so try this:
字符 [] arr = 新 字符 [1];
char[] arr = new char[1];
arr [0] =( char )26; //Ctrl-Z的ascii值
arr[0] = (char)26; //ascii value of Ctrl-Z
m_SerialPort . 写 ( arr ,0, 1 ); //array,start,length
为我工作...
Oded Welgreen
m_SerialPort.Write(arr,0,1); //array, start, length
worked for me...
Oded Welgreen
这篇关于如何在C#中通过串行发送CTRL_Z?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!