[wpilib, hal] Add support for getting faults and versions from power distribution (#3794)

This commit is contained in:
Thad House
2021-12-19 13:42:49 -08:00
committed by GitHub
parent 34b2d0dae1
commit 9778626f34
15 changed files with 743 additions and 165 deletions

View File

@@ -46,6 +46,7 @@ static JException canMessageNotFoundExCls;
static JException canMessageNotAllowedExCls;
static JException canNotInitializedExCls;
static JException uncleanStatusExCls;
static JClass powerDistributionVersionCls;
static JClass pwmConfigDataResultCls;
static JClass canStatusCls;
static JClass matchInfoDataCls;
@@ -56,6 +57,8 @@ static JClass baseStoreCls;
static JClass revPHVersionCls;
static const JClassInit classes[] = {
{"edu/wpi/first/hal/PowerDistributionVersion",
&powerDistributionVersionCls},
{"edu/wpi/first/hal/PWMConfigDataResult", &pwmConfigDataResultCls},
{"edu/wpi/first/hal/can/CANStatus", &canStatusCls},
{"edu/wpi/first/hal/MatchInfoData", &matchInfoDataCls},
@@ -333,6 +336,21 @@ jobject CreateDMABaseStore(JNIEnv* env, jint valueType, jint index) {
return env->NewObject(baseStoreCls, ctor, valueType, index);
}
jobject CreatePowerDistributionVersion(JNIEnv* env, uint32_t firmwareMajor,
uint32_t firmwareMinor,
uint32_t firmwareFix,
uint32_t hardwareMinor,
uint32_t hardwareMajor,
uint32_t uniqueId) {
static jmethodID constructor =
env->GetMethodID(powerDistributionVersionCls, "<init>", "(IIIIII)V");
return env->NewObject(
powerDistributionVersionCls, constructor,
static_cast<jint>(firmwareMajor), static_cast<jint>(firmwareMinor),
static_cast<jint>(firmwareFix), static_cast<jint>(hardwareMinor),
static_cast<jint>(hardwareMajor), static_cast<jint>(uniqueId));
}
JavaVM* GetJVM() {
return jvm;
}