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:
Thad House
2019-09-28 15:38:58 -07:00
committed by Peter Johnson
parent 41efb8015d
commit 8858ec55c7
8 changed files with 22 additions and 201 deletions

View File

@@ -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, &timestamp,
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"