Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mvp_all_java
Browse files Browse the repository at this point in the history
  • Loading branch information
pjreiniger committed Sep 11, 2024
2 parents 04dfc3a + 97c6c86 commit 4c48e5e
Show file tree
Hide file tree
Showing 48 changed files with 4,612 additions and 133 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/aql/wpilib-generic-gradle-cache_unused.aql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"files": [
{
"aql": {
"items.find": {
"$or":[
{ "repo": "wpilib-generic-gradlecache" },
{ "repo": "wpilib-generic-cache-cmake" }
],
"$or":[
{
"stat.downloaded": { "$before":"1mo" }
},
{
"stat.downloaded": { "$eq":null }
}
],
"created": { "$before":"1mo" }
}
}
}
]
}
29 changes: 29 additions & 0 deletions .github/workflows/aql/wpilib-mvn-development_unused.aql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"files": [
{
"aql": {
"items.find": {
"repo": "wpilib-mvn-development",
"path": { "$nmatch":"*edu/wpi/first/thirdparty*" },
"$or":[
{
"artifact.module.build.name": { "$eq":"allwpilib" }
},
{
"artifact.module.build.name": { "$eq":"combiner" }
}
],
"$or":[
{
"stat.downloaded": { "$before":"3mo" }
},
{
"stat.downloaded": { "$eq":null }
}
],
"created": { "$before":"3mo" }
}
}
}
]
}
33 changes: 33 additions & 0 deletions .github/workflows/artifactory-nightly-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Artifactory Nightly Cleanup

on:
workflow_dispatch:
schedule:
- cron: '15 2 * * *'

jobs:
wpilib-mvn-development_unused_cleanup:
runs-on: ubuntu-latest
if: github.repository == 'wpilibsuite/allwpilib' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: jfrog/setup-jfrog-cli@v4
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_CLI_SECRET }}
- name: Cleanup
run: jf rt del --spec=.github/workflows/aql/wpilib-mvn-development_unused.aql

wpilib-generic-gradle-cache_unused_cleanup:
runs-on: ubuntu-latest
if: github.repository == 'wpilibsuite/allwpilib' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: jfrog/setup-jfrog-cli@v4
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_CLI_SECRET }}
- name: Cleanup
run: jf rt del --spec=.github/workflows/aql/wpilib-generic-gradle-cache_unused.aql
18 changes: 13 additions & 5 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

env:
SCCACHE_WEBDAV_ENDPOINT: "https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-cmake-local"
SCCACHE_WEBDAV_KEY_PREFIX: "sccache"

jobs:
build:
strategy:
Expand Down Expand Up @@ -34,20 +38,22 @@ jobs:
run: brew install opencv protobuf@3 ninja
if: runner.os == 'macOS'

- name: Run sccache-cache
- name: Install sccache
uses: mozilla-actions/[email protected]

- uses: actions/checkout@v4

- name: configure
run: cmake ${{ matrix.flags }}
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: build
run: cmake --build build-cmake --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: test
working-directory: build-cmake
Expand Down Expand Up @@ -76,12 +82,14 @@ jobs:
- name: configure
run: cmake --preset sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=OFF -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: build
run: cmake --build build-cmake --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: test
working-directory: build-cmake
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

env:
SCCACHE_WEBDAV_ENDPOINT: "https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-cmake-local"
SCCACHE_WEBDAV_KEY_PREFIX: "sccache"

jobs:
build:
strategy:
Expand All @@ -31,21 +35,23 @@ jobs:
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java clang-14 libprotobuf-dev protobuf-compiler ninja-build

- name: Run sccache-cache
- name: Install sccache
uses: mozilla-actions/[email protected]

- uses: actions/checkout@v4

