I have the following routines and the reading works correctly, but if I need to leave the reading and close the form where it is being read, the form remains blocked and blocks the handheld completely, I'm Using similar to the example CS_RFID3Sample6 What is wrong ?
string hostname = "127.0.0.1";
uint port = 5084;
public bool connect(string ip, uint port)
{
rfid3 = new RFIDReader(ip, port, 0);
try
{
triggernfo.TagReportTrigger = 1;
triggernfo.StartTrigger.Type = START_TRIGGER_TYPE.START_TRIGGER_TYPE_HANDHELD;
triggernfo.StartTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_PRESSED;
triggernfo.StopTrigger.Type = STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_HANDHELD_WITH_TIMEOUT;
triggernfo.StopTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_RELEASED;
triggernfo.StopTrigger.Handheld.Timeout = 0; // Default handheld timeout value
vestado.BackColor = Color.Green;
vestado.Text = "Conectado";
m_IsConnected=true;
if (!rfid3.IsConnected)
{
rfid3.Connect();
configureReader();
}
StartReading();
}
catch (OperationFailureException operationException)
{
m_IsConnected = false;
vestado.BackColor = Color.Red;
MessageBox.Show(operationException.StatusDescription);
return false;
}
catch (Exception ex)
{
m_IsConnected = false;
vestado.BackColor = Color.Red;
MessageBox.Show("RFID Connect failed: " + ex.Message);
return false;
}
return true;
}
private void configureReader()
{
rfid3.Events.AttachTagDataWithReadEvent = false;
rfid3.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
rfid3.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
rfid3.Events.NotifyInventoryStartEvent = true;
rfid3.Events.NotifyInventoryStopEvent = true;
rfid3.Events.NotifyHandheldTriggerEvent=true;
rfid3.Events.NotifyGPIEvent = true;
rfid3.Events.NotifyAntennaEvent = true;
rfid3.Events.NotifyReaderDisconnectEvent = true;
}
private void menuItem3_Click(object sender, EventArgs e)
{
CloseForm();
this.Close();
}
private void CloseForm()
{
try
{
if (m_IsConnected)
{
rfid3.Events.ReadNotify -= Events_ReadNotify;
rfid3.Events.StatusNotify -= Events_StatusNotify;
StopReading(OperationToPerform.IDLE);
rfid3.Disconnect();
}
rfid3.Dispose();
this.Dispose();
}
catch (Exception ex)
{
notifyUser(ex.Message, "Close");
}
}
private void StopReading(OperationToPerform nextOperation)
{
try
{
if (rfid3.Actions.TagAccess.OperationSequence.Length > 0)
{
rfid3.Actions.TagAccess.OperationSequence.StopSequence();
}
else
{
rfid3.Actions.Inventory.Stop();
}
rfid3.Actions.PurgeTags();
}
catch (InvalidOperationException ioe)
{
notifyUser("InvalidOperationException" + ioe.Message, "Stop Operation");
}
catch (OperationFailureException ofe)
{
notifyUser("OperationFailureException:" + ofe.StatusDescription, "Stop Read");
}
catch (InvalidUsageException iue)
{
notifyUser("InvalidUsageException:" + iue.Info, "Stop Read");
}
catch (Exception ex)
{
notifyUser("Exception:" + ex.Message, "Stop Read");
}
}
0 Replies