made stuff actually work
diff --git a/aos/common/sensors/sensor_receiver-tmpl.h b/aos/common/sensors/sensor_receiver-tmpl.h
index 6456a95..076f6ca 100644
--- a/aos/common/sensors/sensor_receiver-tmpl.h
+++ b/aos/common/sensors/sensor_receiver-tmpl.h
@@ -57,19 +57,19 @@
template<class Values>
bool SensorReceiver<Values>::GoodPacket() {
- if (!data_.CheckChecksum()) {
- LOG(WARNING, "got a bad packet\n");
- return false;
- }
-
bool good;
// If it's a multiple of kSensorSendFrequency from start_count_.
if (((data_.count - start_count_) % kSendsPerCycle) == 0) {
if (((data_.count - start_count_) / kSendsPerCycle) >=
((NextLoopTime() - start_time_).ToNSec() / kLoopFrequency.ToNSec())) {
good = true;
+#if 0
+ if (((data_.count - start_count_) / kSendsPerCycle % 20) == 0) {
+ LOG(DEBUG, "dropping one for fun\n");
+ good = false;
+ }
+#endif
} else {
- // when it broke, it got #1 but wanted #0 (etc)
LOG(INFO, "packet %"PRId32" late. is packet #%d, wanted #%"PRId64" now\n",
data_.count, (data_.count - start_count_) / kSendsPerCycle,
(NextLoopTime() - start_time_).ToNSec() / kLoopFrequency.ToNSec());
@@ -195,6 +195,13 @@
bool SensorReceiver<Values>::ReceiveData() {
int old_count = data_.count;
DoReceiveData();
+
+ data_.checksum = ntoh(data_.checksum);
+ if (!data_.CheckChecksum()) {
+ LOG(WARNING, "got a bad packet\n");
+ return ReceiveData();
+ }
+
data_.NetworkToHost();
if (data_.count < 0) {
LOG(FATAL, "data count overflowed. currently %"PRId32"\n", data_.count);
diff --git a/aos/common/sensors/sensors.h b/aos/common/sensors/sensors.h
index 007921c..a6b2bfa 100644
--- a/aos/common/sensors/sensors.h
+++ b/aos/common/sensors/sensors.h
@@ -44,6 +44,7 @@
// All of the other 4-byte chunks in the message bitwise-exclusive-ORed
// together. Needed because it seems like nobody else checks... (vxworks not
// sending the UDP checksum or (not very likely) linux not checking it).
+ // TODO(brians): static_assert that this is at the front
uint32_t checksum;
Values values;