我有一个用于阅读Legic的phg ADMITTO100 RFID阅读器,我尝试将一些CMD发送到这个但它没有回答。
我遵循此示例Serial Port
我忘记了什么?在使用COM-Port之前是否需要安装一些东西?
由于LRC字节,CMD不对,但读者不应该说“不,那是错的”?
这是我的代码:
var serialPort = new SerialPort
{
PortName = "COM1",
BaudRate = 9600,
DataBits = 8,
Parity = Parity.None,
StopBits = StopBits.One,
Handshake = Handshake.None,
ReadTimeout = 500,
WriteTimeout = 500,
};
serialPort.Open();
serialPort.DataReceived += new SerialDataReceivedEventHandler((s, e) =>
{
var message = ((SerialPort)s).ReadExisting();
Console.WriteLine(message);
});
serialPort.ErrorReceived += new SerialErrorReceivedEventHandler((s, e) =>
{
Console.WriteLine(e.EventType);
});
var buffer = new byte[] { 0x02, 0x36, 0x00 };
serialPort.Write(buffer, 0, buffer.Length);