The 2017 FRC Driver Station supports getting the robot IP via a TCP
connection that returns JSON. Use this to support overriding the
server IP address used for client connections.
Default to using this approach for client connections in the NetworkTable
interfaces.
Add support for setting the server address without stopping and
restarting the client.
SetTeam now also round-robins by default.
This will allow dependencies such as wpilibc to update to use wpiutil
without breaking "normal" ntcore static library use in the meantime.
This commit also restructures the gradle files by creating a new
(placeholder) wpiutil project, and moving the ntcore project into
a separate gradle file. Added toolchains/native.gradle (refactored from
ntcore).
Also fixes ntcore skipJava on Windows by providing an alternate .def file
for this case.
There was no way to atomically check for a key in the table,
and then setting if it if non existant. Back before persistent
this was not a problem, however now it is, as its possible for
values to be added before team's robot programs start. This makes
the old method of calling Put*** methods in RobotInit invalid.
This adds SetDefault methods, which do this atomically.
During JVM shutdown, some JNI calls may not return, so it's not possible to
reliably perform a join() during static variable destruction (which occurs
as the JVM unloads the JNI module).
Also, due to static variable destruction, it's not safe to use any members
of a static class instance from a separate thread of execution.
SafeThread is a templated thread class and a related owner class that's
designed for safe operation and shutdown of threads in the presence of
callbacks that may not return. It also passes ownership of variables from
the static instance to the thread, so the thread can safely operate until
it exits (the last operation of the thread being to destroy its instance).
Notifiers, RpcServer, and Logger now use SafeThread to ensure race-free
destruction in both C++ and Java.
All Java callback threads are now marked as Java daemon threads so they
don't keep the JVM running after main() terminates.
All Java callback threads are now named so their purpose is more easily
identified in a debugger.
Add SetRpcServerOnStart and SetRpcServerOnExit (similar to Listener).
no-unused-private-field for Mac builds. Gradle also now works
with the classifier-based dependency system, rather than having
separate repos for every level.
Change-Id: I2eb87391181e91b5675e3e982e4d915be83e14ea
The JVM doesn't always do a good job of telling JNI modules that the JVM
is going away, which results in a crash in the JavaGlobal and/or
JavaWeakGlobal destructors as they try to delete the associated references
after the JVM has already gone away.
To protect against this, the Notifier now has a static variable that's set
when the Notifier instance (a singleton) is destroyed. This is used by
JavaGlobal and JavaWeakGlobal to detect when a process exit is in process.
Starting to add Getters, Setters, and Allocators to the C interface
Because of the union in the NT_Value structure, some languages would
have a difficult time with the interop. This commit adds individual
getters and setters to the C interface to make interop easier.
In addition, some languages cannot allocate native memory in the same
heap that the C code would use. This adds allocation functions to make
sure that all our memory is allocated and can be freed properly from the
same heap.
The reason the getters are not individual get functions are because that
would require the calling code to first get the type, and then call the
specific getter for that type. Doing combined get functions causes
interop code to only have to cross interop boundaries once to get the
value instead of twice, for a light performance increase. However, this
could be changed without much work.
NT getters and setters round 2
Fixed some of the code based on the comments in the pull request.
Creates individual getters.
Should work better then 1 single getter.
Fixes end of file new line, and fixes function nameing
SetNTValue... made less sense then SetEntry... Matches the getter
naming.
Fixed methods to be less leaky.
Fixed Formatting, Fixed return values on Bool and Double. Added Contains Key
Changed ContainsKey to GetType. Also renamed Arr to Array
In public functions, I think I like Array better then Arr. Also, make
the getters that use value check for a null value, which should prevent
segfaults.
Fixes C++ Type functions to work properly
NTString Set functions still do not work properly though. I need some
help on there. Error message is in the pull request.
Changes Get functions to return status and have pointer to data passed in to be set.
Fixes NT_Strings
Added new functions to ntcore.def
Fixes NT_PostRpcResponse in the def file
Was NT_PostRpcRepsonse, which was failing the build.
Removed unused parameter from setters
Since we were forcing exports in the cmake build, they were seen in
windows, but since the header didnt match the implementation they
wouldn't export on linux. So fixed that. Linux builds now work properly,
tested on a physical RIO.
Added a DisposeEntryInfoArray method.
There was no way to free the array returned from GetEntryInfo
Adds NT_DisposeEntryInfoArray to the def file.
Implement automatic persistent saves.
Also loads persistent file on server start.
Update TODO.
raw_istream and kin: a few cleanups.
anchor() doesn't seem to change compiler output in current compilers, so
remove it. Use default where appropriate rather than empty bodies.
Clean up trailing whitespace.
Dispatcher: Move several fixed initial values to header.
Uninline constructors to reduce GetInstance() inlined code size.
Logger: Move m_min_level init to header.
Replaced time.h with std::chrono
This implementation returns the same values as the previous one on both a Linux machine and the roboRIO.
Value: Use variant of enable_if to fix MakeString/MakeRaw in GCC.
Tested on GCC 4.8, GCC 4.9, and clang 3.6.
Don't dispose in ConvertToC for NT_String and NT_Value.
Fixes#16.
Fixed Gradle build to actually export proper functions
Finishes fixes in pull request
Changes array setters to be const
To build RPC, needed a way to allocate a Char Array
Since after the callback, the C code explicitly frees, a way to make
sure to allocate the callback return string from the same heap was
needed.
Adds const to NTString setters.
Removes Const from NTString setters
The JNI bindings are built directly into the shared library. In the gradle
build, all built shared libraries are embedded into the generated jar.
Java bindings may be disabled via -DWITHOUT_JAVA (cmake) or -PskipJava=true
(gradle).
TODO:
- getEntryInfo() and RPC are not yet implemented.
- The cmake build doesn't integrate the built objects into the jar.
- The Java client and server tests are not built (but have been manually
tested).
This has not yet been tested on Windows.