[wpilib] Fix PowerDistribution.GetAllCurrents() (#6025)

This commit is contained in:
scarmain
2024-05-24 19:31:19 -04:00
committed by GitHub
parent f42bc45ee8
commit c62396ce4e
6 changed files with 104 additions and 7 deletions

View File

@@ -179,15 +179,18 @@ JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getAllCurrents
(JNIEnv* env, jclass, jint handle, jdoubleArray jarr)
{
double storage[16];
int32_t status = 0;
// TODO fix me
HAL_GetPowerDistributionAllChannelCurrents(handle, storage, 16, &status);
int32_t size = HAL_GetPowerDistributionNumChannels(handle, &status);
wpi::SmallVector<double, 24> storage;
storage.resize_for_overwrite(size);
HAL_GetPowerDistributionAllChannelCurrents(handle, storage.data(), size,
&status);
if (!CheckStatus(env, status, false)) {
return;
}
env->SetDoubleArrayRegion(jarr, 0, 16, storage);
env->SetDoubleArrayRegion(jarr, 0, size, storage.data());
}
/*