通过 MSComm1 发送 ctrl-E
如何通过串口 MSComm1 发送 ctrl-E ? 它应该继续传递 ctrl-E....就像 for 循环或 do while 循环..这是我的代码:
MSComm1.CommPort = Convert.ToInt16(Settings.Default.PortName); SendKeys.Send("^(e)");
MSComm1.Settings = Settings.Default.BaudRate.ToString().Trim() + "," + Settings.Default.Parity.Substring(0, 1).ToString().Trim() + "," + Settings.Default .DataBits.ToString().Trim() + "," + Settings.Default.StopBits.ToString().Trim();
MSComm1.PortOpen = true;
MSComm1.InputLen = 0;
MSComm1.InputMode = MSCommLib.InputModeConstants.comInputModeText;
if (Settings.Default.FlowControl == "Xon/Xoff")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comXOnXoff;
}
else if (Settings.Default.FlowControl == "None")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comNone;
}
else if (Settings.Default.FlowControl == "RTS")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comRTS;
}
else if (Settings.Default.FlowControl == "RTSXon/Xoff")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comRTSXOnXOff; }
How do i send ctrl-E through serial port MSComm1 ?
it should keep on passing ctrl-E....like for loop or do while loop..Here is my code:
MSComm1.CommPort = Convert.ToInt16(Settings.Default.PortName); SendKeys.Send("^(e)");
MSComm1.Settings = Settings.Default.BaudRate.ToString().Trim() + "," + Settings.Default.Parity.Substring(0, 1).ToString().Trim() + "," + Settings.Default.DataBits.ToString().Trim() + "," + Settings.Default.StopBits.ToString().Trim();
MSComm1.PortOpen = true;
MSComm1.InputLen = 0;
MSComm1.InputMode = MSCommLib.InputModeConstants.comInputModeText;
if (Settings.Default.FlowControl == "Xon/Xoff")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comXOnXoff;
}
else if (Settings.Default.FlowControl == "None")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comNone;
}
else if (Settings.Default.FlowControl == "RTS")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comRTS;
}
else if (Settings.Default.FlowControl == "RTSXon/Xoff")
{
MSComm1.Handshaking = MSCommLib.HandshakeConstants.comRTSXOnXOff;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Control-E 是 5 的键盘快捷键,因此:(
假设串行是 System.IO.Ports.SerialPort 的实例。)
Control-E is a keyboard shortcut for 5, so:
(Assuming serial is an instance of System.IO.Ports.SerialPort.)
使用 C# 进行串行端口通信,来自 此处:
现在您只需以某种方式对 Ctrl+E 进行编码即可。
Serial port communication using C# from here:
Now you just have to encode Ctrl+E some way.