remove all the crio, bbb, and 2014 code
This also meant upgrading to clang-3.5 from llvm.org to try to get it to
build code for the roboRIO.
Change-Id: I44df4af4e9e04296ee7934cc787da3101b1ac449
diff --git a/aos/linux_code/README.txt b/aos/linux_code/README.txt
index 143cefb..65feb21 100644
--- a/aos/linux_code/README.txt
+++ b/aos/linux_code/README.txt
@@ -1,9 +1,9 @@
-see ../README.txt for stuff affecting crio and linux code
+see ../README.txt for stuff affecting all code
The folder is called linux_code because it mainly deals with code that uses the queue system, which only works under GNU/Linux for a variety of reasons, some fundamental (futexes) and some because nobody bothers to fix them.
The layout is designed with multiple linux boxes in mind.
-The code for the linux box that talks the cRIO etc is in ../prime/.
+The code for the linux box that sends motor outputs etc is in ../prime/.
[NOTES]
Any code should call aos::Init() (or aos::InitNRT() for processes that don't need to be realtime) before making any calls to any of the aos functions.
diff --git a/aos/linux_code/starter/netconsole.cc b/aos/linux_code/starter/netconsole.cc
deleted file mode 100644
index c4ca5b9..0000000
--- a/aos/linux_code/starter/netconsole.cc
+++ /dev/null
@@ -1,233 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <sys/stat.h>
-
-#include "aos/common/logging/logging_impl.h"
-#include "aos/common/util/inet_addr.h"
-#include "aos/linux_code/configuration.h"
-#include "aos/common/network_port.h"
-#include "aos/linux_code/init.h"
-#include "aos/common/byteorder.h"
-
-namespace aos {
-namespace {
-
-struct FDsToCopy {
- const int input;
- const int output;
-
- const struct sockaddr_in *const interface_address;
- const struct sockaddr_in *const source_address;
-};
-
-void *FDCopyThread(void *to_copy_in) {
- FDsToCopy *to_copy = static_cast<FDsToCopy *>(to_copy_in);
-
- char buffer[32768];
- ssize_t position = 0;
- while (true) {
- CHECK_GE(position, 0);
- CHECK_LE(position, static_cast<ssize_t>(sizeof(buffer)));
- if (position != sizeof(buffer)) {
- ssize_t read_bytes;
- bool good_data = true;
- if (to_copy->interface_address != nullptr ||
- to_copy->source_address != nullptr) {
- char control_buffer[0x100];
- struct msghdr header;
- memset(static_cast<void *>(&header), 0, sizeof(header));
- header.msg_control = control_buffer;
- header.msg_controllen = sizeof(control_buffer);
- struct iovec iovecs[1];
- iovecs[0].iov_base = buffer + position;
- iovecs[0].iov_len = sizeof(buffer) - position;
- header.msg_iov = iovecs;
- header.msg_iovlen = sizeof(iovecs) / sizeof(iovecs[0]);
- struct sockaddr_in sender_address;
- header.msg_name = &sender_address;
- header.msg_namelen = sizeof(sender_address);
-
- read_bytes = recvmsg(to_copy->input, &header, 0);
- if (read_bytes != -1) {
- if (to_copy->interface_address != nullptr) {
- for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&header);
- cmsg != NULL;
- cmsg = CMSG_NXTHDR(&header, cmsg)) {
- if (cmsg->cmsg_level == IPPROTO_IP &&
- cmsg->cmsg_type == IP_PKTINFO) {
- unsigned char *data = CMSG_DATA(cmsg);
- struct in_pktinfo *pktinfo;
- memcpy(&pktinfo, &data, sizeof(void *));
- if (pktinfo->ipi_spec_dst.s_addr !=
- to_copy->interface_address->sin_addr.s_addr) {
- good_data = false;
- }
- }
- }
- }
- if (to_copy->source_address != nullptr) {
- CHECK_GE(header.msg_namelen, sizeof(struct sockaddr_in));
- if (to_copy->source_address->sin_port != hton<uint16_t>(0)) {
- if (sender_address.sin_port !=
- to_copy->source_address->sin_port) {
- good_data = false;
- }
- }
- if (sender_address.sin_addr.s_addr !=
- to_copy->source_address->sin_addr.s_addr) {
- good_data = false;
- }
- }
- }
- } else {
- read_bytes = read(to_copy->input,
- buffer + position, sizeof(buffer) - position);
- }
- if (read_bytes == -1) {
- if (errno != EINTR) {
- PLOG(FATAL, "read(%d, %p, %zd) failed",
- to_copy->input, buffer + position, position - sizeof(buffer));
- }
- } else if (read_bytes == 0 && to_copy->interface_address == NULL) {
- // read(2) says that this means EOF
- return NULL;
- }
- if (good_data) {
- position += read_bytes;
- }
- }
-
- CHECK_GE(position, 0);
- CHECK_LE(position, static_cast<ssize_t>(sizeof(buffer)));
- if (position > 0) {
- ssize_t sent_bytes = write(to_copy->output, buffer, position);
- if (sent_bytes == -1) {
- if (errno != EINTR) {
- PLOG(FATAL, "write(%d, %p, %zd) failed",
- to_copy->output, buffer, position);
- }
- } else if (sent_bytes != 0) {
- if (sent_bytes == position) {
- position = 0;
- } else {
- memmove(buffer, buffer + sent_bytes, position - sent_bytes);
- position -= sent_bytes;
- }
- }
- }
- }
-}
-
-int NetconsoleMain(int argc, char **argv) {
- WriteCoreDumps();
- logging::Init();
- logging::AddImplementation(new logging::StreamLogImplementation(stdout));
-
- int input, output;
- if (argc > 1) {
- output = open(argv[1], O_APPEND | O_CREAT | O_WRONLY | O_TRUNC, 0666);
- if (output == -1) {
- if (errno == EACCES || errno == ELOOP || errno == ENOSPC ||
- errno == ENOTDIR || errno == EROFS || errno == ETXTBSY) {
- PLOG(FATAL, "opening output file '%s' failed", argv[1]);
- }
- PLOG(FATAL, "open('%s', stuff, 0644) failed", argv[1]);
- }
- fprintf(stderr, "Writing output to '%s'.\n", argv[1]);
- input = -1;
- fprintf(stderr, "Not taking any input.\n");
- } else {
- output = STDOUT_FILENO;
- fprintf(stderr, "Writing output to stdout.\n");
- input = STDIN_FILENO;
- fprintf(stderr, "Reading stdin.\n");
- }
-
- int on = 1;
-
- int from_crio = socket(AF_INET, SOCK_DGRAM, 0);
- if (from_crio == -1) {
- PLOG(FATAL, "socket(AF_INET, SOCK_DGRAM, 0) failed");
- }
- if (setsockopt(from_crio, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
- PLOG(FATAL, "SOL_SOCKET::SO_REUSEADDR=%d(%d) failed", on, from_crio);
- }
- if (setsockopt(from_crio, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) == -1) {
- PLOG(FATAL, "SOL_SOCKET::SO_BROADCAST=%d(%d) failed", on, from_crio);
- }
- if (setsockopt(from_crio, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on)) == -1) {
- PLOG(FATAL, "IPROTO_IP::IP_PKTINFO=%d(%d) failed", on, from_crio);
- }
- union {
- struct sockaddr_in in;
- struct sockaddr addr;
- } address, crio_address;
-
- address.in.sin_family = AF_INET;
- address.in.sin_port = hton<uint16_t>(6666);
- address.in.sin_addr.s_addr = INADDR_ANY;
-
- crio_address.in.sin_family = AF_INET;
- crio_address.in.sin_port = hton<uint16_t>(0);
- crio_address.in.sin_addr = ::aos::configuration::GetOwnIPAddress();
- ::aos::util::SetLastSegment(&crio_address.in.sin_addr,
- ::aos::NetworkAddress::kCRIO);
-
- if (bind(from_crio, &address.addr, sizeof(address)) == -1) {
- PLOG(FATAL, "bind(%d, %p, %zu) failed",
- from_crio, &address.addr, sizeof(address));
- }
-
- pthread_t input_thread, output_thread;
-
- address.in.sin_addr = ::aos::configuration::GetOwnIPAddress();
- ::aos::util::SetLastSegment(&address.in.sin_addr, NetworkAddress::kCRIO);
- fprintf(stderr, "Using cRIO IP %s.\n",
- inet_ntoa(address.in.sin_addr));
-
- if (input != -1) {
- int to_crio = socket(AF_INET, SOCK_DGRAM, 0);
- if (to_crio == -1) {
- PLOG(FATAL, "socket(AF_INET, SOCK_DGRAM, 0) failed");
- }
- if (setsockopt(to_crio, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
- PLOG(FATAL, "SOL_SOCKET::SO_REUSEADDR=%d(%d) failed", on, to_crio);
- }
- address.in.sin_port = hton<uint16_t>(6668);
- if (connect(to_crio, &address.addr, sizeof(address)) == -1) {
- PLOG(FATAL, "connect(%d, %p, %zu) failed",
- to_crio, &address.addr, sizeof(address));
- }
- FDsToCopy input_fds{input, to_crio, nullptr, nullptr};
- if (pthread_create(&input_thread, NULL, FDCopyThread, &input_fds) == -1) {
- PLOG(FATAL, "pthread_create(%p, NULL, %p, %p) failed",
- &input_thread, FDCopyThread, &input_fds);
- }
- }
-
- address.in.sin_addr = ::aos::configuration::GetOwnIPAddress();
- FDsToCopy output_fds{from_crio, output, &address.in, &crio_address.in};
- if (pthread_create(&output_thread, NULL, FDCopyThread, &output_fds) == -1) {
- PLOG(FATAL, "pthread_create(%p, NULL, %p, %p) failed",
- &output_thread, FDCopyThread, &output_fds);
- }
-
- // input_thread will finish when stdin gets an EOF
- if (pthread_join((input == -1) ? output_thread : input_thread, NULL) == -1) {
- PLOG(FATAL, "pthread_join(a_thread, NULL) failed");
- }
- exit(EXIT_SUCCESS);
-}
-
-} // namespace
-} // namespace aos
-
-int main(int argc, char **argv) {
- return ::aos::NetconsoleMain(argc, argv);
-}
diff --git a/aos/linux_code/starter/starter.gyp b/aos/linux_code/starter/starter.gyp
index ee8c9ab..9a16647 100644
--- a/aos/linux_code/starter/starter.gyp
+++ b/aos/linux_code/starter/starter.gyp
@@ -1,19 +1,6 @@
{
'targets': [
{
- 'target_name': 'netconsole',
- 'type': 'executable',
- 'sources': [
- 'netconsole.cc',
- ],
- 'dependencies': [
- '<(AOS)/build/aos.gyp:logging',
- '<(AOS)/linux_code/linux_code.gyp:configuration',
- '<(AOS)/common/util/util.gyp:inet_addr',
- '<(AOS)/linux_code/linux_code.gyp:init',
- ],
- },
- {
'target_name': 'starter_exe',
'type': 'executable',
'sources': [
@@ -32,19 +19,8 @@
{
'destination': '<(rsync_dir)',
'files': [
- 'starter_loop.sh',
+ 'starter.sh',
],
- 'conditions': [
- ['FULL_COMPILER=="gcc_frc"', {
- 'files': [
- 'starter_roborio.sh',
- ],
- }, {
- 'files': [
- 'starter.sh',
- ],
- }
- ]],
},
],
},
diff --git a/aos/linux_code/starter/starter.sh b/aos/linux_code/starter/starter.sh
index 7bdf606..d2a0ae1 100755
--- a/aos/linux_code/starter/starter.sh
+++ b/aos/linux_code/starter/starter.sh
@@ -1,36 +1,7 @@
#!/bin/bash
-echo '/home/driver/tmp/robot_logs/%e-%s-%p-%t.coredump' > /proc/sys/kernel/core_pattern
+# NI already has a core pattern, so we probably shouldn't change it.
+#echo '/home/driver/tmp/robot_logs/%e-%s-%p-%t.coredump' > /proc/sys/kernel/core_pattern
-chrt -o 0 bash -c "export PATH=$PATH:/home/driver/robot_code/bin; starter_loop.sh $*" &
-STARTER_LOOP_PID=$!
-echo Starter is ${STARTER_LOOP_PID}.
-#chrt -o 0 bash -c "while true; do cd /home/driver/mjpg-streamer2; ./server.sh; sleep 5; done" &
-
-# Log everything from the serial port...
-#SERIAL_LOG_FILE=$(date "/home/driver/tmp/robot_logs/serial_log.%F_%H-%M-%S")
-#chrt -o 0 bash -c "( stty -echo -echoe -echok 9600; cat > ${SERIAL_LOG_FILE} ) < /dev/ttyUSB0" &
-
-# Wireshark _everything_ we can see...
-#DUMPCAP_LOG_FILE=$(date "/home/driver/tmp/robot_logs/dumpcap.%F_%H-%M-%S")
-#DUMPCAP_STDOUT_FILE=$(date "/home/driver/tmp/robot_logs/stdout_dumpcap.%F_%H-%M-%S")
-#chrt -o 0 bash -c "dumpcap -i eth0 -w ${DUMPCAP_LOG_FILE} -f 'not port 8080 and not net 10.9.71.13' > ${DUMPCAP_STDOUT_FILE}" &
-
-# Run netconsole to record what the cRIO sends.
-chrt -o 0 bash -c '
-NETCONSOLE_BASE=/home/driver/tmp/robot_logs/netconsole-
-existing=$(ls ${NETCONSOLE_BASE}*)
-if [[ $? -eq 0 ]]; then
- i=$(echo ${existing} | sed "s,${NETCONSOLE_BASE},,g; s/ /\n/g" | sort -g | tail -n1)
-else
- i=0
-fi
-while true; do
- /home/driver/robot_code/bin/netconsole ${NETCONSOLE_BASE}$((++i))
- sleep 1
-done
-' &
-NETCONSOLE_PID=$!
-echo Netconsole is ${NETCONSOLE_PID}.
-
-echo $$ > /tmp/starter.pid
+export PATH=$PATH:/home/admin/robot_code
+exec starter_loop.sh "$@"
diff --git a/aos/linux_code/starter/starter_loop.sh b/aos/linux_code/starter/starter_loop.sh
deleted file mode 100755
index 83d34cc..0000000
--- a/aos/linux_code/starter/starter_loop.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-for ((i=1; 1; i++)); do
- starter_exe $* 1>/tmp/starter${i}_stdout 2>/tmp/starter${i}_stderr
- sleep 2
-done
diff --git a/aos/linux_code/starter/starter_roborio.sh b/aos/linux_code/starter/starter_roborio.sh
deleted file mode 100755
index d2a0ae1..0000000
--- a/aos/linux_code/starter/starter_roborio.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-# NI already has a core pattern, so we probably shouldn't change it.
-#echo '/home/driver/tmp/robot_logs/%e-%s-%p-%t.coredump' > /proc/sys/kernel/core_pattern
-
-export PATH=$PATH:/home/admin/robot_code
-exec starter_loop.sh "$@"