copied everything over from 2012 and removed all of the actual robot code except the drivetrain stuff
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4078 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/atom_code/messages/DriverStationDisplay.cpp b/aos/atom_code/messages/DriverStationDisplay.cpp
new file mode 100644
index 0000000..e48a1eb
--- /dev/null
+++ b/aos/atom_code/messages/DriverStationDisplay.cpp
@@ -0,0 +1,54 @@
+#include "DriverStationDisplay.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+using namespace aos;
+
+static const aos_type_sig signature = {sizeof(DriverStationDisplay), 1234, 10};
+aos_queue *DriverStationDisplay::queue = NULL;
+void DriverStationDisplay::GetQueue() {
+ if (queue == NULL) {
+ queue = aos_fetch_queue("DriverStationDisplay", &signature);
+ }
+}
+
+void DriverStationDisplay::Send(int line, const char *fmt, ...) {
+ GetQueue();
+ DriverStationDisplay *msg = static_cast<DriverStationDisplay *>(
+ aos_queue_get_msg(queue));
+ if (msg == NULL) {
+ LOG(WARNING, "could not get message to send '%s' to the DS queue\n", fmt);
+ return;
+ }
+ msg->line = static_cast<uint8_t>(line);
+
+ va_list ap;
+ va_start(ap, fmt);
+ int ret = vsnprintf(msg->data, sizeof(msg->data), fmt, ap);
+ va_end(ap);
+ if (ret < 0) {
+ LOG(WARNING, "could not format '%s' with arguments\n", fmt);
+ aos_queue_free_msg(queue, msg);
+ return;
+ } else if (static_cast<uintmax_t>(ret) >=
+ static_cast<uintmax_t>(sizeof(msg->data))) {
+ LOG(WARNING, "format '%s' ended up longer than the max size (%zd)\n",
+ fmt, sizeof(msg->data));
+ }
+
+ if (aos_queue_write_msg(queue, msg, NON_BLOCK) < 0) {
+ LOG(ERROR, "writing '%s' (line %hhd) failed\n", msg->data, msg->line);
+ aos_queue_free_msg(queue, msg);
+ }
+}
+
+const DriverStationDisplay *DriverStationDisplay::GetNext() {
+ GetQueue();
+ return static_cast<const DriverStationDisplay *>(aos_queue_read_msg(queue, NON_BLOCK));
+}
+void DriverStationDisplay::Free(const DriverStationDisplay *msg) {
+ GetQueue();
+ aos_queue_free_msg(queue, msg);
+}
+