请帮忙编写这个串行通信程序
这有什么问题吗?我正在尝试与 TReX 电机控制器进行通信。我需要发送以下数据“DA 1F 1F”或“0xDA 0x1F 0x1F”
using System;
using System.IO.Ports;
using System.Threading;
public class PortChat
{
static SerialPort _serialPort;
public static void Main()
{
StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
// Create a new SerialPort object with default settings.
_serialPort = new SerialPort();
_serialPort.PortName = "COM3";
_serialPort.Open();
_serialPort.BaudRate = 19200;
_serialPort.DataBits = 8;
_serialPort.Parity = Parity.None;
_serialPort.StopBits = StopBits.One;
_serialPort.Write("Byte[DA 1F 1F]");
_serialPort.Close();
}
}
What is wrong with this? I am trying to communicate to a TReX motor controller. I need to send the following data "DA 1F 1F" or "0xDA 0x1F 0x1F"
using System;
using System.IO.Ports;
using System.Threading;
public class PortChat
{
static SerialPort _serialPort;
public static void Main()
{
StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
// Create a new SerialPort object with default settings.
_serialPort = new SerialPort();
_serialPort.PortName = "COM3";
_serialPort.Open();
_serialPort.BaudRate = 19200;
_serialPort.DataBits = 8;
_serialPort.Parity = Parity.None;
_serialPort.StopBits = StopBits.One;
_serialPort.Write("Byte[DA 1F 1F]");
_serialPort.Close();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关闭它
Close it