- name: configure
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 -DWITH_JAVA=OFF ${{ matrix.cmake-flags }} ..
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: test
working-directory: build
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/upstream-utils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ jobs:
cd upstream_utils
./apriltag.py clone
./apriltag.py copy-src
- name: Run concurrentqueue.py
run: |
cd upstream_utils
./concurrentqueue.py clone
./concurrentqueue.py copy-src
- name: Run eigen.py
run: |
cd upstream_utils
./eigen.py clone
./eigen.py copy-src
- name: Run expected.py
run: |
cd upstream_utils
./expected.py clone
./expected.py copy-src
- name: Run fmt.py
run: |
cd upstream_utils
Expand Down
7 changes: 7 additions & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ evaluationDependsOn(':wpimath')
evaluationDependsOn(':wpinet')
evaluationDependsOn(':wpiunits')
evaluationDependsOn(':wpiutil')
evaluationDependsOn(':romiVendordep')
evaluationDependsOn(':xrpVendordep')

def baseArtifactIdCpp = 'documentation'
def artifactGroupIdCpp = 'edu.wpi.first.wpilibc'
Expand All @@ -40,6 +42,8 @@ cppProjectZips.add(project(':wpilibc').cppHeadersZip)
cppProjectZips.add(project(':wpimath').cppHeadersZip)
cppProjectZips.add(project(':wpinet').cppHeadersZip)
cppProjectZips.add(project(':wpiutil').cppHeadersZip)
cppProjectZips.add(project(':romiVendordep').cppHeadersZip)
cppProjectZips.add(project(':xrpVendordep').cppHeadersZip)

