Convert aos over to flatbuffers
Everything builds, and all the tests pass. I suspect that some entries
are missing from the config files, but those will be found pretty
quickly on startup.
There is no logging or live introspection of queue messages.
Change-Id: I496ee01ed68f202c7851bed7e8786cee30df29f5
diff --git a/aos/vision/events/BUILD b/aos/vision/events/BUILD
index b887872..a991968 100644
--- a/aos/vision/events/BUILD
+++ b/aos/vision/events/BUILD
@@ -52,6 +52,7 @@
deps = [
"//aos:macros",
"//aos/scoped:scoped_fd",
+ "@com_github_google_glog//:glog",
],
)
diff --git a/aos/vision/events/udp.cc b/aos/vision/events/udp.cc
index 8734443..7ac72e8 100644
--- a/aos/vision/events/udp.cc
+++ b/aos/vision/events/udp.cc
@@ -2,23 +2,23 @@
#include <string.h>
-#include "aos/logging/logging.h"
+#include "glog/logging.h"
namespace aos {
namespace events {
TXUdpSocket::TXUdpSocket(const std::string &ip_addr, int port)
- : fd_(AOS_PCHECK(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))) {
+ : fd_(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) {
+ PCHECK(fd_.get() != -1);
sockaddr_in destination_in;
memset(&destination_in, 0, sizeof(destination_in));
destination_in.sin_family = AF_INET;
destination_in.sin_port = htons(port);
- if (inet_aton(ip_addr.c_str(), &destination_in.sin_addr) == 0) {
- AOS_LOG(FATAL, "invalid IP address %s\n", ip_addr.c_str());
- }
+ CHECK(inet_aton(ip_addr.c_str(), &destination_in.sin_addr) != 0)
+ << ": invalid IP address " << ip_addr;
- AOS_PCHECK(connect(fd_.get(), reinterpret_cast<sockaddr *>(&destination_in),
- sizeof(destination_in)));
+ PCHECK(connect(fd_.get(), reinterpret_cast<sockaddr *>(&destination_in),
+ sizeof(destination_in)) == 0);
}
int TXUdpSocket::Send(const char *data, int size) {
@@ -27,7 +27,8 @@
}
int RXUdpSocket::SocketBindListenOnPort(int port) {
- int fd = AOS_PCHECK(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP));
+ int fd;
+ PCHECK((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) != -1);
sockaddr_in bind_address;
memset(&bind_address, 0, sizeof(bind_address));
@@ -35,15 +36,17 @@
bind_address.sin_port = htons(port);
bind_address.sin_addr.s_addr = htonl(INADDR_ANY);
- AOS_PCHECK(bind(fd, reinterpret_cast<sockaddr *>(&bind_address),
- sizeof(bind_address)));
+ PCHECK(bind(fd, reinterpret_cast<sockaddr *>(&bind_address),
+ sizeof(bind_address)) == 0);
return fd;
}
RXUdpSocket::RXUdpSocket(int port) : fd_(SocketBindListenOnPort(port)) {}
int RXUdpSocket::Recv(void *data, int size) {
- return AOS_PCHECK(recv(fd_.get(), static_cast<char *>(data), size, 0));
+ int result;
+ PCHECK((result = recv(fd_.get(), static_cast<char *>(data), size, 0)) != -1);
+ return result;
}
} // namespace events