端口 'COM11' 不存在。指定端口未开放
The port 'COM11' does not exist. Specified port is not open
我使用Unity和teensy进行串口通信已经有一段时间了。它一直运行良好。
现在我换了我的小板,因此上面的 COM 端口也改变了。
Teensy 在 arduino 中完美通信,并在串行监视器中检查时发送所有正确的信号。但是我在统一中遇到了这个错误。
> IOException: The port `COM11' does not exist.
System.IO.Ports.WinSerialStream.ReportIOError (System.String optional_arg)
System.IO.Ports.WinSerialStream..ctor (System.String port_name, Int32
baud_rate, Int32 data_bits, Parity parity, StopBits sb, Boolean dtr_enable, Boolean rts_enable, Handshake hs, Int32 read_timeout, Int32 write_timeout, Int32 read_buffer_size, Int32 write_buffer_size)
(wrapper remoting-invoke-with-check) System.IO.Ports.WinSerialStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
System.IO.Ports.SerialPort.Open ()
最初,com 端口是个位数的值,例如 COM4 或 COM8 等。但是自从我开始使用两位数的 COM 端口后,我开始面临这个问题。如果我再次将 teensy 连接到单个数字 com 端口,它工作正常,但没有检测到 COM50 等。
我该如何解决?
如果这是 Windows OS 则尝试将 COM 端口名称指定为 \\.\COM11
myPort= new SerialPort("\\.\COM11",9600);
注意:此语法也适用于端口 COM1 到 COM9。某些开发板会让您自己选择端口名称。此语法也适用于这些名称。
使用 System.IO.Ports.SerialPort.GetPortNames() 查看 OS 当前 COM 端口使用的名称。 (我不确定您是否在谈论 .NET,但如果您这样做会有所帮助)
使用
foreach(string str in SerialPort.GetPortNames())
{
Debug.WriteLine(string.Format("Existing COM port: {0}", str));
}
了解可用的端口
我使用Unity和teensy进行串口通信已经有一段时间了。它一直运行良好。 现在我换了我的小板,因此上面的 COM 端口也改变了。 Teensy 在 arduino 中完美通信,并在串行监视器中检查时发送所有正确的信号。但是我在统一中遇到了这个错误。
> IOException: The port `COM11' does not exist.
System.IO.Ports.WinSerialStream.ReportIOError (System.String optional_arg)
System.IO.Ports.WinSerialStream..ctor (System.String port_name, Int32
baud_rate, Int32 data_bits, Parity parity, StopBits sb, Boolean dtr_enable, Boolean rts_enable, Handshake hs, Int32 read_timeout, Int32 write_timeout, Int32 read_buffer_size, Int32 write_buffer_size)
(wrapper remoting-invoke-with-check) System.IO.Ports.WinSerialStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
System.IO.Ports.SerialPort.Open ()
最初,com 端口是个位数的值,例如 COM4 或 COM8 等。但是自从我开始使用两位数的 COM 端口后,我开始面临这个问题。如果我再次将 teensy 连接到单个数字 com 端口,它工作正常,但没有检测到 COM50 等。
我该如何解决?
如果这是 Windows OS 则尝试将 COM 端口名称指定为 \\.\COM11
myPort= new SerialPort("\\.\COM11",9600);
注意:此语法也适用于端口 COM1 到 COM9。某些开发板会让您自己选择端口名称。此语法也适用于这些名称。
使用 System.IO.Ports.SerialPort.GetPortNames() 查看 OS 当前 COM 端口使用的名称。 (我不确定您是否在谈论 .NET,但如果您这样做会有所帮助)
使用
foreach(string str in SerialPort.GetPortNames())
{
Debug.WriteLine(string.Format("Existing COM port: {0}", str));
}
了解可用的端口