Nel Zur Posted March 12, 2017 at 09:59 AM Share Posted March 12, 2017 at 09:59 AM Hallo ich habe ein Listener in meinem Programm integriert. Doch der funktioniert nur einmal wenn das erste mal das Programm durchgelesen wird und wenn das Chip auf dem Bricklet ist. Wenn ich das Chip später auf dem Bricklet ist wird er nicht gelesen. Weiss jemand warum? Danke für Eure Hilfe Nel Quote Link to comment Share on other sites More sharing options...
JoBig Posted March 12, 2017 at 04:14 PM Share Posted March 12, 2017 at 04:14 PM Welches Programm und mit welcher Sprache? Sonst kann keiner dir helfen. Quote Link to comment Share on other sites More sharing options...
Nel Zur Posted March 13, 2017 at 07:13 PM Author Share Posted March 13, 2017 at 07:13 PM Programmiersprache: Java public static void analyse() { nr.addStateChangedListener(new BrickletNFCRFID.StateChangedListener() { public void stateChanged(short state, boolean idle) { try { nr.requestPage(5); } catch (TimeoutException | NotConnectedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (state == BrickletNFCRFID.STATE_REQUEST_PAGE_READY) { // Get and print pages short[] data; try { data = nr.getPage(); bochPos = data[0]; jusPos = data[1]; cerealesPos = data[2]; painPos = data[3]; co1Pos = data[4]; co2Pos = data[5]; } catch (TimeoutException | NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(bochTableau[bochPos].getDescription() + " " + jusTableau[jusPos].getDescription() + " " + cerealesTableau[cerealesPos].getDescription() + " " + painTableau[painPos].getDescription() + " " + confitureTableau[co1Pos].getDescription() + " " + confitureTableau[co2Pos].getDescription()); WindowController.getInstance().nextNFC(bochTableau[bochPos], jusTableau[jusPos], cerealesTableau[cerealesPos], painTableau[painPos], confitureTableau[co1Pos], confitureTableau[co2Pos]); try { ipcon.disconnect(); } catch (NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.println("State " + state); } }); try { nr.requestTagID(BrickletNFCRFID.TAG_TYPE_TYPE2); } catch (TimeoutException | NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Select NFC Forum Type 2 tag } und das ist mein Programm Quote Link to comment Share on other sites More sharing options...
photron Posted March 23, 2017 at 09:00 AM Share Posted March 23, 2017 at 09:00 AM Du rufst nur einmal "nr.requestTagID(BrickletNFCRFID.TAG_TYPE_TYPE2);" auf. Du musst innerhalb deiner stateChanged Methode am Ende wieder "nr.requestTagID(BrickletNFCRFID.TAG_TYPE_TYPE2);" aufrufen, wenn du mit dem Auslesen des Tags fertig bist. Das stößt dann die Suche nach dem nächsten Tag an. Schau dir auch mal das "Scan for Tags" Beispiel an: https://www.tinkerforge.com/de/doc/Software/Bricklets/NFCRFID_Bricklet_Java.html#scan-for-tags Quote Link to comment Share on other sites More sharing options...
Nel Zur Posted March 25, 2017 at 10:51 AM Author Share Posted March 25, 2017 at 10:51 AM nr.addStateChangedListener(new BrickletNFCRFID.StateChangedListener() { public void stateChanged(short state, boolean idle) { try { nr.requestPage(5); } catch (TimeoutException | NotConnectedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (state == BrickletNFCRFID.STATE_REQUEST_PAGE_READY) { // Get and print pages short[] data; try { data = nr.getPage(); bochPos = data[0]; jusPos = data[1]; cerealesPos = data[2]; painPos = data[3]; co1Pos = data[4]; co2Pos = data[5]; vidangePos = data[6]; } catch (TimeoutException | NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { ipcon.disconnect(); } catch (NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(bochTableau[bochPos].getDescription() + " " + jusTableau[jusPos].getDescription() + " " + cerealesTableau[cerealesPos].getDescription() + " " + painTableau[painPos].getDescription() + " " + confitureTableau[co1Pos].getDescription() + " " + confitureTableau[co2Pos].getDescription() + " vidange: " + vidangeTableau[vidangePos].getDescription()); WindowController.getInstance().nextNFC(bochTableau[bochPos], jusTableau[jusPos], cerealesTableau[cerealesPos], painTableau[painPos], confitureTableau[co1Pos], confitureTableau[co2Pos], vidangeTableau[vidangePos]); } else if((state & (1 << 6)) == (1 << 6)) { System.out.println("State " + state); } try { nr.requestTagID(BrickletNFCRFID.TAG_TYPE_TYPE2); } catch (TimeoutException | NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); try { nr.requestTagID(BrickletNFCRFID.TAG_TYPE_TYPE2); } catch (TimeoutException | NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } So klappt es immer noch nicht Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.