Copy back a lot of the 2014 code.

Change-Id: I552292d8bd7bce4409e02d254bef06a9cc009568
diff --git a/y2014/prime/build.sh b/y2014/prime/build.sh
new file mode 100755
index 0000000..f83d9f4
--- /dev/null
+++ b/y2014/prime/build.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cd $(dirname $0)
+
+exec ../../aos/build/build.py $0 prime y2014 prime.gyp "$@"
diff --git a/y2014/prime/compile_loop.sh b/y2014/prime/compile_loop.sh
new file mode 100755
index 0000000..de6b0d3
--- /dev/null
+++ b/y2014/prime/compile_loop.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Runs `build.sh all` and then waits for a file to be modified in a loop.
+# Useful for making changes to the code while continuously making sure they
+# compile.
+# Requires the util-linux and inotify-tools packages.
+
+chrt -i -p 0 $$
+ionice -c 3 -p $$
+
+while true; do
+	$(dirname $0)/build.sh all
+	echo 'compile_loop.sh: Waiting for a file modification...' 1>&2
+	inotifywait -e close_write -r aos frc971 bbb_cape
+	echo 'compile_loop.sh: Done waiting for a file modification' 1>&2
+done
diff --git a/y2014/prime/hot_goal_reader.cc b/y2014/prime/hot_goal_reader.cc
new file mode 100644
index 0000000..ffdb3a3
--- /dev/null
+++ b/y2014/prime/hot_goal_reader.cc
@@ -0,0 +1,108 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <errno.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "aos/common/time.h"
+#include "aos/common/logging/queue_logging.h"
+#include "aos/common/logging/logging.h"
+#include "aos/linux_code/init.h"
+#include "aos/common/byteorder.h"
+
+#include "y2014/queues/hot_goal.q.h"
+
+int main() {
+  ::aos::InitNRT();
+
+  uint64_t left_count, right_count;
+  ::frc971::hot_goal.FetchLatest();
+  if (::frc971::hot_goal.get()) {
+    LOG_STRUCT(DEBUG, "starting with", *::frc971::hot_goal);
+    left_count = ::frc971::hot_goal->left_count;
+    right_count = ::frc971::hot_goal->left_count;
+  } else {
+    LOG(DEBUG, "no starting message\n");
+    left_count = right_count = 0;
+  }
+
+  int my_socket = -1;
+  while (true) {
+    if (my_socket == -1) {
+      my_socket = socket(AF_INET, SOCK_STREAM, 0);
+      if (my_socket == -1) {
+        PLOG(WARNING, "socket(AF_INET, SOCK_STREAM, 0) failed");
+        continue;
+      } else {
+        LOG(INFO, "opened socket (is %d)\n", my_socket);
+        sockaddr_in address, *sockaddr_pointer;
+        memset(&address, 0, sizeof(address));
+        address.sin_family = AF_INET;
+        address.sin_port = ::aos::hton<uint16_t>(1180);
+        sockaddr *address_pointer;
+        sockaddr_pointer = &address;
+        memcpy(&address_pointer, &sockaddr_pointer, sizeof(void *));
+        if (bind(my_socket, address_pointer, sizeof(address)) == -1) {
+          PLOG(WARNING, "bind(%d, %p, %zu) failed",
+               my_socket, &address, sizeof(address));
+          close(my_socket);
+          my_socket = -1;
+          continue;
+        }
+
+        if (listen(my_socket, 1) == -1) {
+          PLOG(WARNING, "listen(%d, 1) failed", my_socket);
+          close(my_socket);
+          my_socket = -1;
+          continue;
+        }
+      }
+    }
+
+    int connection = accept4(my_socket, nullptr, nullptr, SOCK_NONBLOCK);
+    if (connection == -1) {
+      PLOG(WARNING, "accept(%d, nullptr, nullptr) failed", my_socket);
+      continue;
+    }
+    LOG(INFO, "accepted (is %d)\n", connection);
+
+    while (connection != -1) {
+      fd_set fds;
+      FD_ZERO(&fds);
+      FD_SET(connection, &fds);
+      struct timeval timeout_timeval =
+          ::aos::time::Time::InSeconds(1).ToTimeval();
+      switch (
+          select(connection + 1, &fds, nullptr, nullptr, &timeout_timeval)) {
+        case 1: {
+          uint8_t data;
+          ssize_t read_bytes = read(connection, &data, sizeof(data));
+          if (read_bytes != sizeof(data)) {
+            LOG(WARNING, "read %zd bytes instead of %zd\n", read_bytes,
+                sizeof(data));
+            break;
+          }
+          if (data & 0x01) ++right_count;
+          if (data & 0x02) ++left_count;
+          auto message = ::frc971::hot_goal.MakeMessage();
+          message->left_count = left_count;
+          message->right_count = right_count;
+          LOG_STRUCT(DEBUG, "sending", *message);
+          message.Send();
+        } break;
+        case 0:
+          LOG(WARNING, "read on %d timed out\n", connection);
+          close(connection);
+          connection = -1;
+          break;
+        default:
+          PLOG(FATAL,
+               "select(%d, %p, nullptr, nullptr, %p) failed",
+               connection + 1, &fds, &timeout_timeval);
+      }
+    }
+  }
+
+  LOG(FATAL, "finished???\n");
+}
diff --git a/y2014/prime/prime.gyp b/y2014/prime/prime.gyp
new file mode 100644
index 0000000..a64fc1c
--- /dev/null
+++ b/y2014/prime/prime.gyp
@@ -0,0 +1,55 @@
+{
+  'targets': [
+    {
+      'target_name': 'All',
+      'type': 'none',
+      'dependencies': [
+        '../../frc971/frc971.gyp:All',
+
+        '../control_loops/drivetrain/drivetrain.gyp:drivetrain',
+        '../control_loops/drivetrain/drivetrain.gyp:drivetrain_lib_test',
+        '../control_loops/drivetrain/drivetrain.gyp:replay_drivetrain',
+        '../control_loops/claw/claw.gyp:claw',
+        '../control_loops/claw/claw.gyp:claw_calibration',
+        '../control_loops/claw/claw.gyp:claw_lib_test',
+        '../control_loops/claw/claw.gyp:replay_claw',
+        '../control_loops/shooter/shooter.gyp:shooter',
+        '../control_loops/shooter/shooter.gyp:shooter_lib_test',
+        '../control_loops/shooter/shooter.gyp:replay_shooter',
+        '../autonomous/autonomous.gyp:auto',
+        '../y2014.gyp:joystick_reader',
+        '../actors/actors.gyp:binaries',
+        'hot_goal_reader',
+      ],
+      'copies': [
+        {
+          'destination': '<(rsync_dir)',
+          'files': [
+            'start_list.txt',
+          ],
+        },
+      ],
+      'conditions': [
+        ['ARCHITECTURE=="arm_frc"', {
+          'dependencies': [
+            '../wpilib/wpilib.gyp:wpilib_interface',
+          ],
+        }],
+      ],
+    },
+    {
+      'target_name': 'hot_goal_reader',
+      'type': 'executable',
+      'sources': [
+        'hot_goal_reader.cc',
+      ],
+      'dependencies': [
+        '<(AOS)/common/common.gyp:time',
+        '<(AOS)/build/aos.gyp:logging',
+        '<(AOS)/common/logging/logging.gyp:queue_logging',
+        '<(AOS)/linux_code/linux_code.gyp:init',
+        '<(DEPTH)/y2014/queues/queues.gyp:hot_goal'
+      ],
+    },
+  ],
+}
diff --git a/y2014/prime/start_list.txt b/y2014/prime/start_list.txt
new file mode 100644
index 0000000..276aca8
--- /dev/null
+++ b/y2014/prime/start_list.txt
@@ -0,0 +1,13 @@
+binary_log_writer
+motor_writer
+joystick_reader
+drivetrain
+auto
+sensor_receiver
+joystick_proxy
+claw
+shooter
+shoot_action
+drivetrain_action
+catch_action
+hot_goal_reader