Код: Выделить всё
port = 0;
int openResult;
openResult = 30;
Cursor = Cursors.WaitCursor;
try
{
comAddress = Convert.ToByte("FF", 16);
baudRate = Convert.ToByte(5);
openResult = StaticClassReaderB.AutoOpenComPort(ref port, ref comAddress, baudRate, ref comPortIndex);//automatically detects a com port and connects it with the reader
openComIndex = comPortIndex;
if (openResult == 0)
{
comOpen = true;
openedPort = port;
if ((cmdReturn == 0x35 | cmdReturn == 0x30))
{
StaticClassReaderB.CloseSpecComPort(comPortIndex);//disconnects the reader from designated com port when communication error occurs
comOpen = false;
}
}
}
finally
{
Cursor = Cursors.Default;
}
if ((openComIndex != -1) & (openResult != 0X35) & (openResult != 0X30))
{
comOpen = true;
}
if ((openComIndex == -1) && (openResult == 0x30))
{
MessageBox.Show("Serial Communication Error", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Однако, когда я использую библиотеку для подключения, я обнаруживаю, что openResult возвращает 48 (десятичное)/0x30 (шестнадцатеричное), что приводит к ошибке. «Ошибка последовательной связи». Я использую это в Windows 10. Как мне узнать, совместима ли эта библиотека с моей системой, или я могу изменить код, чтобы обновить его?
Подробнее здесь: https://stackoverflow.com/questions/621 ... n-com-port
Мобильная версия