Commit Graph

74 Commits

Author SHA1 Message Date
Austin Shalit
42facbb07e Make Java "struct" constructors public for testing/simulating (#195) 2017-04-30 08:48:02 -07:00
Thad House
e6656326a8 Adds field IP to round robin list (#187)
With how many more coprocessors are being added, this is probably needed
to make the field crew sane.
2017-02-09 00:55:01 -08:00
Peter Johnson
13457d1bf4 Update setUpdateRate() documentation to match implementation.
Update rates as fast as 10 ms are now allowed.

Fixes #184.
2017-01-18 21:32:15 -08:00
Thad House
3e2631f49b Fixes Java artifact clasifiers when using custom suffix (#183) 2017-01-05 14:13:57 -08:00
Peter Johnson
c091d74de4 jni_util: Add JException wrapper class.
This allows more natural C++ Throw semantics (for a variety of string
data types) for any java exception that just takes a String argument.
2016-12-15 21:54:36 -08:00
Peter Johnson
19be09c361 Add null checks on all JNI object parameters. 2016-12-15 00:27:32 -08:00
Peter Johnson
ce7611562f Make JClass more useful and use it in ntcore JNI. 2016-12-14 23:29:18 -08:00
Thad House
bc06c843c7 Adds JNI symbol check to ensure we don't miss any definitions (#160) 2016-11-25 17:07:58 -08:00
Peter Johnson
259cf1ff3a Mark NetworkTablesJNI callback interfaces as FunctionalInterface. (#154)
This allows them to be used in Java 8 lambdas.
2016-11-13 23:33:12 -08:00
Peter Johnson
77edf1e103 Add FRC Driver Station connection support.
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.
2016-11-04 23:42:41 -07:00
Peter Johnson
778edaeb28 Reverse the JNI load order to look for system library first. (#145) 2016-10-25 22:27:33 -07:00
Thad House
c45384b91a Removes the native library from the RoboRIO Jar (#139)
Includes the native zip in the maven artifact as well.
2016-10-25 20:42:06 -07:00
Peter Johnson
011ac1fa22 Java: Allow any Number type (not just Double) to be passed to putValue(). (#129)
Also improve exception message.

Fixes #72.
2016-10-21 19:17:50 -07:00
Thad House
b775b01e0a Optimizes NetworkTables string concatenation (#125)
During testing, I was seeing a lot of unnecessary code (and allocations
in Java/C#) when appending the path separator to the base path. That
technically is a constant, so this computes this constant during class
construction.
2016-10-17 22:33:59 -07:00
Peter Johnson
94c2b65798 Refactor JNI helpers into wpiutil (support/jni_util.h). (#105) 2016-09-25 19:29:17 -07:00
Thad House
3888d7726a Adds connection listeners that can be called statically (#111)
This way you can have a connection listener before initializing NetworkTables.
2016-09-06 21:30:59 -07:00
Peter Johnson
8007a7b153 Correctly handle UTF8 Java translation for StringArray. (#103) 2016-08-26 21:55:11 -07:00
Thad House
bc99d341fb Changes remote_name to remote_ip (#87)
Was confusing, as remote_name seemed like a name but wasn't.
Also changes remote_ip in the C api to use an NT_String
2016-08-07 16:38:20 -05:00
Fredric Silberberg
0f9f7309e3 Sets the duplicate strategy to exclude in all zip tasks (#85) 2016-07-30 23:07:21 -05:00
Peter Johnson
30fbfe46e6 Create dummy wpiutil library. (#84)
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.
2016-07-27 22:18:56 -05:00
Peter Johnson
a73166a665 Make many more utility classes/headers public. (#76)
Moving these headers from src to include enables other libraries to use the
functionality provided.

* tcpsockets
* atomic_static
* raw_istream
* timestamp
* SafeThread
* Base64
* LEB128
* ConcurrentQueue

The classes have been moved into the wpi namespace as they're generic.
2016-07-27 00:39:38 -07:00
Thad House
58092c5190 Adds SetDefault methods to NetworkTables (#54)
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.
2016-07-13 00:31:03 -07:00
Fredric Silberberg
384ad57d21 Updates Gradle to 2.14 (#78) 2016-06-30 19:57:29 -07:00
Peter Johnson
3c77faaf61 Fix UTF8 conversion in Java. (#70)
Java doesn't use standard UTF8, so surrogate pairs were being converted
incorrectly and incompatibly with C++.

Fixes #69 (artf3973).
2016-06-10 22:24:42 -04:00
Jonathan Leitschuh
6272244a73 Adds error-prone to check java code 2016-05-13 21:17:20 -07:00
Peter Johnson
5ac68f74d4 Support client round robin to multiple server addresses.
Change-Id: If87dc64a485b1c8a340c5f6fa39ca09d40133e30
2016-04-08 22:02:52 -07:00
Peter Johnson
b8ad1de33c Make members of ConnectionInfo and EntryInfo public. 2016-04-08 13:08:07 -07:00
Thad House
710bd586d5 Adds extended Remote Connection Listener
Since we now get ConnectionInfo when setting a connection listener,
there is some good information in there that teams could use.
Implemented using default interface methods, so teams should see no
change if they don't implement the Ex methods.

I noticed that the connection listener methods don't exist at all in
C++, so they did not get added there.
2016-02-06 23:28:19 -08:00
Thad House
73d6e98bf2 Loads ntcore from path if extracted load fails
There's a lot of buzz going around the internet about people trying to
get ntcore working on other devices. One of the things that makes it
harder is having to have a separate jar for each platform. What this
change does is if the loading of the extracted library fails, it will
attempt to load ntcore from the path. This means that a program like
GRIP can just provide the libntcore.so and not have to worry about
compiling different versions for different platforms.
2016-01-18 22:39:27 -08:00
Peter Johnson
c90a8c586f getTable(): Don't prepend slash if key already starts with it.
This makes getTable("/foo") and getTable("foo") equivalent.
2016-01-14 21:38:04 -08:00
Peter Johnson
af2f54720d Java: Don't detach thread when releasing globals.
JavaGlobal was unconditionally attaching to (okay) and detaching from (bad)
the current thread during destruction.  We don't want to do this if the
destructor gets called from an attached thread.  Instead, use GetEnv to
first try to get the environment, and only attach and detach if it returns
an error saying the thread is detached.

Also, make sure notifier callbacks appropriately free Java locals to avoid
running out of local variable space.
2016-01-01 19:05:00 -08:00
Peter Johnson
fef8f933d9 Add SafeThread to fix thread JNI shutdown races.
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).
2015-12-28 17:51:56 -08:00
Peter Johnson
8b3f4aa68c Remove unused member variable. 2015-12-21 09:03:30 -08:00
Peter Johnson
65e4eeeb7c Fix Windows linkage.
Windows needs ATOMIC_STATIC_INIT.
2015-12-20 21:06:17 -08:00
Peter Johnson
298dc54910 Fix Windows build. 2015-12-20 20:55:36 -08:00
Peter Johnson
32001427d4 Java: call JNI AttachCurrentThread less frequently.
Each call to AttachCurrentThread results in a new Java thread object being
created.  This is inefficient and also causes debugging issues with Eclipse
due to constant creation and removal of threads.  Now AttachCurrentThread is
only called once for (all) listeners and once for logging (if used).
2015-12-20 20:42:09 -08:00
Peter Johnson
76ee093e92 Add exception-generating C++ functions, but mark as deprecated.
These are good to have for backwards compatibility, but discouraged for new
development (default-taking functions should be used instead).  The reason
is that the exceptions must be explicitly handled and may initially work but
then fail at an inopportune moment.

Mark the similar Java functions as deprecated as well for the same reason.

Update all the docs for consistency.

Mark overridden functions as such in both C++ and Java.

Make IsPersistent and GetFlags const in C++.
2015-12-06 22:39:38 -08:00
Fredric Silberberg
db91e20ec7 Updated ntcore build to build both arm and native versions
Change-Id: I515f051bbb816a1a82667462ad4e140cdb0fabdc
2015-12-06 14:43:30 -05:00
Peter Johnson
3cd20d3ff2 Java: Fix getValue(). 2015-12-06 08:22:34 -08:00
Fredric Silberberg
26c27756af Updated the definitions file to add overloaded functions, added
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
2015-11-23 18:36:43 -05:00
Peter Johnson
c76e60324b Add Java support for raw values.
Either ByteBuffer or byte[] can be used for putRaw().
getRaw() returns byte[].
2015-11-20 01:22:26 -08:00
Thad House
2e050b0540 Makes SetTeam use Mdns 2015-11-19 23:02:39 -08:00
Jonathan Leitschuh
4c42712b24 Makes ITableListener a lambda function 2015-11-18 01:39:53 -05:00
Fredric Silberberg
6a0485a72c Fixed mac lib path
Change-Id: Ib6f38b7f42df9c9908c7e60eca12dd48c9c4114a
2015-11-17 18:51:16 -05:00
Peter Johnson
9200b7c78c Add extern "C" to JNI definitions to catch mismatches. 2015-11-01 07:44:43 -08:00
Fredric Silberberg
b793810e4a Fixes for mac builds
Change-Id: I66dafd5e6d5ff10e7fb98cf718bb6f9343d03184
2015-10-31 18:49:11 -04:00
Fredric Silberberg
9df5f5e27a When running on jenkins, the base name of produced archives becomes the project name. This fixes that to be the correct name.
Change-Id: Ie5a25bf9eabdb8fb1a1ee14d56e2e7badc634afc
2015-10-31 14:28:54 -04:00
Fredric Silberberg
77cf3adf64 This commit updates the gradle files to be cleaner. It also builds for the
current platform by default, and only builds tests when building for the
current platform. Mac builds and VS2015 builds are fixed.

The other big change in this update is the introduction of Debug and
Release builds. Debug builds are built with -O0 and -g. Release builds are
built with -O2 and -g. For GCC-based builds, the resulting shared object
is copied, stripped of debug information, and a debug link is set up to
the copied shared object. This allows the release build to clock in at
around 600 KB. On Windows, the debug info is already stored in a separate
PDB file, so this copy and strip is not necessary.

ntcore is being separated out from the rest of allwpilib. All other
builds will consume a published maven dependency from this project.
There are 4 possible publishing targets now: release, stable, beta, and
development. These are specified on the command line via -Prepo=<repo
name>.

Change-Id: Ie8cb21f910953e09b80a5192317033eb0866cb70
2015-10-31 13:31:01 -04:00
Joe Ross
202cb8bb1f fix javadoc warnings/errors 2015-10-03 19:20:26 -07:00
Peter Johnson
90959defd9 Provide more extensive listener features.
This enables listeners to be notified of not only value updates, but also flag
changes and deletions by using a bitmask to specify what notifications are
desired.  The old API (which only provided a new/not new) flag is still
supported.  This also subsumes the feature to listen to local changes (that's
one of the bitmask options).
2015-09-27 01:55:32 -07:00