removed libusb and most of the old gyro board code
diff --git a/.gitignore b/.gitignore
index 5bfc69f..0d20b64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
 *.pyc
-output/
diff --git a/aos/build/download_externals.sh b/aos/build/download_externals.sh
index 5b759a8..adc0297 100755
--- a/aos/build/download_externals.sh
+++ b/aos/build/download_externals.sh
@@ -112,21 +112,6 @@
   ${CONFIGURE_FLAGS} --prefix=`readlink -f ${GFLAGS_PREFIX}` \
   && make && make install"
 
-# get and build libusb
-LIBUSB_VERSION=1.0.9
-LIBUSB_APIVERSION=1.0
-LIBUSB_TAR=${EXTERNALS}/libusb-${LIBUSB_VERSION}.tar.bz2
-LIBUSB_DIR=${COMPILED}/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_TAR} ] || wget ${LIBUSB_URL} -O ${LIBUSB_TAR}
-[ -d ${LIBUSB_DIR} ] || ( mkdir ${LIBUSB_DIR} && tar \
-  --strip-components=1 -C ${LIBUSB_DIR} -xf ${LIBUSB_TAR} )
-[ -f ${LIBUSB_LIB} ] || bash -c "cd ${LIBUSB_DIR} && ./configure \
-	${CONFIGURE_FLAGS} --prefix=`readlink -f ${LIBUSB_PREFIX}` \
-	&& make && make install"
-
 # get the LLVM Compiler-RT source
 COMPILER_RT_TAG=RELEASE_32/final
 COMPILER_RT_VERSION=`echo ${COMPILER_RT_TAG} | sed s:/:_:`
diff --git a/aos/build/externals.gyp b/aos/build/externals.gyp
index 836ddde..695fc9f 100644
--- a/aos/build/externals.gyp
+++ b/aos/build/externals.gyp
@@ -13,8 +13,6 @@
     'onejar_version': '0.97',
     'ctemplate_version': '129',
     'gflags_version': '2.0',
-    'libusb_version': '1.0.9',
-    'libusb_apiversion': '1.0',
     'compiler_rt_version': 'RELEASE_32_final',
     'libevent_version': '2.0.21',
     'libcdd_version': '094g',
