0 Replies Latest reply on Apr 11, 2018 6:03 AM by Peter Ljung

    Not getting tag read events from FX7500 via Ubuntu host SDK

    Peter Ljung

      I am developing a sample application based on:

       

      * Ubuntu 16.04 host SDK with Java

       

      I am successfully reading from inventory using:

       

      reader.Actions.getReadTags(100)

       

      I dont get any tag read events from:

       

      reader.Events.setTagReadEvent(true); // this does not work!

      reader.Events.setAttachTagDataWithReadEvent(true);

      reader.Events.setBufferFullEvent(true); // this works!

      reader.Events.addEventsListener(event_listener);

       

      Any tips on what might be missing?

       

      I am following "Programmer guide" in the SDK - Linux64_SDK/docs/Java/ProgrammersGuide/Generic Reader Interface/Managing Tags.htm

       

      I have attached the full example ...

       

      import com.mot.rfid.api3.*;

      import java.io.BufferedReader;

      import java.io.IOException;

      import java.io.InputStreamReader;

      import java.util.Scanner;

       

      class EventHandler implements RfidEventsListener {

          // Read Event Notification

          public void eventReadNotify(RfidReadEvents e){

              TagData tag = e.getReadEventData().tagData;

              System.out.println("Event: Tag ID " + tag.getTagID());

              if (tag.getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&

                  tag.getOpStatus() == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS) {

                  if (tag.getMemoryBankData().length() > 0) {

                      System.out.println(" Mem Bank Data " + tag.getMemoryBankData());

                  }

              }

          }

          // Status Event Notification

          public void eventStatusNotify(RfidStatusEvents e) {

              System.out.println("Event: Status Notification " + e.StatusEventData.getStatusEventType());

          }

      }

       

      public class ZebraTest {

       

          public static void main(String[] args) {

              System.out.format("Connect to reader");

              String hostname = "10.128.43.134"; // http://fx7500f0ddc7

              RFIDReader reader = new RFIDReader(hostname, 0, 0);

              EventHandler event_listener = new EventHandler();

              Scanner scanner = new Scanner(System.in);

              int scan_time = 5;

              // Trigger configuration

              TriggerInfo triggerInfo;

              triggerInfo = new TriggerInfo();

              triggerInfo.setEnableTagEventReport(true);

              triggerInfo.TagEventReportInfo.setReportNewTagEvent(TAG_EVENT_REPORT_TRIGGER.IMMEDIATE);

              triggerInfo.TagEventReportInfo.setReportTagBackToVisibilityEvent(TAG_EVENT_REPORT_TRIGGER.IMMEDIATE);

              triggerInfo.TagEventReportInfo.setReportTagInvisibleEvent(TAG_EVENT_REPORT_TRIGGER.IMMEDIATE);

              try {

                  reader.connect();

                  ZebraTest.printReaderCapabilities(reader);

                  ZebraTest.tagStorageSettings(reader);

                  // Set antenna configuration

                  System.out.println("Set antenna configuration.");

                  Antennas antennas = reader.Config.Antennas;

                  short[] antennas_ixs = antennas.getAvailableAntennas();

                  for (int i = 0; i < antennas_ixs.length; i++) {

                      int antennaID = antennas_ixs[i];

                      System.out.println("antennaID = "+antennaID);

                      Antennas.SingulationControl singulationControl = reader.Config.Antennas.getSingulationControl(antennaID);

                      singulationControl.setSession(SESSION.SESSION_S1);

                      singulationControl.setTagPopulation((short)10);

                      reader.Config.Antennas.setSingulationControl(antennaID, singulationControl);

                  }

                  // Set reader events configuration

                  System.out.println("Set reader events configuration.");

                  reader.Events.setTagReadEvent(true);

                  reader.Events.setAttachTagDataWithReadEvent(true);

                  reader.Events.setGPIEvent(true);

                  reader.Events.setReaderDisconnectEvent(true);

                  reader.Events.setBufferFullEvent(true); // this works!

                  reader.Events.addEventsListener(event_listener);

                  for (int j = 0; j < 1000; j++) {

                      reader.Actions.Inventory.perform(null,triggerInfo,null);

                      Thread.sleep(scan_time*1000);

                      System.err.println("Inventory.stop()");

                      reader.Actions.Inventory.stop();

                      TagData[] remainingTags = reader.Actions.getReadTags(100);

                      if (remainingTags != null) {

                          for(int i = 0; i < remainingTags.length; i++) {

                              System.out.println(remainingTags[i].getTagID()+","+

                                  remainingTags[i].getPeakRSSI()+","+

                                  remainingTags[i].getTagSeenCount()+","+

                                  remainingTags[i].getPhase()+","+

                                  remainingTags[i].isContainsLocationInfo());

                          }

                      }

                      System.err.println("Actions.purgeTags()");

                      reader.Actions.purgeTags();

                  }

                  reader.Events.removeEventsListener(event_listener);

                  if (reader.isConnected()) {

                      reader.Events.removeEventsListener(event_listener);

                      reader.disconnect();

                  }

              } catch (InvalidUsageException e) {

                  System.err.println("InvalidUsageException: " + e.getMessage());

              } catch (OperationFailureException e) {

                  System.err.println("OperationFailureException: " + e.getMessage());

              } catch (InterruptedException e) {

                  System.err.println("InterruptedException: " + e.getMessage());

              } finally {

                  try {

                      if (reader.isConnected()) {

                          reader.Events.removeEventsListener(event_listener);

                          reader.disconnect();

                      }

                  } catch (Exception e) {

                      System.err.println("reader.disconnect() Exception: " + e.getMessage());

                  }

              }

          }

      }