我正在使用CF-RU 5102台式阅读器来读取RFID卡。我已经从http://www.chafon.com/productdetails.aspx?pid=384下载了vb.net SDK。
当我运行sdk时出现错误“串行通信错误”。
SDK:CF-RU5102 UHFReader09 vb6.0_17051009420181.rar 作业系统:Windows 10
源代码:
private void OpenPort_Click(object sender, EventArgs e)
{
int port=0;
int openresult,i;
openresult = 30;
string temp;
Cursor = Cursors.WaitCursor;
if (Edit_CmdComAddr.Text=="")
Edit_CmdComAddr.Text="FF";
fComAdr = Convert.ToByte(Edit_CmdComAddr.Text,16); // $FF;
try
{
if (ComboBox_COM.SelectedIndex == 0)//Auto
{
fBaud = Convert.ToByte(ComboBox_baud2.SelectedIndex);
if (fBaud>2)
{
fBaud = Convert.ToByte(fBaud + 2);
}
openresult =StaticClassReaderB.AutoOpenComPort(ref port,ref fComAdr,fBaud,ref frmcomportindex);
fOpenComIndex = frmcomportindex;
if (openresult == 0 )
{
ComOpen = true;
// Button3_Click(sender, e); //自动执行读取写卡器信息
if (fBaud > 3)
{
ComboBox_baud.SelectedIndex = Convert.ToInt32(fBaud - 2);
}
else
{
ComboBox_baud.SelectedIndex = Convert.ToInt32(fBaud);
}
Button3_Click(sender, e); //自动执行读取写卡器信息
if ((fCmdRet==0x35) |(fCmdRet==0x30))
{
MessageBox.Show ("Serial Communication Error or Occupied", "Information");
StaticClassReaderB.CloseSpecComPort(frmcomportindex);
ComOpen = false;
}
}
}
else
{
temp = ComboBox_COM.SelectedItem.ToString();
temp = temp.Trim();
port = Convert.ToInt32(temp.Substring(3, temp.Length - 3));
for (i = 6; i >= 0; i--)
{
fBaud = Convert.ToByte(i);
if (fBaud == 3)
continue;
openresult = StaticClassReaderB.OpenComPort(port, ref fComAdr, fBaud, ref frmcomportindex);
fOpenComIndex = frmcomportindex;
if (openresult == 0x35)
{
MessageBox.Show("COM Opened", "Information");
return;
}
if (openresult == 0)
{
ComOpen = true;
Button3_Click(sender, e); //自动执行读取写卡器信息
if (fBaud > 3)
{
ComboBox_baud.SelectedIndex = Convert.ToInt32(fBaud - 2);
}
else
{
ComboBox_baud.SelectedIndex = Convert.ToInt32(fBaud);
}
if ((fCmdRet == 0x35) || (fCmdRet == 0x30))
{
ComOpen = false;
MessageBox.Show("Serial Communication Error or Occupied", "Information");
StaticClassReaderB.CloseSpecComPort(frmcomportindex);
return;
}
RefreshStatus();
break;
}
}
}
}
finally
{
Cursor = Cursors.Default;
}
if ((fOpenComIndex != -1) &(openresult != 0X35) &(openresult != 0X30))
{
ComboBox_AlreadyOpenCOM.Items.Add("COM"+Convert.ToString(fOpenComIndex)) ;
ComboBox_AlreadyOpenCOM.SelectedIndex = ComboBox_AlreadyOpenCOM.SelectedIndex + 1;
Button3.Enabled = true ;
Button5.Enabled = true;
Button1.Enabled = true;
button2.Enabled = true;
Button_WriteEPC_G2.Enabled = true;
Button_SetMultiReadProtect_G2.Enabled = true;
Button_RemoveReadProtect_G2.Enabled = true;
Button_CheckReadProtected_G2.Enabled = true;
button4.Enabled = true;
SpeedButton_Query_6B.Enabled = true ;
ComOpen = true;
}
if ((fOpenComIndex == -1) &&(openresult == 0x30))
MessageBox.Show("Serial Communication Error", "Information");
if ((ComboBox_AlreadyOpenCOM.Items.Count != 0)&(fOpenComIndex != -1) & (openresult != 0X35) & (openresult != 0X30)&(fCmdRet==0))
{
fComAdr = Convert.ToByte(Edit_ComAdr.Text,16);
temp = ComboBox_AlreadyOpenCOM.SelectedItem.ToString();
frmcomportindex = Convert.ToInt32(temp.Substring(3, temp.Length - 3));
}
RefreshStatus();
}
请帮助我解决这个问题。
谢谢。