@@ -204,19 +202,6 @@
       },
     },
     {
-      'target_name': 'libusb',
-      'type': 'none',
-      'link_settings': {
-        'libraries': ['<(compiled_abs)/libusb-<(libusb_version)-prefix/lib/libusb-<(libusb_apiversion).a'],
-      },
-      'direct_dependent_settings': {
-        'include_dirs': ['<(compiled)/libusb-<(libusb_version)-prefix/include'],
-        'cflags': [
-          '-Wno-error=cast-align',
-        ],
-      },
-    },
-    {
       'target_name': 'libcdd',
       'type': 'none',
       'link_settings': {
diff --git a/frc971/input/gyro_board_data.h b/frc971/input/gyro_board_data.h
deleted file mode 100644
index 94200c9..0000000
--- a/frc971/input/gyro_board_data.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef FRC971_INPUT_GYRO_BOARD_DATA_H_
-#define FRC971_INPUT_GYRO_BOARD_DATA_H_
-
-#include <stdint.h>
-
-namespace frc971 {
-
-#define DATA_STRUCT_NAME GyroBoardData
-#include "../../gyro_board/src/usb/data_struct.h"
-#undef DATA_STRUCT_NAME
-
-}  // namespace frc971
-
-#endif  // FRC971_INPUT_GYRO_BOARD_DATA_H_
diff --git a/frc971/input/gyro_sensor_receiver.cc b/frc971/input/sensor_receiver.cc
similarity index 100%
rename from frc971/input/gyro_sensor_receiver.cc
rename to frc971/input/sensor_receiver.cc
diff --git a/frc971/input/usb_receiver.cc b/frc971/input/usb_receiver.cc
deleted file mode 100644
index 06eb7df..0000000
--- a/frc971/input/usb_receiver.cc
+++ /dev/null
@@ -1,272 +0,0 @@
-#include <string.h>
-#include <errno.h>
-#include <inttypes.h>
-
-#include "frc971/input/usb_receiver.h"
-
-#include "aos/common/logging/logging.h"
-#include "aos/common/control_loop/ControlLoop.h"
-
-namespace frc971 {
-
-USBReceiver::USBReceiver(uint8_t expected_robot_id)
-    : expected_robot_id_(expected_robot_id) {
-  Reset();
-}
-
-void USBReceiver::RunIteration() {
-  if (ReceiveData()) {
-    Reset();
-  } else {
-    const ::aos::time::Time timestamp =
-        ::aos::time::Time::InMS(data()->frame_number);
-
-    if (data()->robot_id != expected_robot_id_) {
-      LOG(ERROR, "gyro board sent data for robot id %hhd instead of %hhd!"
-          " dip switches are %hhx\n",
-          data()->robot_id, expected_robot_id_, data()->dip_switches);
-      return;
-    }
-    if (data()->checksum != GYRO_BOARD_DATA_CHECKSUM) {
-      LOG(ERROR,
-          "gyro board sent checksum %" PRIu16 " instead of %" PRIu16 "!\n",
-          data()->checksum, GYRO_BOARD_DATA_CHECKSUM);
-      return;
-    }
-
-    PacketReceived(timestamp);
-
-    if (phase_locker_.IsCurrentPacketGood(transfer_received_time_, frame_number_)) {
-      LOG(DEBUG, "processing dips %hhx frame %" PRId32 " at %f\n",
-          data()->dip_switches, data()->frame_number, timestamp.ToSeconds());
-
-      ProcessData(timestamp);
-    }
-  }
-}
-
-void USBReceiver::PhaseLocker::Reset() {
-  LOG(INFO, "resetting\n");
-  last_good_packet_time_ = ::aos::time::Time(0, 0);
-  last_good_sequence_ = 0;
-  good_phase_ = guess_phase_ = kUnknownPhase;
-  guess_phase_good_ = guess_phase_bad_ = 0;
-  good_phase_early_ = good_phase_late_ = 0;
-}
-
-void USBReceiver::PacketReceived(const ::aos::time::Time &/*timestamp*/) {}
-void USBReceiver::ProcessData(const ::aos::time::Time &/*timestamp*/) {}
-
-bool USBReceiver::PhaseLocker::IsCurrentPacketGood(
-    const ::aos::time::Time &received_time,
-    uint32_t sequence) {
-  if (last_good_packet_time_ != ::aos::time::Time(0, 0) &&
-      received_time - last_good_packet_time_ > kResetTime) {
-    LOG(WARNING, "no good packet received in too long\n");
-    Reset();
-    return false;
-  }
-  if (last_good_sequence_ != 0 && sequence - last_good_sequence_ > 100) {
-    LOG(WARNING, "skipped too many packets\n");
-    Reset();
-    return false;
-  }
-
-  using ::aos::control_loops::kLoopFrequency;
-  // How often we (should) receive packets.
-  static const ::aos::time::Time kPacketFrequency =
-      kLoopFrequency / kPacketsPerLoopCycle;
-  static const ::aos::time::Time kPacketClose =
-      kPacketFrequency * 65 / 100;
-  static const ::aos::time::Time kSwitchOffset =
-      kPacketFrequency * 6 / 10;
-
-  // When we want to receive a packet for the next cycle of control loops.
-  ::aos::time::Time next_desired =
-      ::aos::control_loops::NextLoopTime(received_time) + kDesiredOffset;
-  // If we came up with something more than 1 packet in the past.
-  if (next_desired - received_time < -kPacketFrequency) {
-    next_desired += kLoopFrequency;
-  }
-  // How far off of when we want the next packet this one is.
-  const ::aos::time::Time offset = next_desired - received_time;
-
-  const int received_phase = sequence % kPacketsPerLoopCycle;
-
-  assert(!(good_phase_early_ != 0 && good_phase_late_ != 0));
-
-  if (good_phase_ == kUnknownPhase &&
-      guess_phase_good_ > kMinGoodGuessCycles) {
-    good_phase_ = guess_phase_;
-    if (guess_phase_offset_ < kPacketFrequency / -2) {
-      ++good_phase_;
-    } else if (guess_phase_offset_ > kPacketFrequency / 2) {
-      --good_phase_;
-    }
-    LOG(INFO, "locked on to phase %d\n", good_phase_);
-  } else if (guess_phase_bad_ > kMaxBadGuessCycles) {
-    LOG(INFO, "guessed wrong phase too many times\n");
-    Reset();
-  }
-  if (good_phase_early_ > kSwitchCycles) {
-    good_phase_early_ = 0;
-    LOG(INFO, "switching from phase %d to %d-1\n",
-        good_phase_, good_phase_);
-    --good_phase_;
-  } else if (good_phase_late_ > kSwitchCycles) {
-    good_phase_late_ = 0;
-    LOG(INFO, "switching from phase %d to %d+1\n",
-        good_phase_, good_phase_);
-    ++good_phase_;
-  }
-  if (good_phase_ == kUnknownPhase) {
-    LOG(DEBUG, "guessing which packet is good\n");
-
-    // If it's close to the right time.
-    if (offset.abs() < kPacketClose) {
-      if (guess_phase_ == kUnknownPhase) {
-        if (offset.abs() < kPacketFrequency * 55 / 100) {
-          guess_phase_ = received_phase;
-          guess_phase_offset_ = offset;
-        }
-      } else if (received_phase == guess_phase_) {
-        LOG(DEBUG, "guessed right phase %d\n", received_phase);
-        ++guess_phase_good_;
-        guess_phase_bad_ = 0;
-        guess_phase_offset_ = (guess_phase_offset_ * 9 + offset) / 10;
-      }
-    } else if (guess_phase_ != kUnknownPhase &&
-               received_phase == guess_phase_) {
-      LOG(DEBUG, "guessed wrong phase %d\n", received_phase);
-      ++guess_phase_bad_;
-      guess_phase_good_ = ::std::max(0, guess_phase_good_ -
-                                     (kMinGoodGuessCycles / 10));
-    }
-    return false;
-  } else {  // we know what phase we're looking for
-    // Deal with it if the above logic for tweaking the phase that we're
-    // using wrapped it around.
-    if (good_phase_ == -1) {
-      good_phase_ = kPacketsPerLoopCycle;
-    } else if (good_phase_ == kPacketsPerLoopCycle) {
-      LOG(DEBUG, "dewrapping\n");
-      good_phase_ = 0;
-    }
-    assert(good_phase_ >= 0);
-    assert(good_phase_ < kPacketsPerLoopCycle);
-
-    if (received_phase == good_phase_) {
-      if (offset < -kSwitchOffset) {
-        ++good_phase_early_;
-        good_phase_late_ = 0;
-      } else if (offset > kSwitchOffset) {
-        ++good_phase_late_;
-        good_phase_early_ = 0;
-      } else {
-        good_phase_early_ = good_phase_late_ = 0;
-      }
-      last_good_packet_time_ = received_time;
-      last_good_sequence_ = sequence;
-
-      return true;
-    } else {
-      return false;
-    }
-  }
-}
-
-void USBReceiver::StaticTransferCallback(libusb::Transfer *transfer,
-                                         void *self) {
-  static_cast<USBReceiver *>(self)->TransferCallback(transfer);
-}
-
-void USBReceiver::TransferCallback(libusb::Transfer *transfer) {
-  transfer_received_time_ = ::aos::time::Time::Now();
-  if (transfer->status() == LIBUSB_TRANSFER_COMPLETED) {
-    completed_transfer_ = transfer;
-  } else if (transfer->status() == LIBUSB_TRANSFER_TIMED_OUT) {
-    LOG(WARNING, "transfer %p timed out\n", transfer);
-    completed_transfer_ = kTransferFailed;
-  } else if (transfer->status() == LIBUSB_TRANSFER_CANCELLED) {
-    LOG(DEBUG, "transfer %p cancelled\n", transfer);
-  } else {
-    LOG(FATAL, "transfer %p has status %d\n", transfer, transfer->status());
-  }
-  transfer->Submit();
-}
-
-bool USBReceiver::ReceiveData() {
-  // Loop and then return once we get a good one.
-  while (true) {
-    completed_transfer_ = NULL;
-    while (completed_transfer_ == NULL) {
-      libusb_.HandleEvents();
-    }
-    if (completed_transfer_ == kTransferFailed) {
-      LOG(WARNING, "transfer failed\n");
-      return true;
-    }
-
-    if (completed_transfer_->read_bytes() <
-        static_cast<ssize_t>(sizeof(GyroBoardData))) {
-      LOG(ERROR, "read %d bytes instead of at least %zd\n",
-          completed_transfer_->read_bytes(), sizeof(GyroBoardData));
-      continue;
-    }
-
-    memcpy(data(), completed_transfer_->data(),
-           sizeof(GyroBoardData));
-
-    if (data()->unknown_frame) {
-      LOG(WARNING, "unknown frame number\n");
-      return true;
-    }
-    uint32_t frame_number_before = frame_number_;
-    frame_number_ = data()->frame_number;
-    if (frame_number_ < 0) {
-      LOG(WARNING, "negative frame number %" PRId32 "\n", frame_number_);
-      return true;
-    }
-    if (frame_number_before == 0) {
-      LOG(INFO, "frame number starting at %" PRId32 "\n", frame_number_);
-    } else if (frame_number_ - frame_number_before != 1) {
-      LOG(WARNING, "frame number went from %" PRId32" to %" PRId32 "\n",
-          frame_number_before, frame_number_);
-    }
-    if (frame_number_ < last_frame_number_ - 2) {
-      LOG(WARNING, "frame number went down a lot\n");
-      return true;
-    }
-    last_frame_number_ = frame_number_;
-
-    return false;
-  }
-}
-
-void USBReceiver::Reset() {
-  typedef ::std::unique_ptr<libusb::IsochronousTransfer> TransferType;
-  for (TransferType &c : transfers_) {
-    c.reset();
-  }
-  dev_handle_ = ::std::unique_ptr<LibUSBDeviceHandle>(
-      libusb_.FindDeviceWithVIDPID(kVid, kPid));
-  if (!dev_handle_) {
-    LOG(ERROR, "couldn't find device. exiting\n");
-    exit(1);
-  }
-  for (TransferType &c : transfers_) {
-    c.reset(new libusb::IsochronousTransfer(kDataLength, 1,
-                                            StaticTransferCallback, this));
-    c->FillIsochronous(dev_handle_.get(), kEndpoint, kReadTimeout);
-    c->Submit();
-  }
-
-  last_frame_number_ = frame_number_ = 0;
-  phase_locker_.Reset();
-}
-
-constexpr ::aos::time::Time USBReceiver::kReadTimeout;
-constexpr ::aos::time::Time USBReceiver::kDesiredOffset;
-constexpr ::aos::time::Time USBReceiver::kResetTime;
-
-}  // namespace frc971
diff --git a/frc971/input/usb_receiver.h b/frc971/input/usb_receiver.h
deleted file mode 100644
index fec847f..0000000
--- a/frc971/input/usb_receiver.h
+++ /dev/null
@@ -1,139 +0,0 @@
-#ifndef FRC971_INPUT_USB_RECEIVER_H_
-#define FRC971_INPUT_USB_RECEIVER_H_
-
-#include <memory>
-
-#include "aos/common/time.h"
-#include "aos/common/macros.h"
-
-#include "gyro_board/src/libusb-driver/libusb_wrap.h"
-#include "frc971/input/gyro_board_data.h"
-
-namespace frc971 {
-
-// TODO(brians): Figure out how to deal with the kernel bunching packets up on
-// us.
-class USBReceiver {
- public:
-  USBReceiver(uint8_t expected_robot_id);
-
-  void RunIteration();
-
-  // The relative priority that tasks doing this should get run at (ie what to
-  // pass to ::aos::Init(int)).
-  static const int kRelativePriority = 5;
-
- protected:
-  GyroBoardData *data() { return &data_; }
-
- private:
-  static const unsigned char kEndpoint = 0x83;
-  // 0 is unlimited
-  static constexpr ::aos::time::Time kReadTimeout =
-      ::aos::time::Time::InSeconds(1.5);
-  // vendor ID
-  static const int32_t kVid = 0x1424;
-  // product ID
-  static const int32_t kPid = 0xd243;
-
-  // A value to put into completed_transfer_ to indicate that it failed.
-  static constexpr libusb::Transfer *kTransferFailed =
-      reinterpret_cast<libusb::Transfer *>(-1);
-  // The kernel on the fitpc seems to miss ~11-15 packets in a row if it misses
-  // any with just 2, so 25 should be enough to ride over any holes.
-  static const int kNumTransfers = 25;
-
-  // How big of a buffer we're going to give the usb transfer stuff.
-  static const size_t kDataLength = 128;
-  static_assert(kDataLength >= sizeof(GyroBoardData), "buffer is too small");
-
-  static const int kPacketsPerLoopCycle = 10;
-
-  // How long "after" the control loops run we want to use a packet.
-  static constexpr ::aos::time::Time kDesiredOffset =
-      ::aos::time::Time::InSeconds(-0.003);
-
-  // How long without a good packet until we give up and Reset().
-  static constexpr ::aos::time::Time kResetTime =
-      ::aos::time::Time::InSeconds(0.25);
-
-  // Contains all of the complicated state and logic for locking onto the the
-  // correct phase.
-  class PhaseLocker {
-   public:
-    void Reset();
-
-    // Gets called for every packet received.
-    // Returns whether or not to process the values from this packet.
-    bool IsCurrentPacketGood(const ::aos::time::Time &received_time,
-                             uint32_t sequence);
-
-   private:
-    // How many times the packet we guessed has to be close to right to use the
-    // guess.
-    static const int kMinGoodGuessCycles = 30;
-    // How many times in a row we have to guess the wrong packet before trying
-    // again.
-    static const int kMaxBadGuessCycles = 3;
-
-    // How many times in a row a different packet has to be better than the one
-    // that we're using befor switching to it.
-    static const int kSwitchCycles = 15;
-
-    ::aos::time::Time last_good_packet_time_{0, 0};
-
-    uint32_t last_good_sequence_;
-
-    const int kUnknownPhase = -11;
-    // kUnknownPhase or the sequence number (%kPacketsPerLoopCycle) to
-    // use or think about using.
-    // If not kUnknownPhase, 0 <= these < kPacketsPerLoopCycle.
-    int good_phase_, guess_phase_;
-    int guess_phase_good_, guess_phase_bad_;
-    ::aos::time::Time guess_phase_offset_{0, 0};
-    int good_phase_early_, good_phase_late_;
-  } phase_locker_;
-
-  static void StaticTransferCallback(libusb::Transfer *transfer, void *self);
-  void TransferCallback(libusb::Transfer *transfer);
-
-  // Returns true if receiving failed and we should try a Reset().
-  bool ReceiveData();
-
-  void Reset();
-
-  // These 2 are the functions for subclasses to override and do stuff in.
-  // timestamp for both of them is the time (as best as this code can determine)
-  // that the values in the packet were captured.
-  // They both have empty implementations here for subclasses that don't want to
-  // do anything in one of them.
-
-  // Gets called after each packet is received (possibly before ProcessData for
-  // the same packet).
-  virtual void PacketReceived(const ::aos::time::Time &timestamp);
-  // Gets called every 10th packet (or so) (at the right time for data for
-  // control loops to get read). PacketReceived will always be called right
-  // before this.
-  virtual void ProcessData(const ::aos::time::Time &timestamp);
-
-  const uint8_t expected_robot_id_;
-
-  GyroBoardData data_;
-
-  int32_t last_frame_number_, frame_number_;
-
-  LibUSB libusb_;
-  ::std::unique_ptr<LibUSBDeviceHandle> dev_handle_;
-  ::std::unique_ptr<libusb::IsochronousTransfer> transfers_[kNumTransfers];
-
-  // "Temporary" variables for communicating information about a transfer that
-  // finished from the callback to the rest of the code.
-  libusb::Transfer *completed_transfer_;
-  ::aos::time::Time transfer_received_time_{0, 0};
-
-  DISALLOW_COPY_AND_ASSIGN(USBReceiver);
-};
-
-}  // namespace frc971
-
-#endif  // FRC971_INPUT_USB_RECEIVER_H_
diff --git a/output/downloaded/.gitignore b/output/downloaded/.gitignore
index 079a15e..68db3c1 100644
--- a/output/downloaded/.gitignore
+++ b/output/downloaded/.gitignore
@@ -16,8 +16,6 @@
 /one-jar-boot-0.97.jar
 /gflags-2.0.tar.gz
 /gflags-2.0/
-/libusb-1.0.9.tar.bz2
-/libusb-1.0.9/
 /compiler-rt-RELEASE_32_final/
 /libevent-2.0.21.tar.gz
 /libevent-2.0.21/