doxygen {
// Doxygen binaries are only provided for x86_64 platforms
Expand Down Expand Up @@ -148,6 +152,7 @@ doxygen {

// Save space by excluding protobuf and eigen
exclude 'Eigen/**'
exclude 'unsupported/**'
exclude 'google/protobuf/**'

exclude '**/.clang-tidy'
Expand Down Expand Up @@ -223,6 +228,8 @@ task generateJavaDocs(type: Javadoc) {
source project(':wpinet').sourceSets.main.java
source project(':wpiunits').sourceSets.main.java
source project(':wpiutil').sourceSets.main.java
source project(':romiVendordep').sourceSets.main.java
source project(':xrpVendordep').sourceSets.main.java
source configurations.javaSource.collect { zipTree(it) }
include '**/*.java'
failOnError = true
Expand Down
4 changes: 2 additions & 2 deletions hal/src/main/native/athena/FRCDriverStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
std::string_view locationRef{location};
std::string_view callStackRef{callStack};

// 1 tag, 4 timestamp, 2 seqnum
// 2 size, 1 tag, 4 timestamp, 2 seqnum
// 2 numOccur, 4 error code, 1 flags, 6 strlen
// 1 extra needed for padding on Netcomm end.
size_t baseLength = 21;
size_t baseLength = 23;

if (baseLength + detailsRef.size() + locationRef.size() +
callStackRef.size() <=
Expand Down
59 changes: 59 additions & 0 deletions ntcore/src/dev/native/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
#include <wpi/print.h>
#include <wpi/timestamp.h>

#include "networktables/DoubleArrayTopic.h"
#include "networktables/NetworkTableInstance.h"
#include "ntcore.h"
#include "ntcore_c.h"
#include "ntcore_cpp.h"

void bench();
void bench2();
void stress();
void stress2();

int main(int argc, char* argv[]) {
wpi::impl::SetupNowDefaultOnRio();
Expand All @@ -40,6 +44,10 @@ int main(int argc, char* argv[]) {
stress();
return EXIT_SUCCESS;
}
if (argc == 2 && std::string_view{argv[1]} == "stress2") {
stress2();
return EXIT_SUCCESS;
}

auto myValue = nt::GetEntry(nt::GetDefaultInstance(), "MyValue");

Expand Down Expand Up @@ -266,3 +274,54 @@ void stress() {

std::this_thread::sleep_for(100s);
}

void stress2() {
using namespace std::chrono_literals;

auto testTopicName = "testTopic";
auto count = 1000;
std::atomic_bool isDone{false};
nt::PubSubOptions pubSubOptions{
.periodic = std::numeric_limits<double>::min(),
.sendAll = true,
.keepDuplicates = true};
auto server = nt::NetworkTableInstance::Create();
server.StartServer();
auto serverTopic = server.GetDoubleArrayTopic(testTopicName);
auto subscriber = serverTopic.Subscribe({}, pubSubOptions);
std::atomic_int receivedCount{0};
server.AddListener(subscriber, NT_EVENT_VALUE_REMOTE, [&](auto event) {
if (receivedCount.fetch_add(1) == count) {
isDone = true;
}
// Warnings about duplicate pubs occur if I either introduce this short
// delay...
std::this_thread::sleep_for(1ms);
// ...or a little IO
// System.out.println("Got %d: %s"
// .formatted(receivedCount.get(), Arrays.toString(
// event.valueData.value.getDoubleArray())));
});

auto client = nt::NetworkTableInstance::Create();
client.SetServer("localhost");
auto clientName = "test client";
client.StartClient4(clientName);
std::this_thread::sleep_for(2s); // Startup time.
int sentCount = 0;
while (sentCount < count) {
auto clientTopic = client.GetDoubleArrayTopic(testTopicName);
{
auto publisher = clientTopic.Publish(pubSubOptions);
publisher.Set(
{{static_cast<double>(sentCount), static_cast<double>(sentCount),
static_cast<double>(sentCount)}});
// client.Flush();
sentCount++;
}
std::this_thread::yield();
}

std::this_thread::sleep_for(10s);
fmt::print("isDone: {}", isDone.load());
}
14 changes: 6 additions & 8 deletions ntcore/src/main/native/cpp/net/ClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ void ClientImpl::HandleLocal(std::vector<ClientMessage>&& msgs) {
msg->properties, msg->options);
m_outgoing.SendMessage(msg->pubHandle, std::move(elem));
} else if (auto msg = std::get_if<UnpublishMsg>(&elem.contents)) {
if (Unpublish(msg->pubHandle, msg->topicHandle)) {
m_outgoing.SendMessage(msg->pubHandle, std::move(elem));
}
Unpublish(msg->pubHandle, msg->topicHandle, std::move(elem));
} else {
m_outgoing.SendMessage(0, std::move(elem));
}
Expand Down Expand Up @@ -199,12 +197,12 @@ void ClientImpl::Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
UpdatePeriodic();
}

bool ClientImpl::Unpublish(NT_Publisher pubHandle, NT_Topic topicHandle) {
void ClientImpl::Unpublish(NT_Publisher pubHandle, NT_Topic topicHandle,
ClientMessage&& msg) {
unsigned int index = Handle{pubHandle}.GetIndex();
if (index >= m_publishers.size()) {
return false;
return;
}
bool doSend = true;
m_publishers[index].reset();

// loop over all publishers to update period
Expand All @@ -216,10 +214,10 @@ bool ClientImpl::Unpublish(NT_Publisher pubHandle, NT_Topic topicHandle) {
}
UpdatePeriodic();

m_outgoing.SendMessage(pubHandle, std::move(msg));

// remove from outgoing handle map
m_outgoing.EraseHandle(pubHandle);

return doSend;
}

void ClientImpl::SetValue(NT_Publisher pubHandle, const Value& value) {
Expand Down
3 changes: 2 additions & 1 deletion ntcore/src/main/native/cpp/net/ClientImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class ClientImpl final : private ServerMessageHandler {
void Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
std::string_view name, std::string_view typeStr,
const wpi::json& properties, const PubSubOptionsImpl& options);
bool Unpublish(NT_Publisher pubHandle, NT_Topic topicHandle);
void Unpublish(NT_Publisher pubHandle, NT_Topic topicHandle,
ClientMessage&& msg);
void SetValue(NT_Publisher pubHandle, const Value& value);

int m_inst;
Expand Down
Loading

0 comments on commit 4c48e5e

Please sign in to comment.