Я пытаюсь установить связь с устройством, используя класс SerialPort в C # /. NET.
Документация по взаимодействию с устройством описана здесь.

Я использую НУЛЕВОЙ модемный кабель, при этом TX / RX и все контакты для квитирования меняются местами (проверено).
Я ожидал, что следующий код C # будет работать, но я не получаю никакого ответа (от низкого к высокому) от камеры, с которой я пытаюсь взаимодействовать. Я уверен, что проблема в коде. Эта камера работает с другими «ПК». Почему я никогда не смогу добиться того, чтобы DsrHolding (нуль-модемный кабель, поэтому DTR от камеры был высоким) стал истинным в моем коде?
static void Main(string[] args)
{
var serialPort = new SerialPort("COM5");
// start the DSR/DTR handshake
// we are using a null modem cable, so DTR/DSR is switched
serialPort.DtrEnable = true;
while (!serialPort.DsrHolding)
{
// probally should timeout instead of infinite wait
Thread.Sleep(10);
Console.WriteLine("Waiting for the DTR line to go high.");
}
// start the RTS/CTS handshake
// we are using a null modem cable, so RTS/CTS is switched
serialPort.RtsEnable = true;
while (!serialPort.CtsHolding)
{
// probally should timeout instead of infinite wait
Thread.Sleep(10);
Console.WriteLine("Waiting for the RTS line to go high.");
}
// read/write
//serialPort.Write("Some command");
//var response = serialPort.ReadChar();
//while (response != stopBit)
// response = serialPort.ReadChar();
// close the connection because we have written/read our data
// start the DSR/DTR handshake
// we are using a null modem cable, so DTR/DSR is switched
serialPort.DtrEnable = false;
while (serialPort.DsrHolding)
{
// probally should timeout instead of infinite wait
Thread.Sleep(10);
Console.WriteLine("Waiting for the DTR line to go low.");
}
// start the RTS/CTS handshake
// we are using a null modem cable, so RTS/CTS is switched
serialPort.RtsEnable = false;
while (serialPort.CtsHolding)
{
// probally should timeout instead of infinite wait
Thread.Sleep(10);
Console.WriteLine("Waiting for the RTS line to go low.");
}
}