From 049be6870c32523a6511614bec2b9b26bc697daf Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 29 Sep 2015 23:45:55 -0700 Subject: [PATCH] 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 --- wpilibj/wpilibJavaJNI/lib/AnalogJNI.cpp | 34 +++++++++++++++++++ wpilibj/wpilibJavaJNI/lib/CANJNI.cpp | 2 ++ wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp | 12 +++++++ wpilibj/wpilibJavaJNI/lib/CounterJNI.cpp | 23 +++++++++++++ wpilibj/wpilibJavaJNI/lib/DIOJNI.cpp | 10 ++++++ wpilibj/wpilibJavaJNI/lib/EncoderJNI.cpp | 12 +++++++ .../lib/FRCNetworkCommunicationsLibrary.cpp | 2 ++ wpilibj/wpilibJavaJNI/lib/HALUtil.cpp | 4 +++ wpilibj/wpilibJavaJNI/lib/I2CJNI.cpp | 1 + wpilibj/wpilibJavaJNI/lib/InterruptJNI.cpp | 11 ++++++ wpilibj/wpilibJavaJNI/lib/NotifierJNI.cpp | 4 +++ wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp | 10 +++++- wpilibj/wpilibJavaJNI/lib/PWMJNI.cpp | 11 ++++++ wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp | 14 ++++++++ wpilibj/wpilibJavaJNI/lib/RelayJNI.cpp | 4 +++ wpilibj/wpilibJavaJNI/lib/SPIJNI.cpp | 3 ++ wpilibj/wpilibJavaJNI/lib/SerialPortJNI.cpp | 18 ++++++++++ wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp | 7 ++++ 18 files changed, 181 insertions(+), 1 deletion(-) diff --git a/wpilibj/wpilibJavaJNI/lib/AnalogJNI.cpp b/wpilibj/wpilibJavaJNI/lib/AnalogJNI.cpp index fbb37d4b23..44da9d76d7 100644 --- a/wpilibj/wpilibJavaJNI/lib/AnalogJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/AnalogJNI.cpp @@ -26,6 +26,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAna jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** analogPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *analogPtr = initializeAnalogInputPort(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *analogPtr; @@ -45,6 +46,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAna jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** analogPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *analogPtr = initializeAnalogOutputPort(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *analogPtr; @@ -103,6 +105,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOutput { void ** javaId = (void**)env->GetDirectBufferAddress(id); jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setAnalogOutput(*javaId, voltage, statusPtr); } @@ -116,6 +119,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOutp { void ** javaId = (void**)env->GetDirectBufferAddress(id); jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getAnalogOutput(*javaId, statusPtr); } @@ -129,6 +133,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogSampleR { ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setAnalogSampleRate( value, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -142,6 +147,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogSamp (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; double returnValue = getAnalogSampleRate( statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << returnValue; @@ -160,6 +166,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogAverage void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setAnalogAverageBits( *javaId, value, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -175,6 +182,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverage void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAnalogAverageBits( *javaId, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << returnValue; @@ -193,6 +201,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOversam void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setAnalogOversampleBits( *javaId, value, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -208,6 +217,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOversam void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAnalogOversampleBits( *javaId, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << returnValue; @@ -225,6 +235,7 @@ JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogValue void ** javaId = (void**)env->GetDirectBufferAddress(id); //ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jshort returnValue = getAnalogValue( *javaId, statusPtr ); //ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; //ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue; @@ -242,6 +253,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverage void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAnalogAverageValue( *javaId, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AverageValue = " << returnValue; @@ -260,6 +272,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltsTo ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; ANALOGJNI_LOG(logDEBUG) << "VoltageValue = " << voltageValue; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAnalogVoltsToValue( *javaId, voltageValue, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue; @@ -277,6 +290,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVolt void ** javaId = (void**)env->GetDirectBufferAddress(id); //ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jdouble returnValue = getAnalogVoltage( *javaId, statusPtr ); //ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; //ANALOGJNI_LOG(logDEBUG) << "Voltage = " << returnValue; @@ -294,6 +308,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAver void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jdouble returnValue = getAnalogAverageVoltage( *javaId, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AverageVoltage = " << returnValue; @@ -311,6 +326,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogLSBWeig void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAnalogLSBWeight(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -329,6 +345,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOffset void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAnalogOffset(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -348,6 +365,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_isAccumulatorCh void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; // isAccumulaotrChanel returns a boolean char vOut = isAccumulatorChannel(*javaId, statusPtr) ? 1 : 0; @@ -370,6 +388,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initAccumulator ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; initAccumulator(*javaId, statusPtr); @@ -388,6 +407,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_resetAccumulator void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; resetAccumulator(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -404,6 +424,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorCe void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setAccumulatorCenter(*javaId, center, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -421,6 +442,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorDe void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setAccumulatorDeadband(*javaId, deadband, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -437,6 +459,7 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorV void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jlong returnValue = getAccumulatorValue(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -456,6 +479,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorCo void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getAccumulatorCount(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -474,6 +498,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorOu void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jlong * valuePtr = (jlong*)env->GetDirectBufferAddress(value); uint32_t * countPtr = (uint32_t*)env->GetDirectBufferAddress(count); @@ -503,6 +528,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAna ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void ** analogTriggerPtr = new void *; + *statusPtr = 0; *analogTriggerPtr = initializeAnalogTrigger(*javaId, (uint32_t *)indexPtr, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AnalogTrigger Ptr = " << *analogTriggerPtr; @@ -524,6 +550,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_cleanAnalogTrigg jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; cleanAnalogTrigger( *javaId, statusPtr ); delete javaId; @@ -543,6 +570,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setAnalogTriggerLimitsRaw( *javaId, lower, upper, statusPtr ); } @@ -560,6 +588,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setAnalogTriggerLimitsVoltage( *javaId, lower, upper, statusPtr ); } @@ -576,6 +605,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setAnalogTriggerAveraged( *javaId, averaged, statusPtr ); } @@ -592,6 +622,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setAnalogTriggerFiltered( *javaId, filtered, statusPtr ); } @@ -609,6 +640,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTrigge jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; return getAnalogTriggerInWindow( *javaId, statusPtr ); } @@ -626,6 +658,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTrigge jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; return getAnalogTriggerTriggerState( *javaId, statusPtr ); } @@ -643,5 +676,6 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTrigge jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; return getAnalogTriggerOutput( *javaId, (AnalogTriggerType)type, statusPtr )? 1 : 0; } diff --git a/wpilibj/wpilibJavaJNI/lib/CANJNI.cpp b/wpilibj/wpilibJavaJNI/lib/CANJNI.cpp index a5acc89155..51458cb84d 100644 --- a/wpilibj/wpilibJavaJNI/lib/CANJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/CANJNI.cpp @@ -52,6 +52,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunica CANJNI_LOG(logDEBUG) << "Period: " << periodMs; + *statusPtr = 0; FRC_NetworkCommunication_CANSessionMux_sendMessage(messageID, dataBuffer, dataSize, periodMs, statusPtr); CANJNI_LOG(logDEBUG) << "Status: " << *statusPtr; @@ -75,6 +76,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommun uint8_t dataSize = 0; + *statusPtr = 0; FRC_NetworkCommunication_CANSessionMux_receiveMessage(messageIDPtr, messageIDMask, buffer, &dataSize, timeStampPtr, statusPtr); CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << *messageIDPtr; diff --git a/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp b/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp index c670cabe27..bcafdfbc3d 100644 --- a/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp @@ -41,6 +41,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressor(*pcm_pointer, status_pointer); } @@ -55,6 +56,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoo VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; setClosedLoopControl(*pcm_pointer, value, status_pointer); } @@ -69,6 +71,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClose VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getClosedLoopControl(*pcm_pointer, status_pointer); } @@ -83,6 +86,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPress VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getPressureSwitch(*pcm_pointer, status_pointer); } @@ -97,6 +101,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompres VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorCurrent(*pcm_pointer, status_pointer); } @@ -111,6 +116,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorCurrentTooHighFault(*pcm_pointer, status_pointer); } @@ -125,6 +131,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorCurrentTooHighStickyFault(*pcm_pointer, status_pointer); } @@ -139,6 +146,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorShortedStickyFault(*pcm_pointer, status_pointer); } @@ -153,6 +161,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorShortedFault(*pcm_pointer, status_pointer); } @@ -167,6 +176,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorNotConnectedStickyFault(*pcm_pointer, status_pointer); } @@ -181,6 +191,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getCompressorNotConnectedFault(*pcm_pointer, status_pointer); } /* @@ -194,5 +205,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMS VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; clearAllPCMStickyFaults(*pcm_pointer, status_pointer); } diff --git a/wpilibj/wpilibJavaJNI/lib/CounterJNI.cpp b/wpilibj/wpilibJavaJNI/lib/CounterJNI.cpp index fe4e00955c..e29c6af5b1 100644 --- a/wpilibj/wpilibJavaJNI/lib/CounterJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/CounterJNI.cpp @@ -28,6 +28,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_initializeCo jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** counterPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *counterPtr = initializeCounter((Mode)mode, (uint32_t*)indexPtr, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Index = " << *indexPtr; COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -48,6 +49,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_freeCounter COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; freeCounter(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -66,6 +68,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterAvera COUNTERJNI_LOG(logDEBUG) << "AverageSize = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterAverageSize(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -85,6 +88,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSou COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterUpSource(*javaId, pin, analogTrigger, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -104,6 +108,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSou COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterUpSourceEdge(*javaId, valueRise, valueFall, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -121,6 +126,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterUpS COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; clearCounterUpSource(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -140,6 +146,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownS COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterDownSource(*javaId, pin, analogTrigger, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -159,6 +166,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownS COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterDownSourceEdge(*javaId, valueRise, valueFall, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -176,6 +184,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterDow COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; clearCounterDownSource(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -193,6 +202,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpDow COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterUpDownMode(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -210,6 +220,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterExter COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterExternalDirectionMode(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -228,6 +239,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSemiP COUNTERJNI_LOG(logDEBUG) << "SemiPeriodMode = " << (jint)value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterSemiPeriodMode(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -246,6 +258,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterPulse COUNTERJNI_LOG(logDEBUG) << "PulseLengthMode = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterPulseLengthMode(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -263,6 +276,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterSampl COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jint returnValue = getCounterSamplesToAverage(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; COUNTERJNI_LOG(logDEBUG) << "getCounterSamplesToAverageResult = " << returnValue; @@ -283,6 +297,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSampl COUNTERJNI_LOG(logDEBUG) << "SamplesToAverage = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterSamplesToAverage(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -300,6 +315,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_resetCounter COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; resetCounter(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -317,6 +333,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounter //COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jint returnValue = getCounter(*javaId, statusPtr); //COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; //COUNTERJNI_LOG(logDEBUG) << "getCounterResult = " << returnValue; @@ -336,6 +353,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterPe COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jdouble returnValue = getCounterPeriod(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; COUNTERJNI_LOG(logDEBUG) << "getCounterPeriodResult = " << returnValue; @@ -356,6 +374,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterMaxPe COUNTERJNI_LOG(logDEBUG) << "MaxPeriod = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterMaxPeriod(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -374,6 +393,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpdat COUNTERJNI_LOG(logDEBUG) << "UpdateWhenEmpty = " << (jint)value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterUpdateWhenEmpty(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -391,6 +411,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterStop COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getCounterStopped(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; COUNTERJNI_LOG(logDEBUG) << "getCounterStoppedResult = " << (jint)returnValue; @@ -410,6 +431,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterDire COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getCounterDirection(*javaId, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; COUNTERJNI_LOG(logDEBUG) << "getCounterDirectionResult = " << (jint)returnValue; @@ -430,6 +452,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterRever COUNTERJNI_LOG(logDEBUG) << "ReverseDirection = " << (jint)value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setCounterReverseDirection(*javaId, value, statusPtr); COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } diff --git a/wpilibj/wpilibJavaJNI/lib/DIOJNI.cpp b/wpilibj/wpilibJavaJNI/lib/DIOJNI.cpp index f77deb87ba..e30dabb70e 100644 --- a/wpilibj/wpilibJavaJNI/lib/DIOJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/DIOJNI.cpp @@ -27,6 +27,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_initializeDigita jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** dioPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *dioPtr = initializeDigitalPort(*javaId, statusPtr); DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; DIOJNI_LOG(logDEBUG) << "DIO Ptr = " << *dioPtr; @@ -46,6 +47,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = allocateDIO(*javaId, value, statusPtr); DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue; @@ -65,6 +67,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDIO DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; freeDIO(*javaId, statusPtr); DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -83,6 +86,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO //DIOJNI_LOG(logDEBUG) << "Value = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setDIO(*javaId, value, statusPtr); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -100,6 +104,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getDIO(*javaId, statusPtr); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; //DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue; @@ -120,6 +125,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIODirection //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getDIODirection(*javaId, statusPtr); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; DIOJNI_LOG(logDEBUG) << "getDIODirectionResult = " << (jbyte)returnValue; @@ -140,6 +146,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_pulse //DIOJNI_LOG(logDEBUG) << "Value = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; pulse(*javaId, value, statusPtr); DIOJNI_LOG(logDEBUG) << "Did it work? Status = " << *statusPtr; } @@ -157,6 +164,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isPulsing //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = isPulsing(*javaId, statusPtr); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; DIOJNI_LOG(logDEBUG) << "isPulsingResult = " << (jbyte)returnValue; @@ -175,6 +183,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsing { DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isAnyPulsing (RR upd)"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jbyte returnValue = isAnyPulsing( statusPtr ); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; DIOJNI_LOG(logDEBUG) << "isAnyPulsingResult = " << (jbyte)returnValue; @@ -191,6 +200,7 @@ JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming { DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jshort returnValue = getLoopTiming( statusPtr ); DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue; diff --git a/wpilibj/wpilibJavaJNI/lib/EncoderJNI.cpp b/wpilibj/wpilibJavaJNI/lib/EncoderJNI.cpp index 7b5269cec9..216cd7b7a1 100644 --- a/wpilibj/wpilibJavaJNI/lib/EncoderJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/EncoderJNI.cpp @@ -34,6 +34,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEn jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** encoderPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *encoderPtr = initializeEncoder(port_a_module, port_a_pin, port_a_analog_trigger, port_b_module, port_b_pin, port_b_analog_trigger, reverseDirection, indexPtr, statusPtr); @@ -57,6 +58,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; freeEncoder(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -74,6 +76,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_resetEncoder ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; resetEncoder(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -91,6 +94,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jint returnValue = getEncoder(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderResult = " << returnValue; @@ -110,6 +114,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderPe ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; double returnValue = getEncoderPeriod(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderPeriodResult = " << returnValue; @@ -129,6 +134,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPe ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setEncoderMaxPeriod(*javaId, value, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -146,6 +152,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderStop ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getEncoderStopped(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderStoppedResult = " << returnValue; @@ -165,6 +172,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderDire ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getEncoderDirection(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderDirectionResult = " << returnValue; @@ -184,6 +192,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderRever ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setEncoderReverseDirection(*javaId, value, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -201,6 +210,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderSampl ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setEncoderSamplesToAverage(*javaId, value, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -218,6 +228,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSampl ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jint returnValue = getEncoderSamplesToAverage(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = " << returnValue; @@ -241,6 +252,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderIndex ENCODERJNI_LOG(logDEBUG) << "Active High = " << (activeHigh?"true":"false"); ENCODERJNI_LOG(logDEBUG) << "Edge Sensitive = " << (edgeSensitive?"true":"false"); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setEncoderIndexSource(*javaId, pin, analogTrigger, activeHigh, edgeSensitive, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } diff --git a/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp b/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp index 7f0024db5b..58e4f8c648 100644 --- a/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp +++ b/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp @@ -615,6 +615,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCo (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return HALGetSystemActive((int32_t*)statusPtr); } @@ -627,6 +628,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCo (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return HALGetBrownedOut((int32_t*)statusPtr); } diff --git a/wpilibj/wpilibJavaJNI/lib/HALUtil.cpp b/wpilibj/wpilibJavaJNI/lib/HALUtil.cpp index c6e19db0e9..da847726ef 100644 --- a/wpilibj/wpilibJavaJNI/lib/HALUtil.cpp +++ b/wpilibj/wpilibJavaJNI/lib/HALUtil.cpp @@ -123,6 +123,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGAVersion"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jshort returnValue = getFPGAVersion( statusPtr ); HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr; HALUTIL_LOG(logDEBUG) << "FPGAVersion = " << returnValue; @@ -139,6 +140,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGARevision"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint returnValue = getFPGARevision( statusPtr ); HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr; HALUTIL_LOG(logDEBUG) << "FPGARevision = " << returnValue; @@ -155,6 +157,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { //HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jlong returnValue = getFPGATime( statusPtr ); //HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr; //HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue; @@ -172,6 +175,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { //HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jboolean returnValue = getFPGAButton( statusPtr ); //HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr; //HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue; diff --git a/wpilibj/wpilibJavaJNI/lib/I2CJNI.cpp b/wpilibj/wpilibJavaJNI/lib/I2CJNI.cpp index c15fa2736d..8f7e5d566e 100644 --- a/wpilibj/wpilibJavaJNI/lib/I2CJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/I2CJNI.cpp @@ -24,6 +24,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CInititalize"; I2CJNI_LOG(logDEBUG) << "Port: " << (jint) value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; i2CInitialize(value, statusPtr); I2CJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } diff --git a/wpilibj/wpilibJavaJNI/lib/InterruptJNI.cpp b/wpilibj/wpilibJavaJNI/lib/InterruptJNI.cpp index 24786af3ea..1138f4de82 100644 --- a/wpilibj/wpilibJavaJNI/lib/InterruptJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/InterruptJNI.cpp @@ -26,6 +26,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeInt INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI initializeInterruptJVM"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jint rs = env->GetJavaVM(&jvm); assert (rs == JNI_OK); } @@ -46,6 +47,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initialize INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** interruptPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *interruptPtr = (void**) initializeInterrupts(interruptIndex, watcher, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << *interruptPtr; @@ -69,6 +71,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrup jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; cleanInterrupts(*javaId, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -88,6 +91,7 @@ JNIEXPORT int JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterru jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; int result = waitForInterrupt(*javaId, timeout, ignorePrevious, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -109,6 +113,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterru jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; enableInterrupts(*javaId, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -128,6 +133,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterr jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; disableInterrupts(*javaId, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -147,6 +153,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRising jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jdouble timeStamp = readRisingTimestamp(*javaId, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -167,6 +174,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallin jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jdouble timeStamp = readFallingTimestamp(*javaId, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -190,6 +198,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterr jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; requestInterrupts(*javaId, (uint8_t) routing_module, (uint32_t) routing_pin, routing_analog_trigger, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -292,6 +301,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterru INTERRUPTJNI_LOG(logDEBUG) << "InterruptHandlerParam->mid = " << interruptHandlerParam->mid; INTERRUPTJNI_LOG(logDEBUG) << "InterruptHandlerParam->param = " << interruptHandlerParam->param; + *statusPtr = 0; attachInterruptHandler(*javaId, interruptHandler, interruptHandlerParam, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -314,6 +324,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_setInterruptU jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); INTERRUPTJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setInterruptUpSourceEdge(*javaId, risingEdge, fallingEdge, statusPtr); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << *statusPtr; diff --git a/wpilibj/wpilibJavaJNI/lib/NotifierJNI.cpp b/wpilibj/wpilibJavaJNI/lib/NotifierJNI.cpp index 273d8fd2ab..6f4aebfc8a 100644 --- a/wpilibj/wpilibJavaJNI/lib/NotifierJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/NotifierJNI.cpp @@ -88,6 +88,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeNoti NOTIFIERJNI_LOG(logDEBUG) << "Calling NOTIFIERJNI initializeNotifierJVM"; jint * statusPtr = GetStatusPtr(env, status); NOTIFIERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jint rs = env->GetJavaVM(&jvm); assert (rs == JNI_OK); } @@ -119,6 +120,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeN func_global = env->NewGlobalRef(func); mid_global = mid; + *statusPtr = 0; void *notifierPtr = initializeNotifier(notifierHandler, statusPtr); NOTIFIERJNI_LOG(logDEBUG) << "Notifier Ptr = " << notifierPtr; @@ -142,6 +144,7 @@ JNIEXPORT void JNICALL jint *statusPtr = GetStatusPtr(env, status); NOTIFIERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; cleanNotifier(ptr, statusPtr); NOTIFIERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -164,6 +167,7 @@ JNIEXPORT void JNICALL NOTIFIERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; NOTIFIERJNI_LOG(logDEBUG) << "triggerTime Ptr = " << &triggerTime; + *statusPtr = 0; updateNotifierAlarm(ptr, (uint32_t)triggerTime, statusPtr); NOTIFIERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } diff --git a/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp b/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp index 47525aad45..9db72d1a69 100644 --- a/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp @@ -22,6 +22,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTemperatur { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; return getPDPTemperature(status_ptr, module); } @@ -35,6 +36,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPVoltage { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; return getPDPVoltage(status_ptr, module); } @@ -48,6 +50,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPChannelCur { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; return getPDPChannelCurrent(channel, status_ptr, module); } @@ -61,6 +64,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalCurre { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; return getPDPTotalCurrent(status_ptr, module); } @@ -74,6 +78,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalPower { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; return getPDPTotalPower(status_ptr, module); } @@ -87,6 +92,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalEnerg { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; return getPDPTotalEnergy(status_ptr, module); } @@ -101,6 +107,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_resetPDPTotalEnergy { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; resetPDPTotalEnergy(status_ptr, module); } @@ -114,5 +121,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_clearPDPStickyFault { jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + *status_ptr = 0; clearPDPStickyFaults(status_ptr, module); -} \ No newline at end of file +} diff --git a/wpilibj/wpilibJavaJNI/lib/PWMJNI.cpp b/wpilibj/wpilibJavaJNI/lib/PWMJNI.cpp index 2307155da8..b791ed4dfa 100644 --- a/wpilibj/wpilibJavaJNI/lib/PWMJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/PWMJNI.cpp @@ -27,6 +27,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWMChan PWMJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = allocatePWMChannel(*javaId, statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; PWMJNI_LOG(logDEBUG) << "allocatePWMChannelResult = " << (jint)returnValue; @@ -46,6 +47,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWMChannel PWMJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; freePWMChannel(*javaId, statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -63,6 +65,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWM PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << *javaId; PWMJNI_LOG(logDEBUG) << "PWM Value = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setPWM( *javaId, value, statusPtr ); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -78,6 +81,7 @@ JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_getPWM void ** javaId = (void**)env->GetDirectBufferAddress(id); PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jshort returnValue = getPWM( *javaId, statusPtr ); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; PWMJNI_LOG(logDEBUG) << "Value = " << returnValue; @@ -95,6 +99,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_latchPWMZero void ** javaId = (void**)env->GetDirectBufferAddress(id); PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; latchPWMZero( *javaId, statusPtr ); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -111,6 +116,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMPeriodScale PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << *javaId; PWMJNI_LOG(logDEBUG) << "PeriodScale Value = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; setPWMPeriodScale( *javaId, value, statusPtr ); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -127,6 +133,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWM jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** pwmPtr = (void**)new unsigned char[4]; + *statusPtr = 0; *pwmPtr = allocatePWM(statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *pwmPtr; @@ -147,6 +154,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWM PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; freePWM(*javaId, statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -163,6 +171,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMRate PWMJNI_LOG(logDEBUG) << "Rate= " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setPWMRate(value, statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -181,6 +190,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMDutyCycle PWMJNI_LOG(logDEBUG) << "DutyCycle= " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setPWMDutyCycle(*javaId, value, statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -199,6 +209,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMOutputChannel PWMJNI_LOG(logDEBUG) << "Pin= " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setPWMOutputChannel(*javaId, (uint32_t) value, statusPtr); PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } diff --git a/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp b/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp index dedf6c92fb..90d4a5076d 100644 --- a/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp @@ -11,6 +11,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinVoltage (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getVinVoltage(statusPtr); } @@ -23,6 +24,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinCurrent (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getVinCurrent(statusPtr); } @@ -35,6 +37,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage6 (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserVoltage6V(statusPtr); } @@ -47,6 +50,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent6 (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserCurrent6V(statusPtr); } @@ -59,6 +63,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserActive6V(statusPtr); } @@ -71,6 +76,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFau (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserCurrentFaults6V(statusPtr); } @@ -83,6 +89,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage5 (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserVoltage5V(statusPtr); } @@ -95,6 +102,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent5 (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserCurrent5V(statusPtr); } @@ -107,6 +115,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserActive5V(statusPtr); } @@ -119,6 +128,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFau (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserCurrentFaults5V(statusPtr); } @@ -131,6 +141,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage3 (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserVoltage3V3(statusPtr); } @@ -143,6 +154,7 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent3 (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserCurrent3V3(statusPtr); } @@ -155,6 +167,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserActive3V3(statusPtr); } @@ -167,6 +180,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFau (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; return getUserCurrentFaults3V3(statusPtr); } diff --git a/wpilibj/wpilibJavaJNI/lib/RelayJNI.cpp b/wpilibj/wpilibJavaJNI/lib/RelayJNI.cpp index 61aceef5a3..f7f2e2044a 100644 --- a/wpilibj/wpilibJavaJNI/lib/RelayJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/RelayJNI.cpp @@ -27,6 +27,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayForward RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setRelayForward(*javaId, value, statusPtr); RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -45,6 +46,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayReverse RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; setRelayReverse(*javaId, value, statusPtr); RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -62,6 +64,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayForward RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getRelayForward(*javaId, statusPtr); RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr; RELAYJNI_LOG(logDEBUG) << "getRelayForwardResult = " << (jint)returnValue; @@ -81,6 +84,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayReverse RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; + *statusPtr = 0; jbyte returnValue = getRelayReverse(*javaId, statusPtr); RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr; RELAYJNI_LOG(logDEBUG) << "getRelayReverseResult = " << (jint)returnValue; diff --git a/wpilibj/wpilibJavaJNI/lib/SPIJNI.cpp b/wpilibj/wpilibJavaJNI/lib/SPIJNI.cpp index bb76367199..099967c135 100644 --- a/wpilibj/wpilibJavaJNI/lib/SPIJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/SPIJNI.cpp @@ -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; } diff --git a/wpilibj/wpilibJavaJNI/lib/SerialPortJNI.cpp b/wpilibj/wpilibJavaJNI/lib/SerialPortJNI.cpp index 3b52cbb68c..ef8da030b7 100644 --- a/wpilibj/wpilibJavaJNI/lib/SerialPortJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/SerialPortJNI.cpp @@ -24,6 +24,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialInitia SERIALJNI_LOG(logDEBUG) << "Calling Serial Initialize"; SERIALJNI_LOG(logDEBUG) << "Port = " << (jint) port; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialInitializePort(port, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -39,6 +40,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetBau SERIALJNI_LOG(logDEBUG) << "Setting Serial Baud Rate"; SERIALJNI_LOG(logDEBUG) << "Baud: " << rate; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetBaudRate(port, rate, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -54,6 +56,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetDat SERIALJNI_LOG(logDEBUG) << "Setting Serial Data Bits"; SERIALJNI_LOG(logDEBUG) << "Data Bits: " << bits; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetDataBits(port, bits, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -69,6 +72,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetPar SERIALJNI_LOG(logDEBUG) << "Setting Serial Parity"; SERIALJNI_LOG(logDEBUG) << "Parity: " << parity; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetParity(port, parity, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -84,6 +88,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetSto SERIALJNI_LOG(logDEBUG) << "Setting Serial Stop Bits"; SERIALJNI_LOG(logDEBUG) << "Stop Bits: " << bits; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetStopBits(port, bits, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -99,6 +104,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWri SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Mode"; SERIALJNI_LOG(logDEBUG) << "Write mode: " << mode; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetWriteMode(port, mode, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -114,6 +120,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetFlo SERIALJNI_LOG(logDEBUG) << "Setting Serial Flow Control"; SERIALJNI_LOG(logDEBUG) << "Flow Control: " << flow; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetFlowControl(port, flow, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -129,6 +136,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetTim SERIALJNI_LOG(logDEBUG) << "Setting Serial Timeout"; SERIALJNI_LOG(logDEBUG) << "Timeout: " << timeout; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetTimeout(port, timeout, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -144,6 +152,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialEnable SERIALJNI_LOG(logDEBUG) << "Setting Serial Enable Termination"; SERIALJNI_LOG(logDEBUG) << "Terminator: " << terminator; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialEnableTermination(port, terminator, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -158,6 +167,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialDisabl { SERIALJNI_LOG(logDEBUG) << "Setting Serial Disable termination"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialDisableTermination(port, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -173,6 +183,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetRea SERIALJNI_LOG(logDEBUG) << "Setting Serial Read Buffer Size"; SERIALJNI_LOG(logDEBUG) << "Size: " << size; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetReadBufferSize(port, size, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -188,6 +199,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWri SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Buffer Size"; SERIALJNI_LOG(logDEBUG) << "Size: " << size; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialSetWriteBufferSize(port, size, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -202,6 +214,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetByt { SERIALJNI_LOG(logDEBUG) << "Serial Get Bytes Received"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; jint retVal = serialGetBytesReceived(port, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; return retVal; @@ -219,6 +232,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); jbyte * dataReceivedPtr = NULL; dataReceivedPtr = (jbyte*)env->GetDirectBufferAddress(dataReceived); + *statusPtr = 0; jint retVal = serialRead(port, (char*)dataReceivedPtr, size, statusPtr); SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -239,6 +253,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialWrite if(dataToSend != 0){ dataToSendPtr = (jbyte*)env->GetDirectBufferAddress(dataToSend); } + *statusPtr = 0; jint retVal = serialWrite(port, (const char*)dataToSendPtr, size, statusPtr); SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; @@ -255,6 +270,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialFlush { SERIALJNI_LOG(logDEBUG) << "Serial Flush"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialFlush(port, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -269,6 +285,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClear { SERIALJNI_LOG(logDEBUG) << "Serial Clear"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialClear(port, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } @@ -283,6 +300,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClose { SERIALJNI_LOG(logDEBUG) << "Serial Close"; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); + *statusPtr = 0; serialClose(port, statusPtr); SERIALJNI_LOG(logDEBUG) << "Status = " << *statusPtr; } diff --git a/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp b/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp index 8712dbc0b5..3cf4883f73 100644 --- a/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp @@ -31,6 +31,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeS SOLENOIDJNI_LOG(logDEBUG) << "Status Ptr = " << status_pointer; VoidPointer *solenoid_port_pointer = new VoidPointer; + *status_pointer = 0; *solenoid_port_pointer = initializeSolenoidPort(*port_pointer_pointer, status_pointer); SOLENOIDJNI_LOG(logDEBUG) << "Status = " << *status_pointer; @@ -72,6 +73,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_setSolenoid jint *status_pointer = (jint*)env->GetDirectBufferAddress(status); SOLENOIDJNI_LOG(logDEBUG) << "Status Ptr = " << status_pointer; + *status_pointer = 0; setSolenoid(*solenoid_port_pointer, value, status_pointer); } @@ -87,6 +89,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); jint *status_pointer = (jint*)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getSolenoid(*solenoid_port_pointer, status_pointer); } @@ -102,6 +105,7 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoi VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); jint *status_pointer = (jint*)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getPCMSolenoidBlackList(*solenoid_port_pointer, status_pointer); } /* @@ -115,6 +119,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSole VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getPCMSolenoidVoltageStickyFault(*solenoid_port_pointer, status_pointer); } /* @@ -128,6 +133,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSole VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; return getPCMSolenoidVoltageFault(*solenoid_port_pointer, status_pointer); } /* @@ -141,5 +147,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMSti VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + *status_pointer = 0; clearAllPCMStickyFaults_sol(*solenoid_port_pointer, status_pointer); }