我试图从串行端口读取一些信息,但当我实际打开一个连接时,它抛出了一个未经授权的访问异常
此代码读取端口名称
SerialPort port = new SerialPort();
string[] serialPorts = System.IO.Ports.SerialPort.GetPortNames();
public Page_Main()
{
InitializeComponent();
for (int i = 0; i < serialPorts.Count(); i++)
portBox.Items.Add(serialPorts[i]);
}这是尝试接收来自串口的信息的代码
port.PortName = portBox.SelectedItem.ToString();
port.BaudRate = 9600;
port.DataBits = 8;
port.Parity = Parity.None;
port.StopBits = StopBits.One;
port.Open();// This is where the exception is thrown
serialOutput.Text = port.ReadLine();发布于 2012-04-27 05:40:56
对端口的访问被拒绝。
当前进程或系统上的另一个进程已经由SerialPort实例或非托管代码打开了指定的COM端口。
https://stackoverflow.com/questions/10341744
复制相似问题