I am working on an Application to Connect to virtual machines(using Hyper-V). (I am using Virtual Machines now for Development, but the end-product will be physical Serial Connected Machines. not VM's) I have created a named pipe with the COM adaptor like this.
I am able to connect with PuTTy Like so.
Running a CentOS Build on the Hyper-V
I then wrote a simple Application to connect to it with C#
my_Serial_Port = new SerialPort();
my_Serial_Port.PortName = @"\\.\pipe\ttyS0";
my_Serial_Port.BaudRate = m_BaudRate;
my_Serial_Port.DataBits = 8;
my_Serial_Port.Parity = Parity.None;
my_Serial_Port.StopBits = StopBits.One;
my_Serial_Port.Handshake = Handshake.None;
my_Serial_Port.DtrEnable = true;
my_Serial_Port.RtsEnable = true;
my_Serial_Port.WriteTimeout = 15000;
my_Serial_Port.ReadTimeout = 15000;
my_Serial_Port.ErrorReceived += my_Serial_Port_ErrorReceived;
The thing is when I open the connection, I get this Exception thrown.
A little searching, and I found this information but no work-around. msdn.microsoft.com/en-us/library/system.io.ports.serialport.portname I have also Tried running my application as Administrator (Putty Needed this too) And it did not work.
With Oystein's Suggestion I tried:
string[] ports = SerialPort.GetPortNames();
string result = "The following serial ports were found:" + Environment.NewLine;
// Display each port name to the console.
foreach (string port in ports)
{
result += port + Environment.NewLine;
}
MessageBox.Show(result);
Unfortunately COM1 is on the Physical Machine.
Does any one know how I can get this to work? Thanks!