438 Commits

Author SHA1 Message Date
Peter Johnson
ed168b522c [ntcore] Disable buf pool when asan is enabled (#5843)
This helps asan catch more errors.
2023-10-29 16:49:31 -07:00
Peter Johnson
c7d6ad5a0b [ntcore] WebSocketConnection: Use weak capture (#5822)
Fixes a potential use-after-free on connection close.
2023-10-25 10:22:43 -07:00
Peter Johnson
8efa586ace [ntcore] Don't check type string on publishing an entry (#5816)
Only check the raw type value.
2023-10-24 00:12:02 -07:00
Peter Johnson
196d963dc4 [ntcore] Fix off-by-one error in stream write (#5810) 2023-10-23 21:31:36 -07:00
Peter Johnson
1fa7445667 [ntcore] Check for valid client in incoming text and binary (#5799) 2023-10-20 23:25:05 -07:00
Peter Johnson
cf54d9ccb7 [wpiutil, ntcore] Add structured data support (#5391)
This adds support for two serialization formats for complex data types:

- Protobuf for complex objects with variable length internals that need forward and backward wire compatibility (lower speed, more flexible)
- Raw struct (ByteBuffer-style) for fixed-length objects (higher speed, less flexible)

Deserialization can be done either by creating a new object (for immutable objects) or overwriting the contents of an existing object (for mutable objects).

Implementing classes should provide inner classes that implement the Protobuf or Struct interface (in Java) or specialize the wpi::Protobuf or wpi::Struct struct (in C++). It is possible for classes to implement both. If the class itself does not implement serialization, it's possible for third parties/users to provide an implementation instead.

Uses the Google protobuf implementation for C++ and the QuickBuffers alternative protobuf implementation for Java.
2023-10-19 21:41:47 -07:00
Peter Johnson
7c6fe56cf2 [ntcore] Fix crash on disconnect (#5788)
The object was being destroyed due to the error handling path.
Instead, defer to the next loop cycle using a one-shot timer.

Properly handle error return values from Send functions.

Fix UB in accessing one past the end of a vector.
2023-10-19 14:36:22 -07:00
Peter Johnson
7d9ba256c2 Revert "[build] Add CMake option to build Java source jars (#5756)" (#5766)
This reverts commit 1c724884ca.

This commit broke local builds on the second run of cmake configure.
2023-10-14 23:53:27 -07:00
PJ Reiniger
210255bfff [wpiutil] Update json to 3.11.2 (#5680) 2023-10-14 21:53:56 -07:00
Gold856
1c724884ca [build] Add CMake option to build Java source jars (#5756) 2023-10-11 12:50:54 -07:00
Peter Johnson
1d23513945 [ntcore] Fix string array value comparison (#5745)
It did not correctly check size prior to checking size=0.
2023-10-10 00:27:56 -07:00
Peter Johnson
420f2f7c80 [ntcore] Add RTT-only subprotocol (#5731)
This is useful for aliveness checking by clients that can't send
WebSocket PING messages.
2023-10-08 00:35:10 -07:00
Peter Johnson
2b63e35ded [ntcore] Fix moving outgoing queue to new period (#5735)
std::remove_if() is destructive--it can assume the removed elements are
not used, but NetworkOutgoingQueue needs them to stay intact to be moved
to a different queue. Use std::stable_partition() instead.
2023-10-08 00:34:36 -07:00
Peter Johnson
be939cb636 [ntcore] Fix notification of SetDefaultEntryValue (#5733) 2023-10-07 20:42:55 -07:00
Peter Johnson
8b7c6852cf [ntcore] Networking improvements (#5659)
- Utilize TrySend to properly backpressure network traffic
- Split updates into reasonable sized frames using WS fragmentation
- Use WS pings for network aliveness (requires 4.1 protocol revision)
- Measure RTT only at start of connection, rather than periodically
  (this avoids them being affected by other network traffic)
- Refactor network queue
- Refactor network ping, ping from server as well
- Improve meta topic performance
- Implement unified approach for network value updates (currently client and server use very different approaches) that respects requested subscriber update frequency

This adds a new protocol version (4.1) due to WS bugs in prior versions.
2023-10-04 22:02:42 -07:00
Peter Johnson
aecbcb08fc [ntcore] Correctly start DataLog for existing publishers (#5703) 2023-10-01 06:43:18 -07:00
Ryan Blue
e8d4a20331 [build][cmake] Fix windows tests and re-enable CI tests (#5674) 2023-09-22 15:39:35 -07:00
PJ Reiniger
dd5612fbee [json] Add forward definition header (#5676) 2023-09-22 13:01:27 -07:00
Tyler Veness
5ab54ff760 Replace wpi::raw_istream with wpi::MemoryBuffer (#5675)
Instances of wpi::raw_istream were left that are reading incrementally
from file descriptors like USB devices.
2023-09-21 23:20:09 -07:00
Tyler Veness
1b6ec5a95d [wpiutil] Upgrade to LLVM 17.0.1 (#5482) 2023-09-21 19:54:33 -07:00
Tyler Veness
07a0d22fe6 [build] Build examples in CMake CI (#5667) 2023-09-20 21:03:55 -07:00
Peter Johnson
7be290147c [wpiutil] Refactor SpanMatcher and TestPrinters from ntcore (#5658) 2023-09-18 00:11:36 -07:00
Peter Johnson
e93c233d60 [ntcore] Compute Value memory size when creating value (#5657)
This avoids a later switch-based computation in NetworkLoopQueue.
2023-09-17 20:01:57 -07:00
autoantwort
cb99517838 [build] cmake: Use default install location on windows for dlls (#5580) 2023-09-17 16:17:32 -07:00
Tyler Veness
4f2114d6f5 Fix warnings from GCC 13 release build (#5637) 2023-09-15 10:37:52 -07:00
autoantwort
4fa56fd884 [build] Add missing find_dependency call (#5623) 2023-09-09 18:57:12 -07:00
Tyler Veness
3a33ce918b [ntcore] Add missing StringMap include (#5620) 2023-09-08 20:13:57 -07:00
Tyler Veness
a8d4b162ab [ntcore] Remove RPC manual tests (#5590)
NT4 doesn't support RPC.
2023-08-29 16:25:54 -07:00
Tyler Veness
b7657a8e28 [wpimath] Split WPIMathJNI into logical chunks (#5552)
This makes things easier to find, and speeds up compilation.
2023-08-29 09:00:19 -07:00
Tyler Veness
165ebe4c79 Upgrade to fmt 10.1.0 (#5326) 2023-08-28 15:15:14 -07:00
Tyler Veness
8e2a7fd306 Include thirdparty libraries with angle brackets (#5578) 2023-08-28 15:13:34 -07:00
Tyler Veness
9d86624c00 [build] Fix CMake configure warnings (#5577)
FetchContent requires CMake 3.11 (released Mar 28, 2018).

Fixed this warning:
```
CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1316 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  imgui/CMakeLists.txt:23 (FetchContent_Declare)
```
2023-08-28 15:06:51 -07:00
Joseph Eng
2e4ad35e36 [wpiutil] jni_util: Add JSpan and CriticalJSpan (#5554)
These replace JArrayRef et al and support statically sized arrays similar to std::span.
2023-08-24 00:02:56 -07:00
Peter Johnson
89e738262c [ntcore] Limit buffer pool size to 64KB per connection (#5485)
Previously this was unlimited, which could result in holding on to a
large amount of memory if the connection got backlogged or a burst of
data transmission occurred.
2023-08-20 13:53:52 -07:00
Tyler Veness
96f7fa662e Upgrade Maven dependencies (#5553)
The following source code changes were required:

* Whitespace changes from spotless
* PMD warning suppressions for utility class tests
* PMD warning rename from "BeanMembersShouldSerialize" to
  "NonSerializableClass"
* Declared more class members as final
2023-08-18 19:18:33 -07:00
Peter Johnson
c01814b80e [wpiutil] Add C API for DataLog (#5509) 2023-08-06 20:18:50 -07:00
Peter Johnson
b46a872494 [ntcore] Remove pImpl from implementation (#5480)
Also change Timestamped into a template.
2023-08-03 23:43:55 -07:00
Peter Johnson
7496e0d208 [ntcore] Value: More efficiently store arrays (#5484) 2023-08-01 22:26:36 -07:00
Peter Johnson
a95994fff6 [wpiutil] timestamp: Call FPGA functions directly (#5235)
This works around an exit race with wpi::Now() on Rio; it was overridden
to call HAL_GetFPGATime(), which calls chipobject, but on exit, because
there was not a library dependency, the chipobject could be destroyed
prior to wpiutil/wpinet being shut down.
2023-07-24 23:03:28 -07:00
Carl Hauser
c3fab7f1f2 [ntcore] Don't update timestamp when value is unchanged (#5356)
This fixes an issue with commands run/cancel.
2023-07-23 17:36:26 -07:00
Peter Johnson
fb57d82e52 [ntcore] Enhance Java raw value support
Add support for start, length, and ByteBuffers
2023-07-22 17:17:52 -07:00
Gold856
1f6428ab63 [ntcore] Fix undefined comparison behavior when array is empty (#5448)
If both arrays are empty, it returns true, avoiding UB with memcmp potentially getting a nullptr.
2023-07-17 17:16:54 -07:00
Peter Johnson
f031513470 [ntcore] NetworkTable::GetSubTables(): Remove duplicates (#5076)
In Java, a set is used. Use a two-stage approach in C++ to achieve the
same result.
2023-07-09 21:31:58 -07:00
Tyler Veness
5d3a133f9f Remove spaces in NOLINT comments (#5407)
clang-tidy ignores the category filter if there's a space. wpiformat now
ignores categories it doesn't understand, so we can remove the spaces.
2023-06-20 20:29:23 -07:00
Tyler Veness
0eccc3f247 [ntcore] Fix clang-tidy warnings (#5405) 2023-06-20 08:21:44 -07:00
Tyler Veness
652d1c44e3 [wpiutil] Upgrade to macOS 12 to remove concept shims (#5379)
The macOS deployment target has been upgraded from 10.15 to 11. Also, a
deprecation warning for sprintf() in libuv was suppressed.
2023-06-08 19:59:54 -07:00
Tyler Veness
59905ea721 Replace WPI_DEPRECATED() macro with [[deprecated]] attribute (#5373)
Continue to use WPI_DEPRECATED macro for constructors until clang-format is fixed.
2023-06-08 00:01:06 -07:00
Ryan Blue
753cb49a5e [ntcore] Fix doxygen module in generated C types (NFC) (#5374) 2023-06-07 09:56:20 -07:00
Tyler Veness
91cbcea841 Replace SFINAE with concepts (#5361)
Concepts are cleaner to use and result in much better error messages for incorrect template use.
2023-06-07 09:50:09 -07:00
Tyler Veness
5fac18ff4a Update formatting to clang-format 16 (#5370) 2023-05-31 22:10:53 -07:00