1
我有以下條碼閱讀器: https://www.honeywellaidc.com/products/barcode-scanners/general-duty/xenon-1900g-1902g霍尼韋爾Xenon 1900條碼閱讀器|讀取數據|虛擬COM端口
和可配置的掃描儀虛擬COM端口。掃描儀已插入,我的設備管理器檢測它:
這裏是我的C#代碼:
class Program
{
private static SerialPort _ReaderPort = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
static void Main(string[] args)
{
_ReaderPort.DataReceived += ReaderPortOnDataReceived;
_ReaderPort.ErrorReceived += ReaderPortOnErrorReceived;
_ReaderPort.Handshake = Handshake.None;
_ReaderPort.ReadTimeout = 500;
_ReaderPort.Encoding = Encoding.UTF8;
_ReaderPort.Open();
Console.ReadLine();
}
private static void ReaderPortOnErrorReceived(object sender, SerialErrorReceivedEventArgs serialErrorReceivedEventArgs)
{
}
private static void ReaderPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
{
}
}
我甚至不接收事件!我不知道我的代碼有什麼問題。