diff --git a/wpilibj/athena.gradle b/wpilibj/athena.gradle index 539a787e8a..fad622c81e 100644 --- a/wpilibj/athena.gradle +++ b/wpilibj/athena.gradle @@ -35,6 +35,7 @@ model { tasks.withType(CppCompile) { dependsOn jniHeaders cppCompiler.args "-DNAMESPACED_PRIORITY" + cppCompiler.args "-DCONFIG_ATHENA" addNiLibraryLinks(linker, targetPlatform) addWpiUtilLibraryLinks(it, linker, targetPlatform) } diff --git a/wpilibj/src/athena/cpp/lib/CANJNI.cpp b/wpilibj/src/athena/cpp/lib/CANJNI.cpp index 1dca8e98c9..64fd454569 100644 --- a/wpilibj/src/athena/cpp/lib/CANJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/CANJNI.cpp @@ -8,7 +8,9 @@ #include #include +#ifdef CONFIG_ATHENA #include "FRC_NetworkCommunication/CANSessionMux.h" +#endif #include "HAL/cpp/Log.h" #include "HALUtil.h" #include "edu_wpi_first_wpilibj_can_CANJNI.h" @@ -37,6 +39,7 @@ extern "C" { JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxSendMessage( JNIEnv *env, jclass, jint messageID, jobject data, jint periodMs) { +#ifdef CONFIG_ATHENA CANJNI_LOG(logDEBUG) << "Calling CANJNI FRCNetCommCANSessionMuxSendMessage"; @@ -69,6 +72,9 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxSendMessage( CANJNI_LOG(logDEBUG) << "Status: " << status; CheckCANStatus(env, status, messageID); +#else + // TODO: Make this throw +#endif } static uint8_t buffer[8]; @@ -82,6 +88,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage( JNIEnv *env, jclass, jobject messageID, jint messageIDMask, jobject timeStamp) { +#ifdef CONFIG_ATHENA CANJNI_LOG(logDEBUG) << "Calling CANJNI FRCNetCommCANSessionMuxReceiveMessage"; @@ -118,6 +125,10 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage( if (!CheckCANStatus(env, status, *messageIDPtr)) return nullptr; return env->NewDirectByteBuffer(buffer, dataSize); +#else + // TODO: Make throw + return nullptr; +#endif } } // extern "C" diff --git a/wpilibj/src/athena/cpp/lib/HALUtil.cpp b/wpilibj/src/athena/cpp/lib/HALUtil.cpp index 3f89c72bf3..6aac1c797c 100644 --- a/wpilibj/src/athena/cpp/lib/HALUtil.cpp +++ b/wpilibj/src/athena/cpp/lib/HALUtil.cpp @@ -15,7 +15,9 @@ #include #include +#ifdef CONFIG_ATHENA #include "FRC_NetworkCommunication/CANSessionMux.h" +#endif #include "HAL/HAL.h" #include "HAL/DriverStation.h" #include "HAL/Errors.h" @@ -78,7 +80,11 @@ void ThrowHalHandleException(JNIEnv *env, int32_t status) { halHandleExCls.Throw(env, buf.c_str()); } -constexpr const char wpilibjPrefix[] = "edu.wpi.first.wpilibj"; +#ifndef _WIN32 +constexpr const char JNI_wpilibjPrefix[] = "edu.wpi.first.wpilibj"; +#else +extern const char JNI_wpilibjPrefix[] = "edu.wpi.first.wpilibj"; +#endif void ReportError(JNIEnv *env, int32_t status, bool do_throw) { if (status == 0) return; @@ -93,7 +99,7 @@ void ReportError(JNIEnv *env, int32_t status, bool do_throw) { runtimeExCls.Throw(env, buf.c_str()); } else { std::string func; - auto stack = GetJavaStackTrace(env, &func); + auto stack = GetJavaStackTrace(env, &func); HAL_SendError(1, status, 0, message, func.c_str(), stack.c_str(), 1); } } @@ -122,7 +128,9 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { case kRioStatusSuccess: // Everything is ok... don't throw. break; +#ifdef CONFIG_ATHENA case ERR_CANSessionMux_InvalidBuffer: +#endif case kRIOStatusBufferInvalidSize: { static jmethodID invalidBufConstruct = nullptr; if (!invalidBufConstruct) @@ -133,7 +141,9 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { env->Throw(static_cast(exception)); break; } +#ifdef CONFIG_ATHENA case ERR_CANSessionMux_MessageNotFound: +#endif case kRIOStatusOperationTimedOut: { static jmethodID messageNotFoundConstruct = nullptr; if (!messageNotFoundConstruct) @@ -144,7 +154,9 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { env->Throw(static_cast(exception)); break; } +#ifdef CONFIG_ATHENA case ERR_CANSessionMux_NotAllowed: +#endif case kRIOStatusFeatureNotSupported: { llvm::SmallString<100> buf; llvm::raw_svector_ostream oss(buf); @@ -152,7 +164,9 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { canMessageNotAllowedExCls.Throw(env, buf.c_str()); break; } +#ifdef CONFIG_ATHENA case ERR_CANSessionMux_NotInitialized: +#endif case kRIOStatusResourceNotInitialized: { static jmethodID notInitConstruct = nullptr; if (!notInitConstruct) diff --git a/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp b/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp index 93443487ab..7f37b5382d 100644 --- a/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp @@ -164,7 +164,7 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrupts( * Method: waitForInterrupt * Signature: (JD)V */ -JNIEXPORT int32_t JNICALL +JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterrupt( JNIEnv* env, jclass, jint interruptHandle, jdouble timeout, jboolean ignorePrevious) {