Я пытаюсь отправить команды и RFID-считыватель через последовательный порт (он действует как клавиатура, M302 от KKMOON).
У меня есть этот кусок кода для отправки инструкций:
SerialPort sp = new SerialPort();
sp.PortName = "COM3";
sp.BaudRate = 9600;
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
sp.DataReceived += myRecieved;
sp.Open();
byte[] bytestosend = { 0x03, 0x0a, 0x00, 0x0d };
sp.Write(bytestosend, 0, bytestosend.Length);
bytestosend = new byte[]{ 0x04, 0x05, 0x00, 0x00, 0x09 };
sp.Write(bytestosend, 0, bytestosend.Length);
bytestosend = new byte[] { 0x03, 0x06, 0x00, 0x09 };
sp.Write(bytestosend, 0, bytestosend.Length);
if (beep)
{
running = false;
bytestosend = new byte[] { 0x02, 0x13, 0x15 };
sp.Write(bytestosend, 0, bytestosend.Length);
}
sp.Close();
sp.Dispose();
sp = null;
, и я получаю этот вывод от слушателя последовательного порта: ![The Current Output from the Serial Program](https://i.stack.imgur.com/vRHN3.png)
Выход, который мне нужно получить для чтения данных, ![The required data](https://i.stack.imgur.com/9yG3c.png)