mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal] Add no throw/error version of CAN Write methods (#2063)
This commit is contained in:
@@ -107,6 +107,59 @@ Java_edu_wpi_first_hal_CANAPIJNI_writeCANRTRFrame
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_CANAPIJNI
|
||||
* Method: writeCANPacketNoThrow
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_CANAPIJNI_writeCANPacketNoThrow
|
||||
(JNIEnv* env, jclass, jint handle, jbyteArray data, jint apiId)
|
||||
{
|
||||
auto halHandle = static_cast<HAL_CANHandle>(handle);
|
||||
JByteArrayRef arr{env, data};
|
||||
auto arrRef = arr.array();
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANPacket(halHandle, reinterpret_cast<const uint8_t*>(arrRef.data()),
|
||||
arrRef.size(), apiId, &status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_CANAPIJNI
|
||||
* Method: writeCANPacketRepeatingNoThrow
|
||||
* Signature: (I[BII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_CANAPIJNI_writeCANPacketRepeatingNoThrow
|
||||
(JNIEnv* env, jclass, jint handle, jbyteArray data, jint apiId,
|
||||
jint timeoutMs)
|
||||
{
|
||||
auto halHandle = static_cast<HAL_CANHandle>(handle);
|
||||
JByteArrayRef arr{env, data};
|
||||
auto arrRef = arr.array();
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANPacketRepeating(halHandle,
|
||||
reinterpret_cast<const uint8_t*>(arrRef.data()),
|
||||
arrRef.size(), apiId, timeoutMs, &status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_CANAPIJNI
|
||||
* Method: writeCANRTRFrameNoThrow
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_CANAPIJNI_writeCANRTRFrameNoThrow
|
||||
(JNIEnv* env, jclass, jint handle, jint length, jint apiId)
|
||||
{
|
||||
auto halHandle = static_cast<HAL_CANHandle>(handle);
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANRTRFrame(halHandle, static_cast<int32_t>(length), apiId, &status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_CANAPIJNI
|
||||
* Method: stopCANPacketRepeating
|
||||
|
||||
Reference in New Issue
Block a user