From ec7f38562059a89f3a9ca38e8dc6427fe40d0a4a Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sun, 21 Jan 2024 16:52:20 -0500 Subject: [PATCH] Set wpi::Now source on roborio when executing `-m cscore` - Fixes #62 --- subprojects/robotpy-cscore/cscore/__main__.py | 8 ++++++++ subprojects/robotpy-cscore/cscore/src/main.cpp | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/subprojects/robotpy-cscore/cscore/__main__.py b/subprojects/robotpy-cscore/cscore/__main__.py index d4fe25f5..51be70c6 100644 --- a/subprojects/robotpy-cscore/cscore/__main__.py +++ b/subprojects/robotpy-cscore/cscore/__main__.py @@ -159,4 +159,12 @@ def main(): if __name__ == "__main__": + # Setup wpi::now on roborio when executed as __main__ + try: + from ._cscore import _setupWpiNow # type: ignore + + _setupWpiNow() + except ImportError: + pass + main() diff --git a/subprojects/robotpy-cscore/cscore/src/main.cpp b/subprojects/robotpy-cscore/cscore/src/main.cpp index 8d999cd3..9e9db309 100644 --- a/subprojects/robotpy-cscore/cscore/src/main.cpp +++ b/subprojects/robotpy-cscore/cscore/src/main.cpp @@ -3,6 +3,12 @@ #include "cscore_cpp.h" +#ifdef __FRC_ROBORIO__ +extern "C" { + void WPI_Impl_SetupNowUseDefaultOnRio(void); +} +#endif + RPYBUILD_PYBIND11_MODULE(m) { initWrapper(m); @@ -16,4 +22,8 @@ RPYBUILD_PYBIND11_MODULE(m) { CS_Shutdown(); }); m.add_object("_cleanup", cleanup); + + #ifdef __FRC_ROBORIO__ + m.def("_setupWpiNow", WPI_Impl_SetupNowUseDefaultOnRio); + #endif } \ No newline at end of file