finished getting all of the usb stuff working nicely(ish)
diff --git a/frc971/crio/crio.gyp b/frc971/crio/crio.gyp
index cbd7d2d..32166dd 100644
--- a/frc971/crio/crio.gyp
+++ b/frc971/crio/crio.gyp
@@ -22,15 +22,16 @@
'main.cc',
],
'dependencies': [
+ '<(AOS)/crio/motor_server/motor_server.gyp:MotorServer',
'../output/output.gyp:MotorWriter',
'WPILib_changes',
'<(EXTERNALS):WPILib',
- '<(AOS)/common/messages/messages.gyp:aos_queues',
'<(AOS)/crio/controls/controls.gyp:ControlsManager',
- '<(AOS)/crio/motor_server/motor_server.gyp:crio_control_loop_runner',
- '<(AOS)/common/sensors/sensors.gyp:sensor_broadcaster',
- '<(DEPTH)/frc971/input/input.gyp:sensor_packer',
- '<(DEPTH)/frc971/input/input.gyp:sensor_unpacker',
+ '<(AOS)/crio/shared_libs/shared_libs.gyp:interrupt_notifier',
+ #'<(AOS)/crio/motor_server/motor_server.gyp:crio_control_loop_runner',
+ #'<(AOS)/common/sensors/sensors.gyp:sensor_broadcaster',
+ #'<(DEPTH)/frc971/input/input.gyp:sensor_packer',
+ #'<(DEPTH)/frc971/input/input.gyp:sensor_unpacker',
],
},
{
diff --git a/frc971/crio/main.cc b/frc971/crio/main.cc
index 85e2d45..3b404b9 100644
--- a/frc971/crio/main.cc
+++ b/frc971/crio/main.cc
@@ -1,12 +1,14 @@
#include "aos/common/libstdc++/memory"
#include "aos/crio/controls/ControlsManager.h"
-#include "aos/crio/motor_server/crio_control_loop_runner.h"
-#include "aos/common/sensors/sensor_broadcaster.h"
+//#include "aos/crio/motor_server/crio_control_loop_runner.h"
+#include "aos/crio/motor_server/MotorServer.h"
+//#include "aos/common/sensors/sensor_broadcaster.h"
+#include "aos/crio/shared_libs/interrupt_bridge.h"
-#include "frc971/queues/sensor_values.h"
-#include "frc971/input/sensor_packer.h"
-#include "frc971/input/sensor_unpacker.h"
+//#include "frc971/queues/sensor_values.h"
+//#include "frc971/input/sensor_packer.h"
+//#include "frc971/input/sensor_unpacker.h"
using ::std::unique_ptr;
@@ -16,12 +18,18 @@
public:
MyRobot() {}
+ private:
virtual void CreateObjects() {
+#if 0
packer_ = unique_ptr< ::frc971::SensorPacker>( new ::frc971::SensorPacker());
unpacker_ = unique_ptr< ::frc971::SensorUnpacker>( new ::frc971::SensorUnpacker());
broadcaster_ = unique_ptr< ::aos::sensors::SensorBroadcaster< ::frc971::sensor_values>>(
new ::aos::sensors::SensorBroadcaster< ::frc971::sensor_values>(packer_.get()));
control_loop_runner_ = unique_ptr< ::aos::crio::CRIOControlLoopRunner< ::frc971::sensor_values>>(new ::aos::crio::CRIOControlLoopRunner< ::frc971::sensor_values>(broadcaster_.get(), unpacker_.get()));
+#endif
+ motor_server_notifier_ =
+ unique_ptr< ::aos::crio::WDInterruptNotifier<void>>(
+ new ::aos::crio::WDInterruptNotifier<void>(WriteOutputs));
}
virtual void RegisterControlLoops() {
@@ -29,14 +37,22 @@
}
virtual void StartSensorBroadcasters() {
- broadcaster_->Start();
+ //broadcaster_->Start();
+ motor_server_notifier_->StartPeriodic(0.01);
}
+ static void WriteOutputs(void *) {
+ ::aos::crio::MotorServer::WriteOutputs();
+ }
+
+#if 0
unique_ptr< ::frc971::SensorPacker> packer_;
unique_ptr< ::frc971::SensorUnpacker> unpacker_;
unique_ptr< ::aos::sensors::SensorBroadcaster< ::frc971::sensor_values>> broadcaster_;
unique_ptr< ::aos::crio::CRIOControlLoopRunner< ::frc971::sensor_values>>
control_loop_runner_;
+#endif
+ unique_ptr< ::aos::crio::WDInterruptNotifier<void>> motor_server_notifier_;
};
} // namespace frc971
diff --git a/frc971/input/gyro_board_data.h b/frc971/input/gyro_board_data.h
index 0a8272a..a1b8712 100644
--- a/frc971/input/gyro_board_data.h
+++ b/frc971/input/gyro_board_data.h
@@ -46,6 +46,8 @@
};
void NetworkToHost() {
+ // Apparently it sends the information out in little endian.
+#if 0
using ::aos::ntoh;
gyro_angle = ntoh(gyro_angle);
@@ -64,6 +66,7 @@
capture_shooter_angle_rise = ntoh(capture_shooter_angle_rise);
digitals = ntoh(digitals);
+#endif
}
} __attribute__((__packed__));
diff --git a/frc971/input/gyro_board_reader.cc b/frc971/input/gyro_board_reader.cc
index dab6130..4628c78 100644
--- a/frc971/input/gyro_board_reader.cc
+++ b/frc971/input/gyro_board_reader.cc
@@ -105,9 +105,9 @@
LOG(FATAL, "libusb gave error %d\n", r);
}
- if (read_bytes != sizeof(data)) {
- LOG(ERROR, "read %d bytes instead of %zu\n",
- read_bytes, sizeof(data));
+ if (read_bytes < static_cast<ssize_t>(sizeof(*real_data))) {
+ LOG(ERROR, "read %d bytes instead of at least %zd\n",
+ read_bytes, sizeof(*real_data));
continue;
}