got everything compiling (should still work too) with aos
diff --git a/aos/build/download_externals.sh b/aos/build/download_externals.sh
index ef843e1..5e07d02 100755
--- a/aos/build/download_externals.sh
+++ b/aos/build/download_externals.sh
@@ -60,3 +60,32 @@
CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
bash -c "cd ${CTEMPLATE_DIR} && ./configure --disable-shared \
--prefix=`readlink -f ${CTEMPLATE_PREFIX}` && make && make install"
+
+# get and build gflags
+GFLAGS_VERSION=2.0
+GFLAGS_DIR=${EXTERNALS}/gflags-${GFLAGS_VERSION}
+GFLAGS_PREFIX=${GFLAGS_DIR}-prefix
+GFLAGS_LIB=${GFLAGS_PREFIX}/lib/libgflags.a
+GFLAGS_URL=https://gflags.googlecode.com/files/gflags-${GFLAGS_VERSION}.tar.gz
+[ -f ${GFLAGS_DIR}.tar.gz ] || wget ${GFLAGS_URL} -O ${GFLAGS_DIR}.tar.gz
+[ -d ${GFLAGS_DIR} ] || ( mkdir ${GFLAGS_DIR} && tar \
+ --strip-components=1 -C ${GFLAGS_DIR} -xf ${GFLAGS_DIR}.tar.gz )
+[ -f ${GFLAGS_LIB} ] || env -i PATH="${PATH}" \
+ CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
+ bash -c "cd ${GFLAGS_DIR} && ./configure \
+ --prefix=`readlink -f ${GFLAGS_PREFIX}` && make && make install"
+
+# get and build libusb
+LIBUSB_VERSION=1.0.9
+LIBUSB_APIVERSION=1.0
+LIBUSB_DIR=${EXTERNALS}/libusb-${LIBUSB_VERSION}
+LIBUSB_PREFIX=${LIBUSB_DIR}-prefix
+LIBUSB_LIB=${LIBUSB_PREFIX}/lib/libusb-${LIBUSB_APIVERSION}.a
+LIBUSB_URL=http://sourceforge.net/projects/libusb/files/libusb-${LIBUSB_APIVERSION}/libusb-${LIBUSB_VERSION}/libusb-${LIBUSB_VERSION}.tar.bz2
+[ -f ${LIBUSB_DIR}.tar.bz2 ] || wget ${LIBUSB_URL} -O ${LIBUSB_DIR}.tar.bz2
+[ -d ${LIBUSB_DIR} ] || ( mkdir ${LIBUSB_DIR} && tar \
+ --strip-components=1 -C ${LIBUSB_DIR} -xf ${LIBUSB_DIR}.tar.bz2 )
+[ -f ${LIBUSB_LIB} ] || env -i PATH="${PATH}" \
+ CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
+ bash -c "cd ${LIBUSB_DIR} && ./configure \
+ --prefix=`readlink -f ${LIBUSB_PREFIX}` && make && make install"
diff --git a/aos/build/externals.gyp b/aos/build/externals.gyp
index eb19cd0..ad6a886 100644
--- a/aos/build/externals.gyp
+++ b/aos/build/externals.gyp
@@ -10,6 +10,9 @@
'gtest_version': '1.6.0-p1',
'onejar_version': '0.97',
'ctemplate_version': '2.2',
+ 'gflags_version': '2.0',
+ 'libusb_version': '1.0.9',
+ 'libusb_apiversion': '1.0',
},
'targets': [
{
@@ -139,11 +142,31 @@
'target_name': 'ctemplate',
'type': 'none',
'link_settings': {
- 'libraries': ['<(externals)/ctemplate-<(ctemplate_version)-prefix/lib/libctemplate.a'],
+ 'libraries': ['<(externals_abs)/ctemplate-<(ctemplate_version)-prefix/lib/libctemplate.a'],
},
'direct_dependent_settings': {
'include_dirs': ['<(externals)/ctemplate-<(ctemplate_version)-prefix/include'],
},
},
+ {
+ 'target_name': 'gflags',
+ 'type': 'none',
+ 'link_settings': {
+ 'libraries': ['<(externals_abs)/gflags-<(gflags_version)-prefix/lib/libgflags.a'],
+ },
+ 'direct_dependent_settings': {
+ 'include_dirs': ['<(externals)/gflags-<(gflags_version)-prefix/include'],
+ },
+ },
+ {
+ 'target_name': 'libusb',
+ 'type': 'none',
+ 'link_settings': {
+ 'libraries': ['<(externals_abs)/libusb-<(libusb_version)-prefix/lib/libusb-<(libusb_apiversion).a'],
+ },
+ 'direct_dependent_settings': {
+ 'include_dirs': ['<(externals)/libusb-<(libusb_version)-prefix/include'],
+ },
+ },
],
}
diff --git a/aos/common/common.gyp b/aos/common/common.gyp
index 967eb51..4265b18 100644
--- a/aos/common/common.gyp
+++ b/aos/common/common.gyp
@@ -151,6 +151,7 @@
'queue_testutils',
'common',
'queue_test_queue',
+ '<(AOS)/common/util/util.gyp:thread',
],
},
{
diff --git a/aos/common/queue_test.cc b/aos/common/queue_test.cc
index b24fcd5..65a1c25 100644
--- a/aos/common/queue_test.cc
+++ b/aos/common/queue_test.cc
@@ -5,53 +5,12 @@
#include "gtest/gtest.h"
#include "aos/common/test_queue.q.h"
#include "aos/common/queue_testutils.h"
-
+#include "aos/common/util/thread.h"
using ::aos::time::Time;
namespace aos {
namespace common {
-
-// TODO(aschuh): Pull this out somewhere and test it.
-class Thread {
- public:
- Thread () {
- started_ = false;
- joined_ = false;
- }
-
- ~Thread() {
- if (!joined_ && started_) {
- assert(false);
- }
- }
-
- void Start() {
- assert(!started_);
- pthread_create(&thread_, NULL, &Thread::StaticRun, this);
- started_ = true;
- }
-
- virtual void Run() = 0;
-
- void Join() {
- assert(!joined_);
- pthread_join(thread_, NULL);
- joined_ = true;
- }
- private:
- static void *StaticRun(void *thread_class) {
- static_cast<Thread *>(thread_class)->Run();
- return NULL;
- }
-
- pthread_t thread_;
- bool started_;
- bool joined_;
-
- DISALLOW_COPY_AND_ASSIGN(Thread);
-};
-
namespace testing {
class QueueTest : public ::testing::Test {
@@ -65,7 +24,7 @@
QueueTest() : my_test_queue(".aos.common.testing.test_queue") {}
};
-class MyThread : public Thread {
+class MyThread : public util::Thread {
public:
MyThread() : threaded_test_queue(".aos.common.testing.test_queue") {}
diff --git a/aos/common/util/thread.cc b/aos/common/util/thread.cc
new file mode 100644
index 0000000..fab62eb
--- /dev/null
+++ b/aos/common/util/thread.cc
@@ -0,0 +1,39 @@
+#include "aos/common/util/thread.h"
+
+#include <pthread.h>
+#include <assert.h>
+
+namespace aos {
+namespace util {
+
+Thread::Thread() : started_(false), joined_(false), should_terminate_(false) {}
+
+Thread::~Thread() {
+ if (started_ && !joined_) {
+ assert(false);
+ }
+}
+
+void Thread::Start() {
+ assert(!started_);
+ started_ = true;
+ assert(pthread_create(&thread_, NULL, &Thread::StaticRun, this) == 0);
+}
+
+void Thread::Join() {
+ assert(!joined_ && started_);
+ joined_ = true;
+ {
+ MutexLocker locker(&should_terminate_mutex_);
+ should_terminate_ = true;
+ }
+ assert(pthread_join(thread_, NULL) == 0);
+}
+
+void *Thread::StaticRun(void *self) {
+ static_cast<Thread *>(self)->Run();
+ return NULL;
+}
+
+} // namespace util
+} // namespace aos
diff --git a/aos/common/util/thread.h b/aos/common/util/thread.h
new file mode 100644
index 0000000..10867ec
--- /dev/null
+++ b/aos/common/util/thread.h
@@ -0,0 +1,50 @@
+#ifndef AOS_COMMON_UTIL_THREAD_H_
+#define AOS_COMMON_UTIL_THREAD_H_
+
+#include "aos/common/mutex.h"
+
+namespace aos {
+namespace util {
+
+// A nice wrapper around a pthreads thread.
+//
+// TODO(aschuh): Test this.
+class Thread {
+ public:
+ Thread();
+ ~Thread();
+
+ // Actually creates the thread.
+ void Start();
+
+ // Asks the code to stop and then waits until it has done so.
+ void Join();
+
+ protected:
+ // Subclasses need to call this periodically if they are going to loop to
+ // check whether they have been asked to stop.
+ bool should_continue() {
+ MutexLocker locker(&should_terminate_mutex_);
+ return !should_terminate_;
+ }
+
+ private:
+ // Where subclasses actually do something.
+ //
+ // They should not block for long periods of time without checking
+ // should_continue().
+ virtual void Run() = 0;
+
+ static void *StaticRun(void *self);
+
+ pthread_t thread_;
+ bool started_;
+ bool joined_;
+ bool should_terminate_;
+ Mutex should_terminate_mutex_;
+};
+
+} // namespace util
+} // namespace aos
+
+#endif // AOS_COMMON_UTIL_THREAD_H_
diff --git a/aos/common/util/util.gyp b/aos/common/util/util.gyp
index 15f868f..c00b9e3 100644
--- a/aos/common/util/util.gyp
+++ b/aos/common/util/util.gyp
@@ -1,6 +1,19 @@
{
'targets': [
{
+ 'target_name': 'thread',
+ 'type': 'static_library',
+ 'sources': [
+ 'thread.cc',
+ ],
+ 'dependencies': [
+ '<(AOS)/common/common.gyp:mutex',
+ ],
+ 'export_dependent_settings': [
+ '<(AOS)/common/common.gyp:mutex',
+ ],
+ },
+ {
'target_name': 'trapezoid_profile',
'type': 'static_library',
'sources': [
diff --git a/aos/externals/.gitignore b/aos/externals/.gitignore
index 3417a33..7f6c98d 100644
--- a/aos/externals/.gitignore
+++ b/aos/externals/.gitignore
@@ -15,3 +15,9 @@
/libjpeg/
/ninja/
/one-jar-boot-0.97.jar
+/gflags-2.0-prefix/
+/gflags-2.0.tar.gz
+/gflags-2.0/
+/libusb-1.0.9-prefix/
+/libusb-1.0.9.tar.bz2
+/libusb-1.0.9/
diff --git a/frc971/atom_code/atom_code.gyp b/frc971/atom_code/atom_code.gyp
index d727036..b84dd95 100644
--- a/frc971/atom_code/atom_code.gyp
+++ b/frc971/atom_code/atom_code.gyp
@@ -13,6 +13,7 @@
'../output/output.gyp:MotorWriter',
'../output/output.gyp:CameraServer',
'camera/camera.gyp:frc971',
+ '../../gyro_board/src/libusb-driver/libusb-driver.gyp:get',
],
'copies': [
{
diff --git a/gyro_board/src/libusb-driver/Makefile b/gyro_board/src/libusb-driver/Makefile
deleted file mode 100644
index 707fa0c..0000000
--- a/gyro_board/src/libusb-driver/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-SRCS = get.cc libusb_wrap.cc signal_handler.cc thread.cc
-CFLAGS = -I./ -I/usr/include/libusb-1.0 -g -std=gnu++0x
-LDFLAGS = -g -lgflags -lglog -lusb-1.0 -lboost_thread-mt -lrt
-
-get: $(SRCS:.cc=.o)
- g++ $^ -o $@ $(LDFLAGS)
-
-%.o: %.cc
- g++ -MMD -MP -c $(CFLAGS) $< -o $@
-
-clean:
- $(RM) $(SRCS:.cc=.o) $(SRCS:.cc=.d) get
-
-.PHONY: clean
--include $(SRCS:.cc=.d)
diff --git a/gyro_board/src/libusb-driver/get.cc b/gyro_board/src/libusb-driver/get.cc
index 5922958..f2ad2f8 100644
--- a/gyro_board/src/libusb-driver/get.cc
+++ b/gyro_board/src/libusb-driver/get.cc
@@ -1,15 +1,17 @@
#include "get.h"
-#include <google/gflags.h>
-#include <glog/logging.h>
-#include <iostream>
-#include <signal.h>
#include <stdio.h>
-#include <queue>
#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+
+#include <queue>
+#include <iostream>
#include <map>
-#include "signal_handler.h"
+#include <google/gflags.h>
+#include "aos/common/mutex.h"
+#include "aos/common/logging/logging_impl.h"
DEFINE_int32(vid, 0x1424, "Vendor ID of the device.");
DEFINE_int32(pid, 0xd243, "Product ID of the device.");
@@ -65,7 +67,7 @@
}
}
-class GyroDriver::PacketReceiver : public Thread {
+class GyroDriver::PacketReceiver : public ::aos::util::Thread {
public:
// refusing to send any more frames.
static const int kMaxRXFrames = 128;
@@ -74,7 +76,7 @@
: Thread(), dev_handle_(dev_handle), rx_queue_(new can_priority_queue) {}
// Serve.
- void operator()();
+ virtual void Run();
bool GetCanFrame(struct can_frame *msg);
@@ -84,16 +86,13 @@
can_frame_priority_comparator> can_priority_queue;
LibUSBDeviceHandle *dev_handle_;
- boost::mutex rx_mutex_;
+ ::aos::Mutex rx_mutex_;
std::unique_ptr<can_priority_queue> rx_queue_;
- //boost::condition_variable rx_cond_;
};
GyroDriver::GyroDriver(LibUSBDeviceHandle *dev_handle)
: dev_handle_(dev_handle), dbg_(new DbgReader(this)),
- debug_thread_(new boost::thread(boost::ref(*dbg_))),
- rx_(new GyroDriver::PacketReceiver(dev_handle)),
- rx_thread_(new boost::thread(boost::ref(*rx_))) { }
+ rx_(new GyroDriver::PacketReceiver(dev_handle)) {}
std::string GyroDriver::GetDebugData() {
@@ -106,15 +105,9 @@
return std::string(data, transferred);
}
-void GyroDriver::Terminate() {
- rx_->Terminate();
-}
-
GyroDriver::~GyroDriver() {
- rx_->Terminate();
- rx_thread_->join();
- dbg_->Terminate();
- debug_thread_->join();
+ rx_->Join();
+ dbg_->Join();
}
//bool GyroDriver::GetCanFrame(struct can_frame *msg) {
@@ -151,24 +144,29 @@
int8_t shooter_angle_rise_count;
} __attribute__((__packed__));
-void GyroDriver::PacketReceiver::operator()() {
- int r;
- int actual;
- uint8_t data[64];
+void GyroDriver::PacketReceiver::Run() {
+ int r;
+ int actual;
+ uint8_t data[64];
DataStruct *real_data;
- real_data = (DataStruct *)data;
+ static_assert(sizeof(*real_data) <= sizeof(data), "it doesn't fit");
+
+ uint8_t *data_pointer = data;
+ memcpy(&real_data, &data_pointer, sizeof(data_pointer));
- while (should_run()) {
+ while (should_continue()) {
r = dev_handle_->interrupt_transfer(
0x81, data, sizeof(data), &actual, 1000);
printf("size: %d\n",sizeof(DataStruct));
- CHECK_GT(actual, 0);
-
- if (r != 0) {
- LOG(ERROR) << "Read Error. Read " << actual;
+ if (actual <= 0) {
+ LOG(FATAL, "didn't get any data\n");
}
- printf("angle: %d\n", real_data->gyro_angle);
+ if (r != 0) {
+ LOG(ERROR, "Read Error. Read %d\n", actual);
+ }
+
+ printf("angle: %"PRId64"\n", real_data->gyro_angle);
printf("drivel: %d\n", real_data->left_drive);
printf("driver: %d\n", real_data->right_drive);
printf("shooter: %d\n", real_data->shooter);
@@ -197,33 +195,33 @@
//}
}
//rx_cond_.notify_all();
- LOG(INFO) << "Receive thread down.";
+ LOG(INFO, "Receive thread down.");
}
DbgReader::DbgReader(GyroDriver *gyro)
: Thread(), gyro_(gyro) {}
-void DbgReader::operator()() {
- unsigned char data[64];
- LOG(INFO) << "Running debug dump thread.";
- while (should_run()) {
+void DbgReader::Run() {
+ LOG(INFO, "Running debug dump thread.");
+ while (should_continue()) {
printf("%s", gyro_->GetDebugData().c_str());
}
- LOG(INFO) << "Exiting debug dump thread.";
+ LOG(INFO, "Exiting debug dump thread.");
}
int main(int argc, char ** argv) {
- int r;
- google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
- google::InstallFailureSignalHandler();
+ ::aos::logging::Init();
LibUSB libusb;
{
std::unique_ptr<LibUSBDeviceHandle> dev_handle(
- CHECK_NOTNULL(libusb.FindDeviceWithVIDPID(FLAGS_vid, FLAGS_pid)));
+ libusb.FindDeviceWithVIDPID(FLAGS_vid, FLAGS_pid));
+ if (!dev_handle) {
+ LOG(FATAL, "couldn't find device\n");
+ }
GyroDriver gyro(dev_handle.release());
diff --git a/gyro_board/src/libusb-driver/get.h b/gyro_board/src/libusb-driver/get.h
index c0ed6a6..62462d3 100644
--- a/gyro_board/src/libusb-driver/get.h
+++ b/gyro_board/src/libusb-driver/get.h
@@ -3,11 +3,11 @@
#include <sys/socket.h>
#include <linux/can.h>
-#include <memory>
-#include <boost/thread/locks.hpp>
-#include <boost/thread.hpp>
-#include "thread.h"
+#include <memory>
+
+#include "aos/common/util/thread.h"
+
#include "libusb_wrap.h"
// Use a packed version of can_frame.
@@ -61,8 +61,6 @@
// Handle for the object run in the debug thread which prints out debug
// information.
std::unique_ptr<DbgReader> dbg_;
- // Thread handle for the debug thread.
- std::unique_ptr<boost::thread> debug_thread_;
// Handle for the transmit object which runs in the transmit thread and also
// handles priority queueing of packets.
@@ -73,16 +71,14 @@
// Handle for the rx object which runs in the rx thread and also
// handles priority queueing of packets.
std::unique_ptr<PacketReceiver> rx_;
- // Thread handle for the receive thread.
- std::unique_ptr<boost::thread> rx_thread_;
};
-class DbgReader : public Thread {
+class DbgReader : public ::aos::util::Thread {
public:
explicit DbgReader(GyroDriver *dev_handle);
// Serve.
- void operator()();
+ virtual void Run();
private:
GyroDriver *gyro_;
diff --git a/gyro_board/src/libusb-driver/libusb-driver.gyp b/gyro_board/src/libusb-driver/libusb-driver.gyp
new file mode 100644
index 0000000..1c50633
--- /dev/null
+++ b/gyro_board/src/libusb-driver/libusb-driver.gyp
@@ -0,0 +1,31 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'get',
+ 'type': 'executable',
+ 'sources': [
+ 'get.cc',
+ ],
+ 'dependencies': [
+ '<(EXTERNALS):gflags',
+ '<(AOS)/common/util/util.gyp:thread',
+ 'libusb_wrap',
+ '<(AOS)/build/aos.gyp:logging',
+ ],
+ },
+ {
+ 'target_name': 'libusb_wrap',
+ 'type': 'static_library',
+ 'sources': [
+ 'libusb_wrap.cc',
+ ],
+ 'dependencies': [
+ '<(EXTERNALS):libusb',
+ '<(AOS)/build/aos.gyp:logging',
+ ],
+ 'export_dependent_settings': [
+ '<(EXTERNALS):libusb',
+ ],
+ },
+ ],
+}
diff --git a/gyro_board/src/libusb-driver/libusb_wrap.cc b/gyro_board/src/libusb-driver/libusb_wrap.cc
index 1f54998..d8161ab 100644
--- a/gyro_board/src/libusb-driver/libusb_wrap.cc
+++ b/gyro_board/src/libusb-driver/libusb_wrap.cc
@@ -1,12 +1,13 @@
-#include <libusb.h>
-#include <google/gflags.h>
-#include <glog/logging.h>
-#include <iostream>
-
#include "libusb_wrap.h"
+#include <iostream>
+
+#include "aos/common/logging/logging.h"
+
LibUSB::LibUSB() {
- CHECK_GE(libusb_init(&ctx_), 0) << ": LibUSB failed to initialize.";
+ if (libusb_init(&ctx_) < 0) {
+ LOG(FATAL, "libusb_init(%p) failed\n", &ctx_);
+ }
libusb_set_debug(ctx_, 3);
}
@@ -17,26 +18,30 @@
ssize_t cnt;
cnt = libusb_get_device_list(ctx_, &devs);
- if(cnt < 0) {
- LOG(ERROR) << "Get Device Error";
+ if (cnt < 0) {
+ LOG(ERROR, "Get Device Error\n");
return NULL;
}
- LOG(INFO) << cnt << " Devices in list.";
+ LOG(INFO, "%d Devices in list.\n", cnt);
bool found = false;
for (int i = 0; i < cnt; ++i) {
struct libusb_device_descriptor desc;
r = libusb_get_device_descriptor(devs[i], &desc);
- CHECK_GE(r, 0) << ": Couldn't get device descriptor, error " << r;
+ if (r < 0) {
+ LOG(FATAL, "lib_usb_get_device_descriptor(%p, %p) failed\n",
+ devs[i], &desc);
+ }
if (desc.idVendor == vid && desc.idProduct == pid) {
- LOG(INFO) << "Device " << (int)libusb_get_bus_number(devs[i]) << ":"
- << (int)libusb_get_device_address(devs[i]) << " matches";
+ LOG(INFO, "Device %d:%d matches\n",
+ (int)libusb_get_bus_number(devs[i]),
+ (int)libusb_get_device_address(devs[i]));
r = libusb_open(devs[i], &dev_handle);
if (libusb_kernel_driver_active(dev_handle, 0) == 1) {
- LOG(INFO) << "Device already in use, trying next one.";
+ LOG(INFO, "Device already in use, trying next one.");
continue;
}
if (r < 0) {
- LOG(WARNING) << "Failed to open device.";
+ LOG(WARNING, "Failed to open device.");
} else {
found = true;
break;
@@ -45,26 +50,26 @@
}
libusb_free_device_list(devs, 1);
if (!found) {
- LOG(ERROR) << "Couldn't open device.";
+ LOG(ERROR, "Couldn't open device.");
return NULL;
}
if (libusb_kernel_driver_active(dev_handle, 0) == 1) {
- LOG(INFO) << "Kernel Driver Active";
+ LOG(INFO, "Kernel Driver Active");
if (libusb_detach_kernel_driver(dev_handle, 0) == 0) {
- LOG(INFO) << "Kernel Driver Detached!";
+ LOG(INFO, "Kernel Driver Detached!");
} else {
- LOG(ERROR) << "Couldn't detach kernel driver.";
+ LOG(ERROR, "Couldn't detach kernel driver.");
return NULL;
}
}
r = libusb_claim_interface(dev_handle, 0);
if (r < 0) {
- LOG(ERROR) << "Cannot Claim Interface";
+ LOG(ERROR, "Cannot Claim Interface");
return 0;
}
- LOG(INFO) << "Claimed Interface";
+ LOG(INFO, "Claimed Interface");
return new LibUSBDeviceHandle(dev_handle);
}
@@ -79,9 +84,9 @@
int r;
r = libusb_release_interface(dev_handle_, 0);
if (r != 0) {
- LOG(FATAL) << "Cannot Release Interface";
+ LOG(FATAL, "Cannot Release Interface");
}
- LOG(INFO) << "Released Interface";
+ LOG(INFO, "Released Interface");
libusb_close(dev_handle_);
}
diff --git a/gyro_board/src/libusb-driver/libusb_wrap.h b/gyro_board/src/libusb-driver/libusb_wrap.h
index f87f235..074408d 100644
--- a/gyro_board/src/libusb-driver/libusb_wrap.h
+++ b/gyro_board/src/libusb-driver/libusb_wrap.h
@@ -1,7 +1,7 @@
#ifndef LIBUSB_H_
#define LIBUSB_H_
-#include <libusb.h>
+#include <libusb-1.0/libusb.h>
class LibUSBDeviceHandle;
diff --git a/gyro_board/src/libusb-driver/signal_handler.cc b/gyro_board/src/libusb-driver/signal_handler.cc
deleted file mode 100644
index ffb1b99..0000000
--- a/gyro_board/src/libusb-driver/signal_handler.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "signal_handler.h"
-
-#include <boost/thread/locks.hpp>
-#include <boost/thread.hpp>
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <google/gflags.h>
-#include <glog/logging.h>
-#include <iostream>
-#include <signal.h>
-#include <stdio.h>
-#include <sys/socket.h>
-#include <linux/can.h>
-#include <memory>
-#include <queue>
-#include <unistd.h>
-
-#include "thread.h"
-
-// Boolean signaling if the handler has been set up or not.
-static bool pipe_has_been_initialized = false;
-
-// Pipe that the signal handler writes the signal number to
-static int handler_write_pipe;
-// Pipe that the handler thread reads the signal number from.
-static int thread_read_pipe;
-// Mutex to lock the signal handler dictionary.
-static boost::mutex signal_dict_lock;
-// Signal handler dictionary.
-static std::unique_ptr<std::map<int, boost::function<void(int)> > > signal_dict;
-
-// Thread which reads signal numbers from the pipe and handles them.
-class SignalHandlerThread: public Thread {
- public:
- void operator()() {
- while (true) {
- int signal_number;
- LOG(INFO) << "Back to waiting.";
- int size = read(thread_read_pipe, &signal_number, sizeof(int));
- if (size == -1) {
- continue;
- }
- CHECK_EQ(size, sizeof(int))
- << ": Read the wrong number of bytes when receiving a signal.";
- LOG(INFO) << "Got signal " << signal_number;
-
- boost::function<void(int)> function;
- if (GetFromMap(*signal_dict, signal_number, &function)) {
- function(signal_number);
- }
- }
- }
-};
-
-static std::unique_ptr<SignalHandlerThread> signal_handler_thread;
-static std::unique_ptr<boost::thread> signal_handler_thread_;
-
-// Simple signal handler which writes the signal number to the pipe.
-static void signal_handler(int signal_number) {
- CHECK_EQ(write(handler_write_pipe, &signal_number, sizeof(int)),
- sizeof(int));
-}
-
-void RegisterSignalHandler(int signal_number,
- boost::function<void(int)> function){
- if (!pipe_has_been_initialized) {
- int pipefd[2];
- CHECK(!pipe2(pipefd, 0))
- << ": Failed to create pipes for signal handler.";
- thread_read_pipe = pipefd[0];
- handler_write_pipe = pipefd[1];
- signal_handler_thread.reset(new SignalHandlerThread());
- signal_handler_thread_.reset(
- new boost::thread(boost::ref(*signal_handler_thread)));
- signal_dict.reset(new std::map<int, boost::function<void(int)> >());
- }
- struct sigaction new_action, old_action;
-
- new_action.sa_handler = &signal_handler;
- sigemptyset(&new_action.sa_mask);
-
- boost::lock_guard<boost::mutex> lockguard(signal_dict_lock);
-
- InsertIntoMap(signal_dict.get(), signal_number, function);
-
- sigaction(signal_number, &new_action, NULL);
-}
diff --git a/gyro_board/src/libusb-driver/signal_handler.h b/gyro_board/src/libusb-driver/signal_handler.h
deleted file mode 100644
index fbc8a37..0000000
--- a/gyro_board/src/libusb-driver/signal_handler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef SIGNAL_HANDLER_H_
-#define SIGNAL_HANDLER_H_
-
-#include <boost/function.hpp>
-#include <map>
-
-// TODO(aschuh): Template std::map as well.
-// Maps the key to the value, inserting it if it isn't there, or replacing it if
-// it is. Returns true if the key was added and false if it was replaced.
-template <typename K, typename V>
-bool InsertIntoMap(std::map<K, V> *my_map, const K &key, const V &new_value) {
- std::pair<typename std::map<K, V>::iterator, bool> element;
- element = my_map->insert(std::pair<K,V>(key, new_value));
- if (element.second == false) {
- element.first->second = new_value;
- }
- return element.second;
-}
-
-// Gets the value for the key from the map.
-// Returns true if the key was found and then populates value with the value.
-// Otherwise, leaves value alone and returns false.
-template <typename K, typename V>
-bool GetFromMap(const std::map<K, V> &my_map, const K &key, V *value) {
- typename std::map<K, V>::const_iterator element = my_map.find(key);
- if (element != my_map.end()) {
- *value = element->second;
- return true;
- }
- return false;
-}
-
-
-// Registers a signal handler to be run when we get the specified signal.
-// The handler will run in a thread, rather than in the signal's context.
-void RegisterSignalHandler(int signal_number,
- boost::function<void(int)> function);
-
-#endif // SIGNAL_HANDLER_H_
diff --git a/gyro_board/src/libusb-driver/thread.cc b/gyro_board/src/libusb-driver/thread.cc
deleted file mode 100644
index 0121f35..0000000
--- a/gyro_board/src/libusb-driver/thread.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "thread.h"
-
-#include <boost/bind.hpp>
-
-
-void Thread::Terminate() {
- boost::lock_guard<boost::mutex> lockguard(terminate_mutex_);
- should_terminate_ = true;
-}
-
-bool Thread::should_run() {
- boost::lock_guard<boost::mutex> lockguard(terminate_mutex_);
- return !should_terminate_;
-}
diff --git a/gyro_board/src/libusb-driver/thread.h b/gyro_board/src/libusb-driver/thread.h
deleted file mode 100644
index 1e94777..0000000
--- a/gyro_board/src/libusb-driver/thread.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef THREAD_H_
-#define THREAD_H_
-
-#include <sys/socket.h>
-#include <linux/can.h>
-#include <boost/thread/locks.hpp>
-#include <boost/thread.hpp>
-
-class Thread {
- public:
- // Constructer initializes terminate to false.
- Thread() : should_terminate_(false) {}
-
- // Terminate the thread soon.
- void Terminate();
-
- protected:
- // Helper method to atomically read the should_terminate_ boolean.
- bool should_run();
-
- private:
- // Stores whether or not the thread has been asked to quit.
- // TODO(aschuh): This really should be a Notification...
- bool should_terminate_;
- // Mutex to protect should_terminate.
- boost::mutex terminate_mutex_;
-};
-
-#endif // THREAD_H_
diff --git a/gyro_board/src/usb/Makefile b/gyro_board/src/usb/Makefile
index 7b20a72..b91b6a5 100644
--- a/gyro_board/src/usb/Makefile
+++ b/gyro_board/src/usb/Makefile
@@ -58,7 +58,7 @@
@cd ../../bin; python serial_looper.py
assm.S: $(NAME).elf
- $(OBJDUMP) -D -S $(NAME).elf > assm.S
+ $(OBJDUMP) -D -S $(NAME).elf > $@
%.hex: %.elf Makefile
$(OBJCOPY) -O ihex $< $@