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);
}
我看到其他用途的库也有同样的问题。完整代码可以在here找到。我的特殊问题是尝试通过 COM 端口使用应用程序连接阅读器。首先,我使用串行端口监视器独立测试了 COM 端口。每当 RFID 标签靠近阅读器时,阅读器就会通过 COM 端口传输此数据,并且端口监视器会显示标签的 ID。所以我知道读者是功能性的。
但是,当我使用库连接时,我发现openResult返回48(十进制)/0x30(十六进制),这会产生错误“串行通信错误”。我在 Windows 10 上运行此库。我如何知道此库是否不再与我的系统兼容,或者我可以更改代码以使其更新吗?
您成功解决该错误了吗? 我有类似的东西,CFHid_GetUsbCount 方法总是返回零,我找不到可能的解决方案。