Alr9900 rfid reader

The Forum for Non-Technical questions

Moderators: Matt, kyle, Moderators

Post Reply
Arun
Posts: 5
Joined: Thu Dec 18, 2014 9:16 am
Organization: Preva systems Pvt Ltd

Alr9900 rfid reader

Post by Arun » Thu Dec 25, 2014 3:49 am

I want my messageListener machine to be notified only when there is a change in tagList(either addition of tag or removing of tag from the antenna field )how can I achieve it(actually i tried this by setting the notifyTrigger as CHANGE but it is not working as expected )
Here is my code sniipet


package com.alien.enterpriseRFID.examples;

import com.alien.enterpriseRFID.reader.*;
import com.alien.enterpriseRFID.tags.*;
import com.alien.enterpriseRFID.notify.*;

import java.io.Reader;
import java.net.InetAddress;
import java.util.*;
/**
* Starts up a message listener service, then opens a connection to a reader
* connected to COM1 and tells it to go into autonomous mode. The reader sends
* a notification to this application every second, whether it sees a tag or not.
* <p>
* The notifications are delivered to the messageReceived method, where the tag
* list is then displayed.
* <p>
* One thing to note: we will set up the reader to read in autonomous mode. But
* we don't exit this application nicely, other than with a Ctrl-C or similar
* method. This means that the reader is still reading and notifying, even though
* we have finished the application. This will be evidenced by the yellow "sniff"
* light being almost permanently lit on the reader.
* <p>
* The solution to this is to log onto the reader and turn autonomous mode off
* (set autonomousmode=off) or to make this application behave nicely and turn the
* background mode off programatically, by calling setAutoMode() or resetAutoMode().
*
* @version 1.2 Feb 2004
* @author Chris Parkinson
* @author David Krull
*/
public class MessageListenerTest implements MessageListener {

/**
* Constructor.
*/


public MessageListenerTest() throws Exception {
System.out.println();
// Set up the message listener service
MessageListenerService service = new MessageListenerService(4000);
service.setMessageListener(this);
service.startService();
System.out.println("Message Listener has Started");

// Instantiate a new reader object, and open a connection to it on COM1
AlienClass1Reader reader = new AlienClass1Reader();
reader.setConnection("192.168.2.187", 23);
reader.setUsername("alien");
reader.setPassword("password");
reader.open();
reader.clearTagList();
System.out.println("reader.open");
// Set up Notification.
// Use this host's IPAddress, and the port number that the service is listening on.
reader.setNotifyAddress(InetAddress.getLocalHost().getHostAddress(), service.getListenerPort());
reader.setNotifyFormat(AlienClass1Reader.XML_FORMAT); // Listener only supports XML messages
reader.setNotifyTrigger("change"); // Notify whether there's a tag or not
reader.setNotifyMode(AlienClass1Reader.ON);

// Set up AutoMode





reader.autoModeReset();
/* reader.autoModeTriggerNow();
reader.setAutoAction("acquire");
reader.setAutoStartTrigger(1, 0);
reader.setAutoStopTimer(1800);

reader.setAutoTruePause(0);

reader.setAutoFalsePause(0);
*/

reader.setAutoStopTimer(1000*3); // Read for 1 second
reader.setPersistTime(-1);
//reader.programEPC();
/* reader.setProgUserData("10112011");
System.out.println("reader.getProgUserData() "+reader.getProgUserData());
*/ /* reader.eraseTag();
reader.clearTagList();*/

/*reader.setAcquireC1Cycles(1);
reader.setAcquireC1Count(1);
*/ reader.setAutoMode(AlienClass1Reader.ON);
/*System.out.println("persist time"+reader.getPersistTime());
System.out.println("reader.getProgAntenna() "+reader.getProgAntenna());
System.out.println("reader.getNetworkTimeout() "+reader.getNetworkTimeout());
System.out.println("reader.getProgEPCData() "+reader.getProgEPCData());
reader.setProgEPCData("1111222233334444");*/

// Close the connection and spin while messages arrive
reader.close();
System.out.println("reader.close");

while(service.isRunning()){
Thread.sleep(1000);

}
System.out.println("after while");
}


/**
* A single Message has been received from a Reader.
*
* @param message the notification message received from the reader
*/
public void messageReceived(Message message){
System.out.println("\nMessage Received:");

if (message.getTagCount() == 0) {
System.out.println("(No Tags)");
} else {
TagTable tt=new TagTable();

for (int i = 0; i < message.getTagCount(); i++) {
Tag tag = message.getTag(i);
//tt.addTag(tag);

//System.out.println(tag.getTagID());

System.out.println(tag.toLongString());
/*String[]arr=tag.toLongString().split("=");
String[]arr2=arr[4].split(" ");*/
/*if(!(Integer.parseInt(arr2[0])>30))*/
//System.out.println(tag.toLongString());
//tag.setRenewCount(0);
// tag.getTimeToLive();


}

// System.out.println(tt.toString());
}
}


/**
* Main
*/
public static final void main(String args[]){
try {
System.out.println("messageListenerTest");
new MessageListenerTest();
System.out.println("here");
} catch (Exception e) {
System.out.println("Error:" + e.toString());
}
}

}

Daniel
Posts: 23
Joined: Tue Nov 25, 2014 1:47 pm
Organization: Apes

Re: Alr9900 rfid reader

Post by Daniel » Thu Feb 05, 2015 5:56 pm

Do you actually have a device on the I/O Ports? check that first because that can be interfering with the autonomous cycle.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests