Jump to content

Recommended Posts

Geschrieben

Hallo Leute,

ich hab folgendes Problem mit der ChibiExtension.

Über brickv stell ich Kanal 5 ein und mach einen Reset. Danach ist der Kanal der angezeigt wird 5-1 = 4. Das ist das erste Problem.

 

Wenn ich jetzt per java versuche die Frequenz auszulesen und den Kanal gibt es die Funktionen nicht in der Tinkerforge.jar (ich hab schon reingeschut in der Klasse BrickMaster fehlen die Funktionen einfach komplett.

 

hier der Fehler:

 

javac -cp Tinkerforge.jar:. ExampleStackStatus.java 
ExampleStackStatus.java:28: error: cannot find symbol
	short frequenz = master.getChibiFrequency();
	                       ^
  symbol:   method getChibiFrequency()
  location: variable master of type BrickMaster
ExampleStackStatus.java:30: error: cannot find symbol
	short kanal = master.getChibiChannel();
	                    ^
  symbol:   method getChibiChannel()
  location: variable master of type BrickMaster
2 errors

 

Ich hoffe es kann mir wer helfen.

 

Gruß

Einstein

Geschrieben

Ich nutze eigentlich die latest von heute.

 

hier der Auszug aus der BrickMaster.java

 

/*************************************************************
* This file was automatically generated on 2012-02-15.      *
*                                                           *
* If you have a bugfix for this file and want to commit it, *
* please fix the bug in the generator. You can find a link  *
* to the generator git on tinkerforge.com                   *
*************************************************************/

package com.tinkerforge;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.concurrent.TimeUnit;


public class BrickMaster extends Device {
private final static byte TYPE_GET_STACK_VOLTAGE = (byte)1;
private final static byte TYPE_GET_STACK_CURRENT = (byte)2;
private final static byte TYPE_SET_EXTENSION_TYPE = (byte)3;
private final static byte TYPE_GET_EXTENSION_TYPE = (byte)4;
private final static byte TYPE_IS_CHIBI_PRESENT = (byte)5;
private final static byte TYPE_SET_CHIBI_ADDRESS = (byte)6;
private final static byte TYPE_GET_CHIBI_ADDRESS = (byte)7;
private final static byte TYPE_SET_CHIBI_MASTER_ADDRESS = (byte)8;
private final static byte TYPE_GET_CHIBI_MASTER_ADDRESS = (byte)9;
private final static byte TYPE_SET_CHIBI_SLAVE_ADDRESS = (byte)10;
private final static byte TYPE_GET_CHIBI_SLAVE_ADDRESS = (byte)11;
private final static byte TYPE_GET_CHIBI_SIGNAL_STRENGTH = (byte)12;
private final static byte TYPE_GET_CHIBI_ERROR_LOG = (byte)13;

public class ChibiErrorLog {
	public int underrun;
	public int crcError;
	public int noAck;
	public int overflow;

	public String toString() {
		 return "[" + "underrun = " + underrun + ", " + "crcError = " + crcError + ", " + "noAck = " + noAck + ", " + "overflow = " + overflow + "]";
	}
}

public class Version {
	public String name = null;
	public short[] firmwareVersion = new short[3];
	public short[] bindingVersion = new short[3];

	public String toString() {
		 return "[" + "name = " + name + ", " + "firmwareVersion = " + firmwareVersion + ", " + "bindingVersion = " + bindingVersion + "]";
	}
}

public BrickMaster(String uid) {
	super(uid);

	bindingVersion[0] = 1;
	bindingVersion[1] = 1;
	bindingVersion[2] = 0;
}

public int getStackVoltage() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_STACK_VOLTAGE);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_GET_STACK_VOLTAGE, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getStackVoltage in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	int voltage = IPConnection.unsignedShort(bb.getShort());

	semaphoreWrite.release();
	return voltage;
}

public int getStackCurrent() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_STACK_CURRENT);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_GET_STACK_CURRENT, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getStackCurrent in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	int current = IPConnection.unsignedShort(bb.getShort());

	semaphoreWrite.release();
	return current;
}

