I have been using Unity and teensy to perform serial communication for quite some time. And it has been working fine. Now I changed my teensy board and thus the COM Port has changed on it. Teensy is communicating perfectly in arduino and sending all the right signals when checked in serial monitor. But I am getting this error in unity.
> 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 ()
Initially the com ports were single digit values such as COM4 or COM8 etc. But since I started getting twodigit COM Ports I started facing this problem. If I connect a teensy again with a single digit com port it works fine but does not detect COM50 etc.
How do I solve this?
If this is Windows OS then try to specify the COM port name as \\.\COM11
myPort= new SerialPort("\\\\.\\COM11",9600);
NOTES: This syntax also works for ports COM1 through COM9. Certain boards will let you choose the port names yourself. This syntax works for those names as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With