mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Always initialize status to 0 when calling HAL from JNI.
The HAL functions often call NI functions that may expect status to be initialized on entry. Java does not guarantee direct pointer allocation memory to be initialized, although that may have been occurring by accident. Change-Id: I5e3a553f3a7be8de3716ccfc13e6ca1cb4f2a552
This commit is contained in:
@@ -25,6 +25,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitialize";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
*statusPtr = 0;
|
||||
spiInitialize(port, statusPtr);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
@@ -149,6 +150,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectAct
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveHigh";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
*statusPtr = 0;
|
||||
spiSetChipSelectActiveHigh(port, statusPtr);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
@@ -164,6 +166,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectAct
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveLow";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
*statusPtr = 0;
|
||||
spiSetChipSelectActiveLow(port, statusPtr);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user