Create an enum for sender errors

Will replace usages of bools, and will now currently only be used
for indicating that messages were sent too fast

After we merge this commit we will replace this enum with a general
Status class for all of aos, similar to absl::Status.

Change-Id: I4b5b2e7685744b3c6826a241cd3c84190eaa96ee
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
diff --git a/y2020/vision/camera_reader.cc b/y2020/vision/camera_reader.cc
index e908a47..b13c19c 100644
--- a/y2020/vision/camera_reader.cc
+++ b/y2020/vision/camera_reader.cc
@@ -165,6 +165,7 @@
   std::vector<cv::FlannBasedMatcher> matchers_;
   aos::Sender<CameraImage> image_sender_;
   aos::Sender<sift::ImageMatchResult> result_sender_;
+  aos::SendFailureCounter result_failure_counter_;
   aos::Sender<sift::ImageMatchResult> detailed_result_sender_;
   // We schedule this immediately to read an image. Having it on a timer means
   // other things can run on the event loop in between.
@@ -289,10 +290,11 @@
   result_builder.add_image_monotonic_timestamp_ns(
       image.monotonic_timestamp_ns());
   result_builder.add_camera_calibration(camera_calibration_offset);
+  result_builder.add_send_failures(result_failure_counter_.failures());
 
   // TODO<Jim>: Need to add target point computed from matches and
   // mapped by homography
-  builder.Send(result_builder.Finish());
+  result_failure_counter_.Count(builder.Send(result_builder.Finish()));
 }
 
 void CameraReader::ProcessImage(const CameraImage &image) {
@@ -713,7 +715,8 @@
   {
     aos::Sender<sift::TrainingData> training_data_sender =
         event_loop.MakeSender<sift::TrainingData>("/camera");
-    training_data_sender.Send(training_data);
+    CHECK_EQ(training_data_sender.Send(training_data),
+             aos::RawSender::Error::kOk);
   }
 
   V4L2Reader v4l2_reader(&event_loop, "/dev/video0");
diff --git a/y2020/vision/sift/sift.fbs b/y2020/vision/sift/sift.fbs
index 427b91c..3336d0c 100644
--- a/y2020/vision/sift/sift.fbs
+++ b/y2020/vision/sift/sift.fbs
@@ -167,6 +167,9 @@
 
   // Information about the camera which took this image.
   camera_calibration:CameraCalibration (id: 4);
+
+  // Total number of match result send failures.
+  send_failures:uint64 (id: 5);
 }
 
 root_type ImageMatchResult;
diff --git a/y2020/vision/v4l2_reader.h b/y2020/vision/v4l2_reader.h
index 3c9d795..04548d6 100644
--- a/y2020/vision/v4l2_reader.h
+++ b/y2020/vision/v4l2_reader.h
@@ -53,7 +53,7 @@
                         aos::monotonic_clock::time_point monotonic_eof);
 
     void Send() {
-      builder.Send(message_offset);
+      (void)builder.Send(message_offset);
       message_offset = flatbuffers::Offset<CameraImage>();
     }