public void setExtensionType(short extension, long exttype)  {
	ByteBuffer bb = ByteBuffer.allocate(9);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_SET_EXTENSION_TYPE);
	bb.putShort((short)9);
	bb.put((byte)extension);
	bb.putInt((int)exttype);

	ipcon.write(this, bb, TYPE_SET_EXTENSION_TYPE, false);
}

public long getExtensionType(short extension) throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(5);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_EXTENSION_TYPE);
	bb.putShort((short)5);
	bb.put((byte)extension);

	ipcon.write(this, bb, TYPE_GET_EXTENSION_TYPE, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getExtensionType in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	long exttype = IPConnection.unsignedInt(bb.getInt());

	semaphoreWrite.release();
	return exttype;
}

public boolean isChibiPresent() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_IS_CHIBI_PRESENT);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_IS_CHIBI_PRESENT, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for isChibiPresent in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	boolean present = (bb.get()) != 0;

	semaphoreWrite.release();
	return present;
}

public void setChibiAddress(short address)  {
	ByteBuffer bb = ByteBuffer.allocate(5);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_SET_CHIBI_ADDRESS);
	bb.putShort((short)5);
	bb.put((byte)address);

	ipcon.write(this, bb, TYPE_SET_CHIBI_ADDRESS, false);
}

public short getChibiAddress() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_CHIBI_ADDRESS);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_GET_CHIBI_ADDRESS, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getChibiAddress in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	short address = IPConnection.unsignedByte(bb.get());

	semaphoreWrite.release();
	return address;
}

public void setChibiMasterAddress(short address)  {
	ByteBuffer bb = ByteBuffer.allocate(5);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_SET_CHIBI_MASTER_ADDRESS);
	bb.putShort((short)5);
	bb.put((byte)address);

	ipcon.write(this, bb, TYPE_SET_CHIBI_MASTER_ADDRESS, false);
}

public short getChibiMasterAddress() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_CHIBI_MASTER_ADDRESS);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_GET_CHIBI_MASTER_ADDRESS, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getChibiMasterAddress in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	short address = IPConnection.unsignedByte(bb.get());

	semaphoreWrite.release();
	return address;
}

public void setChibiSlaveAddress(short num, short address)  {
	ByteBuffer bb = ByteBuffer.allocate(6);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_SET_CHIBI_SLAVE_ADDRESS);
	bb.putShort((short)6);
	bb.put((byte)num);
	bb.put((byte)address);

	ipcon.write(this, bb, TYPE_SET_CHIBI_SLAVE_ADDRESS, false);
}

public short getChibiSlaveAddress(short num) throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(5);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_CHIBI_SLAVE_ADDRESS);
	bb.putShort((short)5);
	bb.put((byte)num);

	ipcon.write(this, bb, TYPE_GET_CHIBI_SLAVE_ADDRESS, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getChibiSlaveAddress in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	short address = IPConnection.unsignedByte(bb.get());

	semaphoreWrite.release();
	return address;
}

public short getChibiSignalStrength() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_CHIBI_SIGNAL_STRENGTH);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_GET_CHIBI_SIGNAL_STRENGTH, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getChibiSignalStrength in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	short signalStrength = IPConnection.unsignedByte(bb.get());

	semaphoreWrite.release();
	return signalStrength;
}

