Skip to content

Commit

Permalink
Set wpi::Now source on roborio when executing -m cscore
Browse files Browse the repository at this point in the history
- Fixes #62
  • Loading branch information
virtuald committed Jan 21, 2024
1 parent a07b9d9 commit ec7f385
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions subprojects/robotpy-cscore/cscore/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 10 additions & 0 deletions subprojects/robotpy-cscore/cscore/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
}

0 comments on commit ec7f385

Please sign in to comment.