blob: e8ac6db5fd51003c8b0bf0f8530810d3a1b4f90c [file] [log] [blame]
Austin Schuh8d5fff42018-05-30 20:44:12 -07001#include <netdb.h>
2
3#include "aos/common/logging/logging.h"
4#include "aos/common/logging/queue_logging.h"
5#include "aos/common/time.h"
6#include "aos/linux_code/init.h"
7#include "aos/vision/events/udp.h"
8#include "y2018/vision.pb.h"
9#include "y2018/vision/vision.q.h"
10
11namespace y2018 {
12namespace vision {
13
14using aos::monotonic_clock;
15
16int Main() {
17 ::aos::events::RXUdpSocket video_rx(5001);
18 char data[65507];
19 ::y2018::VisionStatus status;
20
21 while (true) {
22 const ssize_t rx_size = video_rx.Recv(data, sizeof(data));
23 if (rx_size > 0) {
24 status.ParseFromArray(data, rx_size);
25 auto new_vision_status = vision_status.MakeMessage();
26 new_vision_status->high_frame_count = status.high_frame_count();
27 new_vision_status->low_frame_count = status.low_frame_count();
28 LOG_STRUCT(DEBUG, "vision", *new_vision_status);
29 if (!new_vision_status.Send()) {
30 LOG(ERROR, "Failed to send vision information\n");
31 }
32 }
33 }
34}
35
36} // namespace vision
37} // namespace y2018
38
39int main(int /*argc*/, char ** /*argv*/) {
40 ::aos::InitNRT();
41 ::y2018::vision::Main();
42}