mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Remove periodic can read call (#1868)
It is not necessary anymore, and is a complicated and confusing API to keep around.
This commit is contained in:
committed by
Peter Johnson
parent
41efb8015d
commit
8858ec55c7
@@ -203,38 +203,4 @@ Java_edu_wpi_first_hal_CANAPIJNI_readCANPacketTimeout
|
||||
reinterpret_cast<jbyte*>(dataTemp));
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_CANAPIJNI
|
||||
* Method: readCANPeriodicPacket
|
||||
* Signature: (IIIILjava/lang/Object;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_CANAPIJNI_readCANPeriodicPacket
|
||||
(JNIEnv* env, jclass, jint handle, jint apiId, jint timeoutMs, jint periodMs,
|
||||
jobject data)
|
||||
{
|
||||
auto halHandle = static_cast<HAL_CANHandle>(handle);
|
||||
uint8_t dataTemp[8];
|
||||
int32_t dataLength = 0;
|
||||
uint64_t timestamp = 0;
|
||||
int32_t status = 0;
|
||||
HAL_ReadCANPeriodicPacket(halHandle, apiId, dataTemp, &dataLength, ×tamp,
|
||||
timeoutMs, periodMs, &status);
|
||||
if (status == HAL_CAN_TIMEOUT ||
|
||||
status == HAL_ERR_CANSessionMux_MessageNotFound) {
|
||||
return false;
|
||||
}
|
||||
if (!CheckStatus(env, status)) {
|
||||
return false;
|
||||
}
|
||||
if (dataLength > 8) dataLength = 8;
|
||||
|
||||
jbyteArray toSetArray = SetCANDataObject(env, data, dataLength, timestamp);
|
||||
auto javaLen = env->GetArrayLength(toSetArray);
|
||||
if (javaLen < dataLength) dataLength = javaLen;
|
||||
env->SetByteArrayRegion(toSetArray, 0, dataLength,
|
||||
reinterpret_cast<jbyte*>(dataTemp));
|
||||
return true;
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user