started cleanup up the socket mess
removed unused #include + dependency
more formatting fixes + fixed users of ReceiveSocket
cleaned more stuff up (converted from references to pointers is one)
wip. started rewriting everything, not quite finished
got everything except SensorOutput done (I think...)
got everything compiling except for missing SensorReceiver
worked on implementing the logic. didn't finish
made everything compile and finished implementing SensorReceiver
pulling over Austin's mock time stuff
added IncrementMockTime
finished up and started on tests
remembered something else
diff --git a/aos/crio/shared_libs/ByteBuffer.h b/aos/crio/shared_libs/ByteBuffer.h
index f1cf60a..9a926a7 100644
--- a/aos/crio/shared_libs/ByteBuffer.h
+++ b/aos/crio/shared_libs/ByteBuffer.h
@@ -14,7 +14,7 @@
int m_i;
char *m_buffer;
bool recv_from_sock(ReceiveSocket *sock) {
- m_length = sock->Recv(m_buffer, m_size, 40000);
+ m_length = sock->Receive(m_buffer, m_size, 40000);
if (m_length < 0) {
m_length = 0;
}
diff --git a/aos/crio/shared_libs/interrupt_bridge-tmpl.h b/aos/crio/shared_libs/interrupt_bridge-tmpl.h
index fbd3e98..ef53dce 100644
--- a/aos/crio/shared_libs/interrupt_bridge-tmpl.h
+++ b/aos/crio/shared_libs/interrupt_bridge-tmpl.h
@@ -6,7 +6,6 @@
#include "aos/common/logging/logging.h"
#include "aos/crio/motor_server/MotorServer.h"
-#include "aos/common/time.h"
extern "C" {
// A really simple function implemented in a .c file because the header that
@@ -80,12 +79,14 @@
PeriodicNotifier<T>::PeriodicNotifier(
typename InterruptBridge<T>::Handler handler,
T *param, int priority)
- : InterruptBridge<T>(handler, param, priority) {}
+ : InterruptBridge<T>(handler, param, priority),
+ period_(-1, -1) {}
template<typename T>
-void PeriodicNotifier<T>::StartPeriodic(double period) {
+void PeriodicNotifier<T>::StartPeriodic(time::Time period) {
+ period_ = period;
this->StartTask();
- StartNotifications(period);
+ StartNotifications();
}
template<typename T>
@@ -128,11 +129,11 @@
}
template<typename T>
-void TimerNotifier<T>::StartNotifications(double period) {
+void TimerNotifier<T>::StartNotifications() {
itimerspec timer_spec;
timer_spec.it_value.tv_sec = 0;
timer_spec.it_value.tv_nsec = 1; // 0 would mean to disarm the timer
- timer_spec.it_interval = time::Time::InSeconds(period).ToTimespec();
+ timer_spec.it_interval = this->period().ToTimespec();
if (timer_settime(timer_, 0, &timer_spec, NULL) != OK) {
LOG(FATAL, "timer_settime(%p, 0, %p, NULL) failed with %d: %s\n",
timer_, &timer_spec, errno, strerror(errno));
@@ -163,8 +164,8 @@
}
template<typename T>
-void WDInterruptNotifier<T>::StartNotifications(double period) {
- delay_ = time::Time::InSeconds(period).ToTicks();
+void WDInterruptNotifier<T>::StartNotifications() {
+ delay_ = this->period().ToTicks();
if (wdStart(wd_,
1, // run it really soon
diff --git a/aos/crio/shared_libs/interrupt_bridge.h b/aos/crio/shared_libs/interrupt_bridge.h
index f8f68b4..aedaaea 100644
--- a/aos/crio/shared_libs/interrupt_bridge.h
+++ b/aos/crio/shared_libs/interrupt_bridge.h
@@ -8,6 +8,7 @@
#include "aos/common/scoped_ptr.h"
+#include "aos/common/time.h"
#include "aos/common/macros.h"
class Task;
@@ -61,8 +62,23 @@
template<typename T>
class PeriodicNotifier : public InterruptBridge<T> {
public:
- // Period is how much (in seconds) to wait between running the handler.
- void StartPeriodic(double period);
+ // Period is how much to wait each time between running the handler.
+ void StartPeriodic(time::Time period);
+ // DEPRECATED(brians): use the overload that takes a time::Time
+ void StartPeriodic(double seconds) {
+ StartPeriodic(time::Time::InSeconds(seconds));
+ }
+ // After StartPeriodic is called, returns whether or not the subclass can
+ // actually call the callback exactly on those intervals or whether it will
+ // call it on some rounded amount.
+ //
+ // Default implementation assumes that the subclass has sysClockRateGet()
+ // resolution. Override if this is not true.
+ virtual bool IsExact() {
+ return period_ == time::Time::InTicks(period_.ToTicks());
+ }
+
+ time::Time period() { return period_; }
protected:
PeriodicNotifier(typename InterruptBridge<T>::Handler handler, T *param,
@@ -72,8 +88,10 @@
private:
virtual void StopNotifications() = 0;
// Subclasses should do whatever they have to to start calling Notify() every
- // period seconds.
- virtual void StartNotifications(double period) = 0;
+ // period_.
+ virtual void StartNotifications() = 0;
+
+ time::Time period_;
};
// This one works accurately, but it has the potential to drift over time.
@@ -91,7 +109,7 @@
// an instance. This function calls Notify() on that instance.
static void StaticNotify(void *self_in);
virtual void StopNotifications();
- virtual void StartNotifications(double period);
+ virtual void StartNotifications();
WDOG_ID wd_;
int delay_; // what to pass to wdStart
@@ -122,7 +140,7 @@
// and calls Notify() on that instance.
static void StaticNotify(int signum);
virtual void StopNotifications();
- virtual void StartNotifications(double period);
+ virtual void StartNotifications();
timer_t timer_;
// Which signal timer_ will notify on.