Thank you again for your answer Andy.
I'm having problem with I2C write, I use port 1 and I only talk with the leJOS firmware.
Here is the Java class of my RFID:
- Code: Select all
package lejos.nxt;
/**
* Test for a RFID sensor
* using I2C protocol
*
*/
public class RFIDSensor extends I2CSensor {
byte[] buf = new byte[1];
byte[] buf2 = new byte[2];
private static byte I_O_FRAME = 0x01;
//CRC_B sur deux octets est calculé automatiquement
public RFIDSensor(I2CPort port)
{
super(port);
port.setType(TYPE_LOWSPEED_9V);
super.setAddress(0x50);
}
public int set_rfid_APf(byte valeur) {
buf[0] = valeur;
int ret = sendData(I_O_FRAME,buf, 1);
return ret;
}
public int set_rfid_AFI(byte valeur) {
buf[0] = valeur;
int ret = sendData(I_O_FRAME,buf, 1);
return ret;
}
public int set_rfid_PARAM(byte valeur) {
buf[0] = valeur;
int ret = sendData(I_O_FRAME,buf, 1);
return ret;
}
public int getSthg() {
int ret = getData(I_O_FRAME, buf, 1);
return ret;
}
/*
public int get_rdif_flag() {
int ret = getData(GET_RFID_FLAG, buf, 1);
return ret;
}
}
And here the test:
- Code: Select all
import lejos.nxt.*;
public class TestRFID{
private static byte APf = 0x05;
private static byte AFI = 0x00;
private static byte PARAM = 0x00;
public static byte [] buf = new byte[1];
byte reply=0;
int rfid_tag;
public static void main(String[] args) throws Exception {
RFIDSensor RFID = new RFIDSensor(SensorPort.S1);
RFID.set_rfid_APf(APf);
RFID.set_rfid_AFI(AFI);
RFID.set_rfid_PARAM(PARAM);
while(!Button.ESCAPE.isPressed()) {
// reply=RFID.new_rfid_data();
// if(reply){
int ret=RFID.getData(0x01,buf,1);
LCD.drawString("RFID Tag:",4, 0);
LCD.drawInt(ret, 6,5,1);
//LCD.drawInt(3, 8, 2);
LCD.drawString("Test:",1, 3);
LCD.drawInt(RFID.getSthg(), 3, 4);
LCD.refresh();
Thread.sleep(500);
}
}
}
I've no answer from the slave.
When I read the SDA I see on the scope the 0x50 address. But no ACK...
Is it really a low speed problem? ..
Thanks for help.