refactored the IP address handling code
It is now split up much more cleanly, has less stuff running on the
cRIO, and doesn't do as much of the stuff with string manipulation.
Before, it was kind of ridicilous how many times the code converted IP
addresses back and forth between 32-bit ints and strings to do various
manipulations and pass them around. Also, there was various junk that
the cRIO code did that it did not need to be doing.
diff --git a/frc971/crio/crio.gyp b/frc971/crio/crio.gyp
index dad68a8..d544f71 100644
--- a/frc971/crio/crio.gyp
+++ b/frc971/crio/crio.gyp
@@ -8,7 +8,8 @@
],
'dependencies': [
'<(EXTERNALS):WPILib',
- '<(AOS)/common/common.gyp:common',
+ '<(AOS)/crio/crio.gyp:ip',
+ '<(AOS)/common/common.gyp:util',
],
},
{
diff --git a/frc971/crio/dumb_main.cc b/frc971/crio/dumb_main.cc
index 4accd9c..8cf0eb4 100644
--- a/frc971/crio/dumb_main.cc
+++ b/frc971/crio/dumb_main.cc
@@ -1,17 +1,23 @@
#include "WPILib/NetworkRobot/NetworkRobot.h"
#include "WPILib/RobotBase.h"
-#include "aos/common/Configuration.h"
+
+#include "aos/common/network_port.h"
+#include "aos/crio/ip.h"
+#include "aos/common/util.h"
+
+using ::aos::util::MakeIPAddress;
+using ::aos::util::GetOwnIPAddress;
namespace frc971 {
class MyRobot : public NetworkRobot {
public:
MyRobot() : NetworkRobot(static_cast<uint16_t>(::aos::NetworkPort::kMotors),
- ::aos::configuration::GetIPAddress(
- ::aos::configuration::NetworkDevice::kAtom),
+ ::MakeIPAddress(::GetOwnIPAddress(),
+ ::aos::NetworkAddress::kAtom),
static_cast<uint16_t>(::aos::NetworkPort::kDS),
- ::aos::configuration::GetIPAddress(
- ::aos::configuration::NetworkDevice::kAtom)) {}
+ ::MakeIPAddress(::GetOwnIPAddress(),
+ ::aos::NetworkAddress::kAtom)) {}
};
} // namespace frc971
diff --git a/frc971/output/CameraServer.cc b/frc971/output/CameraServer.cc
index 944f417..939731d 100644
--- a/frc971/output/CameraServer.cc
+++ b/frc971/output/CameraServer.cc
@@ -3,11 +3,11 @@
#include "aos/atom_code/output/HTTPServer.h"
#include "aos/atom_code/output/evhttp_ctemplate_emitter.h"
#include "aos/atom_code/output/ctemplate_cache.h"
-#include "aos/common/Configuration.h"
#include "aos/common/messages/RobotState.q.h"
#include "ctemplate/template.h"
#include "aos/atom_code/init.h"
#include "aos/common/logging/logging.h"
+#include "aos/atom_code/configuration.h"
#include "frc971/constants.h"
@@ -17,7 +17,7 @@
class CameraServer : public aos::http::HTTPServer {
public:
- CameraServer() : HTTPServer(aos::configuration::GetRootDirectory(), 8080),
+ CameraServer() : HTTPServer(::aos::configuration::GetRootDirectory(), 8080),
buf_(NULL) {
AddPage<CameraServer>("/robot.html", &CameraServer::RobotHTML, this);
}
diff --git a/frc971/output/output.gyp b/frc971/output/output.gyp
index 6643d73..90fccb2 100644
--- a/frc971/output/output.gyp
+++ b/frc971/output/output.gyp
@@ -12,6 +12,7 @@
'<(AOS)/atom_code/atom_code.gyp:init',
'<(AOS)/build/aos.gyp:logging',
'<(AOS)/common/messages/messages.gyp:aos_queues',
+ '<(AOS)/atom_code/atom_code.gyp:configuration',
],
'copies': [
{