worked more on usb sensor reading code timing
diff --git a/frc971/input/usb_receiver.cc b/frc971/input/usb_receiver.cc
index bd2e665..0addd66 100644
--- a/frc971/input/usb_receiver.cc
+++ b/frc971/input/usb_receiver.cc
@@ -17,8 +17,17 @@
if (ReceiveData()) {
Reset();
} else {
- const ::aos::time::Time received_time = ::aos::time::Time::Now();
- if (phase_locker_.IsCurrentPacketGood(received_time, sequence_)) {
+ // TODO(brians): Remove this temporary debug stuff.
+ static ::aos::time::Time temp(0, 0);
+ ::aos::time::Time delta = transfer_received_time_ - temp;
+ if (delta < ::aos::time::Time::InSeconds(0.0008)) {
+ LOG(INFO, "short delta %f\n", delta.ToSeconds());
+ } else if (delta > ::aos::time::Time::InSeconds(0.0012)) {
+ LOG(INFO, "long delta %f\n", delta.ToSeconds());
+ }
+ temp = transfer_received_time_;
+
+ if (phase_locker_.IsCurrentPacketGood(transfer_received_time_, sequence_)) {
LOG(DEBUG, "processing data %" PRIu32 "\n", sequence_);
ProcessData();
}
@@ -163,6 +172,7 @@
}
void USBReceiver::TransferCallback(libusb::Transfer *transfer) {
+ transfer_received_time_ = ::aos::time::Time::Now();
if (transfer->status() == LIBUSB_TRANSFER_COMPLETED) {
LOG(DEBUG, "transfer %p completed\n", transfer);
completed_transfer_ = transfer;
diff --git a/frc971/input/usb_receiver.h b/frc971/input/usb_receiver.h
index 0b0dd60..a3b7c5c 100644
--- a/frc971/input/usb_receiver.h
+++ b/frc971/input/usb_receiver.h
@@ -110,9 +110,11 @@
LibUSB libusb_;
::std::unique_ptr<LibUSBDeviceHandle> dev_handle_;
::std::unique_ptr<libusb::IsochronousTransfer> transfers_[kNumTransfers];
- // "Temporary" variable for holding a completed transfer to communicate that
- // information from the callback to the code that wants it.
+
+ // "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};
};
} // namespace frc971