use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.
the class DyIOChannel method resync.
/**
* Live query the device for its mode and cache it.
*
* @param all - should all channels be refreshed.
*/
public void resync(boolean all) {
if (all) {
getDevice().resync();
return;
}
BowlerDatagram bd = getDevice().send(new GetChannelModeCommand(number));
// System.out.println(bd);
fireModeChangeEvent(DyIOChannelMode.get(bd.getData().getByte(1)));
throw new RuntimeException();
}
use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.
the class DyIOChannel method getValue.
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.dyio.IDyIOChannel#getValue()
*/
public int getValue() {
int val = 0;
if (getDevice().isLegacyParser()) {
BowlerDatagram response = null;
try {
response = getDevice().send(new GetValueCommand(number));
} catch (InvalidResponseException e) {
response = getDevice().send(new GetValueCommand(number));
}
ByteList bl = response.getData();
Byte b = bl.pop();
if (b == null || b.intValue() != number) {
Log.error("Failed to get value " + response);
return 0;
}
val = new DyIOChannelEvent(this, bl).getValue();
setCachedValue(val);
setPreviousValue(val);
} else {
// Object [] args =getDevice().send("bcs.io.*;0.3;;",
// BowlerMethod.GET,
// "gchv",
// new Object[]{number});
// val=(Integer)args[1];
// Log.debug("Got Value: "+val);
// For the new API the channel values should come in through the asynchronous path.
val = getPreviousValue();
}
return val;
}
use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.
the class BowlerAbstractDeviceServer method sendAsync.
/**
* Send a sendable to the getConnection().
*
* @param sendable the sendable without expecting a response
* @throws IOException
*/
public void sendAsync(BowlerAbstractCommand command, int rpcIndexID) throws IOException {
command.setNamespaceIndex(rpcIndexID);
BowlerDatagram bd = BowlerDatagramFactory.build(getAddress(), command);
// Log.debug("ASYN>>\n"+bd.toString());
getConnection().sendAsync(bd);
getConnection().getDataOuts().flush();
}
use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.
the class NRBootLoader method reset.
public void reset() {
// We expect this to fail the connection.
// No response is expected
// Disconnect afterwards
BowlerDatagram bd = BowlerDatagramFactory.build(getAddress(), new ResetChipCommand());
try {
getConnection().sendAsync(bd);
getConnection().getDataOuts().flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
disconnect();
}
use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.
the class NRBootLoader method getBootloaderID.
public String getBootloaderID() {
BowlerDatagram back = send(new BootloaderIDCommand());
if (back == null)
return null;
String s = new String();
for (Byte b : back.getData()) {
s += (char) b.byteValue();
}
return s;
}
Aggregations