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);
+}
+
diff --git a/aos/atom_code/messages/DriverStationDisplay.h b/aos/atom_code/messages/DriverStationDisplay.h
new file mode 100644
index 0000000..9ce3712
--- /dev/null
+++ b/aos/atom_code/messages/DriverStationDisplay.h
@@ -0,0 +1,31 @@
+#ifndef AOS_ATOM_CODE_MESSAGES_DRIVER_STATION_DISPLAY_H_
+#define AOS_ATOM_CODE_MESSAGES_DRIVER_STATION_DISPLAY_H_
+
+#include <stdint.h>
+#include <string.h>
+
+#include "aos/aos_core.h"
+#include "aos/common/type_traits.h"
+
+namespace aos {
+const size_t kLineLength = 21;
+
+struct DriverStationDisplay {
+ static void Send(int line, const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
+ static const DriverStationDisplay *GetNext(); // returns NULL if there are no more
+ static void Free(const DriverStationDisplay *msg);
+
+ uint8_t line;
+ char data[kLineLength + 1];
+
+ private:
+ static void GetQueue();
+ static aos_queue *queue;
+};
+static_assert(shm_ok<DriverStationDisplay>::value,
+ "DriverStationDisplay will go through shared memory");
+} // namespace aos
+
+#endif
+
diff --git a/aos/atom_code/messages/messages.gyp b/aos/atom_code/messages/messages.gyp
new file mode 100644
index 0000000..ddbe9ec
--- /dev/null
+++ b/aos/atom_code/messages/messages.gyp
@@ -0,0 +1,38 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'messages_so',
+ 'type': 'shared_library',
+ 'variables': {'no_rsync': 1},
+ 'sources': [
+ 'DriverStationDisplay.cpp',
+ ],
+ 'dependencies': [
+ '<(AOS)/build/aos.gyp:aos_shared_lib',
+ ],
+ 'export_dependent_settings': [
+ '<(AOS)/build/aos.gyp:aos_shared_lib',
+ ],
+ 'direct_dependent_settings': {
+ 'variables': {
+ 'jni_libs': [
+ 'messages_so',
+ ],
+ },
+ },
+ },
+ {
+ 'target_name': 'messages',
+ 'type': 'static_library',
+ 'sources': [
+ 'DriverStationDisplay.cpp',
+ ],
+ 'dependencies': [
+ '<(AOS)/atom_code/ipc_lib/ipc_lib.gyp:ipc_lib'
+ ],
+ 'export_dependent_settings': [
+ '<(AOS)/atom_code/ipc_lib/ipc_lib.gyp:ipc_lib'
+ ],
+ },
+ ],
+}