Jump to content

[Bindings 2.0] Device Identifier


Recommended Posts

ahhh THX

für alle die es auch suchen

"11", "Brick DC"
"12", "Brick Debug"
"13", "Brick Master 2.0"
"14", "Brick Servo"
"15", "Brick Stepper"
"16", "Brick IMU"
"21", "Bricklet Ambient Light"
"22", "Bricklet Breakout"
"23", "Bricklet Current12"
"24", "Bricklet Current25"
"25", "Bricklet Distance IR"
"26", "Bricklet Dual Relay"
"27", "Bricklet Humidity"
"28", "Bricklet IO-16"
"29", "Bricklet IO-4"
"210", "Bricklet Joystick"
"211", "Bricklet LCD 16x2"
"212", "Bricklet LCD 20x4"
"213", "Bricklet Linear Poti"
"214", "Bricklet Piezo Buzzer"
"215", "Bricklet Rotary Poti"
"216", "Bricklet Temperature"
"217", "Bricklet Temperature IR"
"218", "Bricklet Voltage"
"219", "Bricklet Analog In"
"220", "Bricklet Analog Out"
"221", "Bricklet Barometer"
"222", "Bricklet GPS"
"223", "Bricklet Industrial Digital In 4"
"224", "Bricklet Industrial Digital Out 4"
"225", "Bricklet Industrial Quad Relay"
"226", "Bricklet PTC"
"227", "Bricklet Voltage/Current"

Link to comment
Share on other sites

Ich bekomme nach umbauen meines Programms einen NullPointer. Sieht da jemand einen Fehler?

Exception in thread "Thread-0" java.lang.NullPointerException
at com.tinkerforge.CallbackThread.run(IPConnection.java:124)

Hier das Programm

ipcon.addListener(new IPConnection.EnumerateListener() {
            public void enumerate(String uid, String connectedUID, char position,
                    short[] hardwareVersion, short[] firmwareVersion,
                    int deviceIdentifier, short enumerationType) {
                
                
                if(enumerationType == IPConnection.ENUMERATION_TYPE_DISCONNECTED) {
                    System.out.println("Device UID: " + uid + " disconnected.");
                    return;
                }
                if(enumerationType == IPConnection.ENUMERATION_TYPE_AVAILABLE) {
                    /*System.out.println("UID:               " + uid);
                     * System.out.println("Enumeration Type:  " + enumerationType);
                     * System.out.println("Connected UID:     " + connectedUID);
                     * System.out.println("Position:          " + position);
                     * System.out.println("Hardware Version:  " + hardwareVersion[0] + "." +
                     * hardwareVersion[1] + "." +
                     * hardwareVersion[2]);
                     * System.out.println("Firmware Version:  " + firmwareVersion[0] + "." +
                     * firmwareVersion[1] + "." +
                     * firmwareVersion[2]);
                     * System.out.println("Device Identifier: " + deviceIdentifier);*/ AKTUELL AUSKOMMENTIERT
                    uid_list.add(uid);
                    deviceID_list.add(deviceIdentifier);
                    counter ++;
                }
            }
        });

Link to comment
Share on other sites

Mir fehlen deine zeilennummern, aber in Zeile 124 ist ein Wert null der es nicht sein sollte :D

 

Davon ausgehend, dass die TF-Api hoffentlich funktioniert und das meiste ja auskommentiert ist:

                    uid_list.add(uid);
                    deviceID_list.add(deviceIdentifier);

 

Ich vermute eine der Listen oder beide Listen sind nicht initialisiert.

Link to comment
Share on other sites

Ich vermute es liegt an der ipcon.disconnect().

 

Könnte jemand der Java macht dies hier mal versuchen?

 

public class RS485_stats {
    
    private static String host = "192.168.0.255";
    private static String UID_rs485_master = "******";
    private static String UID_rs485_slave1 = "******";
    
    public static void main(String[] args) throws IOException, InterruptedException, IPConnection.TimeoutException {
        // Create connection to brickd
        IPConnection ipcon = new IPConnection(); // Can throw IOException
        ipcon.connect(host, main.port);
        
        BrickMaster rs485_master = new BrickMaster(UID_rs485_master,ipcon);
        BrickMaster rs485_slave1 = new BrickMaster(UID_rs485_slave1,ipcon);
        
        System.out.println("RS485 Master CRC-Errors: " + rs485_master.getRS485ErrorLog());
        System.out.println("RS485 Slave 1 CRC-Errors: " + rs485_slave1.getRS485ErrorLog());
        
        ipcon.disconnect(); ipcon.
    }
}

Link to comment
Share on other sites

hi Einstein

 

kann das leider nicht auf arbeit testen aber heute abend kann ich das gerne mal durch teste

 

mfg masder

 

edit: ich habe gerade gesehen das eine variable fehlt und das wäre bei dir "main.port" ohne das es ja natürlich nicht gehen kann.

also musst du nur am anfan wo du auch die ip festlegst

folgendes ergänzen

private static final int port = 4223;

Link to comment
Share on other sites

Einstein, es hat nichts mit deinem Code zu tun, der ist so in Ordnung.

 

Das Problem ist in der IP Connection selbst. Es wird durch den disconnect Aufruf ausgelöst, der versucht den Callback Thread zu beenden. Den gleichen Bug hatten auch die C# Bindings, dort habe ich es gestern behoben.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...