public ChibiErrorLog getChibiErrorLog() throws IPConnection.TimeoutException {
	ByteBuffer bb = ByteBuffer.allocate(4);
	bb.order(ByteOrder.LITTLE_ENDIAN);
	bb.put((byte)stackID);
	bb.put((byte)TYPE_GET_CHIBI_ERROR_LOG);
	bb.putShort((short)4);

	ipcon.write(this, bb, TYPE_GET_CHIBI_ERROR_LOG, true);

	byte[] answer = null;
	try {
		answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS);
		if(answer == null) {
			throw new IPConnection.TimeoutException("Did not receive answer for getChibiErrorLog in time");
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	bb = ByteBuffer.wrap(answer, 4, answer.length - 4);
	bb.order(ByteOrder.LITTLE_ENDIAN);

	ChibiErrorLog obj = new ChibiErrorLog();
	obj.underrun = IPConnection.unsignedShort(bb.getShort());
	obj.crcError = IPConnection.unsignedShort(bb.getShort());
	obj.noAck = IPConnection.unsignedShort(bb.getShort());
	obj.overflow = IPConnection.unsignedShort(bb.getShort());

	semaphoreWrite.release();
	return obj;
}

public Version getVersion() {
	Version version = new Version();
	version.name = name;
	version.firmwareVersion[0] = firmwareVersion[0];
	version.firmwareVersion[1] = firmwareVersion[1];
	version.firmwareVersion[2] = firmwareVersion[2];
	version.bindingVersion[0] = bindingVersion[0];
	version.bindingVersion[1] = bindingVersion[1];
	version.bindingVersion[2] = bindingVersion[2];

	return version;
}

public void addListener(Object o) {

}
}

 

 

und hier meinen Quelltext den ich versucht habe

 

import com.tinkerforge.BrickMaster;
import com.tinkerforge.IPConnection;

public class ExampleStackStatus {
    private static final String host = new String("localhost");
    private static final int port = 4223;
    private static final String UID = new String("*****"); // Change to your UID
    
    // Note: To make the example code cleaner we do not handle exceptions. Exceptions you
    //       might normally want to catch are described in the commnents below
    public static void main(String args[]) throws Exception {
        // Create connection to brickd
        IPConnection ipcon = new IPConnection(host, port); // Can throw IOException

        BrickMaster master = new BrickMaster(UID); // Create device object

        // Add device to ip connection
        ipcon.addDevice(master); // Can throw IPConnection.TimeoutException
        // Don't use device before it is added to a connection
        
        // Get voltage and current from stack (in mV/mA)
        int voltage = master.getStackVoltage();
        int current = master.getStackCurrent();

if (master.isChibiPresent() == true)
{
	System.out.println("Chibi da");
	short frequenz = master.getChibiFrequency();
	System.out.println(frequenz);
	short kanal = master.getChibiChannel();
	System.out.println(kanal);
}
        System.out.println("Stack Voltage: " + voltage/1000.0 + " V");
        System.out.println("Stack Current: " + current/1000.0 + " A");
        
        System.out.println("Press ctrl+c to exit");
        ipcon.joinThread();
    }
}

 

Ich versteh es nicht ganz...vielleicht siehst du gleich das Problem

 

Gruß

Geschrieben

:o da fehlen ja wirklich die zwei Funktionen! Bei mir lokal waren sie drin und es hatte lokal die gleiche Version wie die letzte online.

 

Bin gerade durchgegangen, es fehlten überall die Funktionen außer bei den Python Bindings. D.h. ich muss überall alles geupdatet haben und dann aus irgendwelchen Gründen habe ich nur die Python Bindings hochgeladen. Oh man :D.

 

Probier es nochmal mit der neuesten Version: http://download.tinkerforge.com/bindings/java/

Geschrieben

soo nun funktionierts wunderbar. ist nur noch die Frage bei 915MHz Kann ich zwar Kanal 5 auswählen, aber speichert bzw ich habs grad mit Java ausgelesen immer Kanal 4.

Er speichert immer Kanal der eingestellt ist -1.

Ich hoffe du kannst mit meiner Schilderung was anfangen.

 

Gruß

Geschrieben

Jop, Danke für den Tipp. Der 915Mhz Bereich fängt bei Channel 1 an (statt 0 wie bei den anderen Frequenzen). Da fehlt einfach ein +1 im Brick Viewer Code. Habs gefixt, werde in nächster Zeit sowieso eine neue brickv Version hochladen (mit RS485 support), da ists dann gefixt.

 

Gleich zwei Bugs auf einmal gefunden, nicht schlecht ;D.

Join the conversation

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

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...