我试图向COM1发送字节,COM1上附有打印机。
我有以下内容:
foreach (var portName in SerialPort.GetPortNames())
{
WriteLine(portName);
}
var mPort = new SerialPort();
if (mPort.IsOpen)
mPort.Close();
mPort.PortName = "COM1";
mPort.Open();
" COM1"由SerialPort.GetPortNames
返回,但是,当我到达mPort.Open()
行时,我得到ArgumentException
:
The given port name does not start with COM/com or does not resolve to a valid serial port.