Skip to content

Commit

Permalink
Sync-up with Java Crazyflie lib
Browse files Browse the repository at this point in the history
  • Loading branch information
fredg02 committed Dec 29, 2016
1 parent c88ee26 commit 80dd0d8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/se/bitcraze/crazyflie/lib/bootloader/Bootloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import se.bitcraze.crazyflie.lib.bootloader.Target.TargetTypes;
import se.bitcraze.crazyflie.lib.bootloader.Utilities.BootVersion;
import se.bitcraze.crazyflie.lib.crazyradio.ConnectionData;
import se.bitcraze.crazyflie.lib.crtp.CrtpDriver;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import se.bitcraze.crazyflie.lib.bootloader.Target.TargetTypes;
import se.bitcraze.crazyflie.lib.bootloader.Utilities.BootVersion;
import se.bitcraze.crazyflie.lib.crazyradio.ConnectionData;
import se.bitcraze.crazyflie.lib.crtp.CrtpDriver;

/**
* Bootloading utilities for the Crazyflie.
*
Expand Down
2 changes: 1 addition & 1 deletion src/se/bitcraze/crazyflie/lib/bootloader/Cloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
import se.bitcraze.crazyflie.lib.crazyradio.RadioDriver;
import se.bitcraze.crazyflie.lib.crtp.CrtpDriver;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket.Header;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;

/**
* Crazyflie radio bootloader for flashing firmware.
Expand Down
6 changes: 6 additions & 0 deletions src/se/bitcraze/crazyflie/lib/crazyflie/DataListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@

/**
* Interface for receiving notifications about data received from the Crazyflie.
*
* TODO:
* -add channel?
* -add port mask (or use CrtpPort.ALL?)
* -add channel mask
*
*/
public abstract class DataListener {

Expand Down
4 changes: 2 additions & 2 deletions src/se/bitcraze/crazyflie/lib/crtp/CommanderPacket.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
Expand Down
10 changes: 7 additions & 3 deletions src/se/bitcraze/crazyflie/lib/log/Logg.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
import se.bitcraze.crazyflie.lib.crazyflie.Crazyflie;
import se.bitcraze.crazyflie.lib.crazyflie.DataListener;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket.Header;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.toc.Toc;
import se.bitcraze.crazyflie.lib.toc.TocCache;
import se.bitcraze.crazyflie.lib.toc.TocElement;
import se.bitcraze.crazyflie.lib.toc.TocFetchFinishedListener;
import se.bitcraze.crazyflie.lib.toc.TocFetcher;
import se.bitcraze.crazyflie.lib.toc.TocFetchFinishedListener;
import se.bitcraze.crazyflie.lib.toc.VariableType;

//TODO: find better name
Expand Down Expand Up @@ -448,6 +448,10 @@ public void create(LogConfig logConfig) {
noOfLogVariables++;
} else { // Item in TOC
String name = variable.getName();
if (mToc == null) {
mLogger.error("TOC is null.");
return;
}
int tocElementId = mToc.getElementId(name);
if (tocElementId == -1) {
mLogger.error("Toc element " + name + " not found in TOC.");
Expand All @@ -459,7 +463,7 @@ public void create(LogConfig logConfig) {
if (logTocElement != null) {
int variableTypeId = logTocElement.getVariableTypeId();
if (variableTypeId == -1) {
mLogger.error("VariableType " + variableType.name() + " not found in LogTocElement.VARIABLE_TYPE_MAP.");
mLogger.error("No variableType found for TOC element " + logTocElement.getCompleteName() + ".");
//TODO: notifyLogError(logConfig);?
//TODO: return instead?
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/se/bitcraze/crazyflie/lib/param/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
import se.bitcraze.crazyflie.lib.crazyflie.Crazyflie;
import se.bitcraze.crazyflie.lib.crazyflie.DataListener;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket.Header;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.toc.Toc;
import se.bitcraze.crazyflie.lib.toc.TocCache;
import se.bitcraze.crazyflie.lib.toc.TocElement;
import se.bitcraze.crazyflie.lib.toc.TocFetchFinishedListener;
import se.bitcraze.crazyflie.lib.toc.TocFetcher;
import se.bitcraze.crazyflie.lib.toc.TocFetchFinishedListener;

/**
* Enables reading/writing of parameter values to/from the Crazyflie.
Expand Down
10 changes: 6 additions & 4 deletions src/se/bitcraze/crazyflie/lib/toc/TocFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import se.bitcraze.crazyflie.lib.crazyflie.Crazyflie;
import se.bitcraze.crazyflie.lib.crazyflie.DataListener;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.crtp.CrtpPacket.Header;
import se.bitcraze.crazyflie.lib.crtp.CrtpPort;
import se.bitcraze.crazyflie.lib.log.LogTocElement;
import se.bitcraze.crazyflie.lib.param.ParamTocElement;

Expand Down Expand Up @@ -116,9 +116,9 @@ public TocState getState() {
return this.mState;
}

// TODO: only for testing, try to remove
public void setState(TocState state) {
this.mState = state;
// TODO: only for testing?
public int getNoOfItems() {
return this.mNoOfItems;
}

public void newPacketReceived(CrtpPacket packet) {
Expand All @@ -136,6 +136,7 @@ public void newPacketReceived(CrtpPacket packet) {
if (packet.getPayload()[0] == CMD_TOC_INFO) {
// [self.nbr_of_items, self._crc] = struct.unpack("<BI", payload[:5])
this.mNoOfItems = payloadBuffer.get();
// Fix for TOC > 128 items (fixed by Arnaud)
this.mNoOfItems &= 0x00ff;
this.mCrc = payloadBuffer.getInt();
mToc.setCrc(mCrc);
Expand Down Expand Up @@ -163,6 +164,7 @@ public void newPacketReceived(CrtpPacket packet) {
// Always add new element, but only request new if it's not the last one.

// if self.requested_index != ord(payload[0]):
// Fix for TOC > 128 items (fixed by Arnaud)
if (this.mRequestedIndex != (payloadBuffer.get(0) & 0x00ff)) {
/*
# TODO: There might be a timing issue here with resending old
Expand Down

0 comments on commit 80dd0d8

Please sign in to comment.