mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
JNI implementation for Java
Normal vs
This commit is contained in:
484
wpilibj/wpilibJavaJNI/src/main/native/AnalogJNI.cpp
Normal file
484
wpilibj/wpilibJavaJNI/src/main/native/AnalogJNI.cpp
Normal file
@@ -0,0 +1,484 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_AnalogJNI.h"
|
||||
|
||||
#include "HAL/Analog.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel analogJNILogLevel = logDEBUG;
|
||||
|
||||
#define ANALOGJNI_LOG(level) \
|
||||
if (level > analogJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: initializeAnalogPort
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogPort
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
void** analogPtr = (void**)new unsigned char[4];
|
||||
*analogPtr = initializeAnalogPort(*javaId, statusPtr);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *analogPtr;
|
||||
return env->NewDirectByteBuffer( analogPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: checkAnalogModule
|
||||
* Signature: (B)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogModule
|
||||
(JNIEnv *, jclass, jbyte value)
|
||||
{
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Module = " << (jint)value;
|
||||
jbyte returnValue = checkAnalogModule( value );
|
||||
//ANALOGJNI_LOG(logDEBUG) << "checkAnalogModuleResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: checkAnalogChannel
|
||||
* Signature: (I)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogChannel
|
||||
(JNIEnv *, jclass, jint value)
|
||||
{
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Channel = " << value;
|
||||
jbyte returnValue = checkAnalogChannel( value );
|
||||
//ANALOGJNI_LOG(logDEBUG) << "checkAnalogChannelResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogSampleRate
|
||||
* Signature: (DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogSampleRate
|
||||
(JNIEnv * env, jclass, jdouble value, jobject status)
|
||||
{
|
||||
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setAnalogSampleRate( value, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogSampleRate
|
||||
* Signature: (Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogSampleRate
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
double returnValue = getAnalogSampleRate( statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogSampleRateWithModule
|
||||
* Signature: (BDLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogSampleRateWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jdouble value, jobject status)
|
||||
{
|
||||
ANALOGJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setAnalogSampleRateWithModule( module, value, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogSampleRateWithModule
|
||||
* Signature: (BLjava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogSampleRateWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jobject status)
|
||||
{
|
||||
ANALOGJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
double returnValue = getAnalogSampleRateWithModule( module, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogAverageBits
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogAverageBits
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status)
|
||||
{
|
||||
ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << value;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setAnalogAverageBits( *javaId, value, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogAverageBits
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageBits
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jint returnValue = getAnalogAverageBits( *javaId, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogOversampleBits
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOversampleBits
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status)
|
||||
{
|
||||
ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << value;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setAnalogOversampleBits( *javaId, value, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogOversampleBits
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOversampleBits
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jint returnValue = getAnalogOversampleBits( *javaId, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogValue
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogValue
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jshort returnValue = getAnalogValue( *javaId, statusPtr );
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogAverageValue
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageValue
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jint returnValue = getAnalogAverageValue( *javaId, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "AverageValue = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogVoltsToValue
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltsToValue
|
||||
(JNIEnv * env, jclass, jobject id, jdouble voltageValue, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
ANALOGJNI_LOG(logDEBUG) << "VoltageValue = " << voltageValue;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jint returnValue = getAnalogVoltsToValue( *javaId, voltageValue, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogVoltage
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltage
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jdouble returnValue = getAnalogVoltage( *javaId, statusPtr );
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
//ANALOGJNI_LOG(logDEBUG) << "Voltage = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogAverageVoltage
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageVoltage
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jdouble returnValue = getAnalogAverageVoltage( *javaId, statusPtr );
|
||||
ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ANALOGJNI_LOG(logDEBUG) << "AverageVoltage = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogLSBWeight
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogLSBWeight
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogOffset
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOffset
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: isAccumulatorChannel
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_isAccumulatorChannel
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: initAccumulator
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initAccumulator
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: resetAccumulator
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_resetAccumulator
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAccumulatorCenter
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorCenter
|
||||
(JNIEnv *, jclass, jobject, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAccumulatorDeadband
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorDeadband
|
||||
(JNIEnv *, jclass, jobject, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAccumulatorValue
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorValue
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAccumulatorCount
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorCount
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAccumulatorOutput
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/LongBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorOutput
|
||||
(JNIEnv *, jclass, jobject, jobject, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: initializeAnalogTrigger
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogTrigger
|
||||
(JNIEnv *, jclass, jobject, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: cleanAnalogTrigger
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_cleanAnalogTrigger
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogTriggerLimitsRaw
|
||||
* Signature: (Ljava/nio/ByteBuffer;IILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerLimitsRaw
|
||||
(JNIEnv *, jclass, jobject, jint, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogTriggerLimitsVoltage
|
||||
* Signature: (Ljava/nio/ByteBuffer;DDLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerLimitsVoltage
|
||||
(JNIEnv *, jclass, jobject, jdouble, jdouble, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogTriggerAveraged
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerAveraged
|
||||
(JNIEnv *, jclass, jobject, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: setAnalogTriggerFiltered
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerFiltered
|
||||
(JNIEnv *, jclass, jobject, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogTriggerInWindow
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerInWindow
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogTriggerTriggerState
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerTriggerState
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_AnalogJNI
|
||||
* Method: getAnalogTriggerOutput
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerOutput
|
||||
(JNIEnv *, jclass, jobject, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
99
wpilibj/wpilibJavaJNI/src/main/native/CANJNI.cpp
Normal file
99
wpilibj/wpilibJavaJNI/src/main/native/CANJNI.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_can_CANJNI.h"
|
||||
|
||||
#include "HAL/CAN.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel canJNILogLevel = logDEBUG;
|
||||
|
||||
#define CANJNI_LOG(level) \
|
||||
if (level > canJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_can_CANJNI
|
||||
* Method: FRCNetworkCommunicationJaguarCANDriverSendMessage
|
||||
* Signature: (I[BBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunicationJaguarCANDriverSendMessage
|
||||
(JNIEnv *env, jclass, jint messageID, jobject data, jobject status)
|
||||
{
|
||||
CANJNI_LOG(logDEBUG) << "Calling CANJNI JaguarCANDriverSendMessage";
|
||||
CANJNI_LOG(logDEBUG) << "MessageID = " << std::hex << messageID;
|
||||
jbyte * dataPtr = NULL;
|
||||
jlong dataCapacity = 0;
|
||||
|
||||
if(data != 0)
|
||||
{
|
||||
dataPtr = (jbyte*)env->GetDirectBufferAddress(data);
|
||||
dataCapacity = env->GetDirectBufferCapacity(data);
|
||||
}
|
||||
CANJNI_LOG(logDEBUG) << "MessageSize = " << dataCapacity;
|
||||
|
||||
if( logDEBUG <= canJNILogLevel )
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << std::setfill('0') << std::hex;
|
||||
for( int dataIndex = 0; dataIndex < dataCapacity; dataIndex++)
|
||||
{
|
||||
str << std::setw(2) << static_cast<unsigned int>(dataPtr[dataIndex]) << " ";
|
||||
}
|
||||
Log().Get(logDEBUG) << "MSG: " << str.str();
|
||||
}
|
||||
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
//CANJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
JaguarCANSendMessage((uint32_t) messageID, (const uint8_t*)dataPtr, (uint8_t)dataCapacity, statusPtr);
|
||||
CANJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_can_CANJNI
|
||||
* Method: FRCNetworkCommunicationJaguarCANDriverReceiveMessage
|
||||
* Signature: (Ljava/nio/IntBuffer;Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunicationJaguarCANDriverReceiveMessage
|
||||
(JNIEnv * env, jclass, jobject messageID, jint timeout, jobject status)
|
||||
{
|
||||
CANJNI_LOG(logDEBUG) << "Calling CANJNI JaguarCANDriverReceiveMessage";
|
||||
jint * messageIDPtr = (jint*)env->GetDirectBufferAddress(messageID);
|
||||
CANJNI_LOG(logDEBUG) << "MessageID In = " << std::hex << *messageIDPtr;
|
||||
CANJNI_LOG(logDEBUG) << "Timeout = " << timeout;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
//CANJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
uint8_t dataSize = 8;
|
||||
jbyte* dataPtr = new jbyte[8];
|
||||
//CANJNI_LOG(logDEBUG) << "Original MessageSize = " << (jint)dataSize;
|
||||
//CANJNI_LOG(logDEBUG) << "Original MessagePtr = " << (jint*)dataPtr;
|
||||
JaguarCANReceiveMessage((uint32_t*)messageIDPtr, (uint8_t*)dataPtr, &dataSize, timeout, statusPtr);
|
||||
|
||||
//CANJNI_LOG(logDEBUG) << "MessageID Out = " << std::hex << *messageIDPtr;
|
||||
CANJNI_LOG(logDEBUG) << "MessageSize = " << (jint)dataSize;
|
||||
CANJNI_LOG(logDEBUG) << "MessagePtr = " << (jint*)dataPtr;
|
||||
|
||||
if( logDEBUG <= canJNILogLevel )
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << std::setfill('0') << std::hex;
|
||||
for( int dataIndex = 0; dataIndex < dataSize; dataIndex++)
|
||||
{
|
||||
str << std::setw(2) << static_cast<unsigned int>(dataPtr[dataIndex]) << " ";
|
||||
}
|
||||
Log().Get(logDEBUG) << "MSG: " << str.str();
|
||||
}
|
||||
|
||||
CANJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
|
||||
if( dataSize > 0 )
|
||||
{
|
||||
return env->NewDirectByteBuffer( dataPtr, dataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
471
wpilibj/wpilibJavaJNI/src/main/native/CounterJNI.cpp
Normal file
471
wpilibj/wpilibJavaJNI/src/main/native/CounterJNI.cpp
Normal file
@@ -0,0 +1,471 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_CounterJNI.h"
|
||||
|
||||
#include "HAL/Digital.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel counterJNILogLevel = logDEBUG;
|
||||
|
||||
#define COUNTERJNI_LOG(level) \
|
||||
if (level > counterJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: initializeCounter
|
||||
* Signature: (ILjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_initializeCounter
|
||||
(JNIEnv * env, jclass, jint mode, jobject index, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI initializeCounter";
|
||||
COUNTERJNI_LOG(logDEBUG) << "Mode = " << mode;
|
||||
jint * indexPtr = (jint*)env->GetDirectBufferAddress(index);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
void** counterPtr = (void**)new unsigned char[4];
|
||||
*counterPtr = initializeCounter((Mode)mode, (uint32_t*)indexPtr, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Index = " << *indexPtr;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
COUNTERJNI_LOG(logDEBUG) << "COUNTER Ptr = " << *counterPtr;
|
||||
return env->NewDirectByteBuffer( counterPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: freeCounter
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_freeCounter
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI freeCounter";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
freeCounter(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterAverageSize
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterAverageSize
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterAverageSize";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "AverageSize = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterAverageSize(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterUpSourceWithModule
|
||||
* Signature: (Ljava/nio/ByteBuffer;BIBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSourceWithModule
|
||||
(JNIEnv * env, jclass, jobject id, jbyte module, jint pin, jbyte analogTrigger, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpSourceWithModule";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Pin = " << pin;
|
||||
COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterUpSourceWithModule(*javaId, module, pin, analogTrigger, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterUpSourceEdge
|
||||
* Signature: (Ljava/nio/ByteBuffer;BBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSourceEdge
|
||||
(JNIEnv * env, jclass, jobject id, jbyte valueRise, jbyte valueFall, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpSourceEdge";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Rise = " << (jint)valueRise;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterUpSourceEdge(*javaId, valueRise, valueFall, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: clearCounterUpSource
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterUpSource
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI clearCounterUpSource";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
clearCounterUpSource(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterDownSourceWithModule
|
||||
* Signature: (Ljava/nio/ByteBuffer;BIBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownSourceWithModule
|
||||
(JNIEnv * env, jclass, jobject id, jbyte module, jint pin, jbyte analogTrigger, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterDownSourceWithModule";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Pin = " << pin;
|
||||
COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterDownSourceWithModule(*javaId, module, pin, analogTrigger, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterDownSourceEdge
|
||||
* Signature: (Ljava/nio/ByteBuffer;BBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownSourceEdge
|
||||
(JNIEnv * env, jclass, jobject id, jbyte valueRise, jbyte valueFall, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterDownSourceEdge";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Rise = " << (jint)valueRise;
|
||||
COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterDownSourceEdge(*javaId, valueRise, valueFall, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: clearCounterDownSource
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterDownSource
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI clearCounterDownSource";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
clearCounterDownSource(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterUpDownMode
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpDownMode
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpDownMode";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterUpDownMode(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterExternalDirectionMode
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterExternalDirectionMode
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterExternalDirectionMode";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterExternalDirectionMode(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterSemiPeriodMode
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSemiPeriodMode
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterSemiPeriodMode";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "SemiPeriodMode = " << (jint)value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterSemiPeriodMode(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterPulseLengthMode
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterPulseLengthMode
|
||||
(JNIEnv * env, jclass, jobject id, jdouble value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterPulseLengthMode";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "PulseLengthMode = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterPulseLengthMode(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: getCounterSamplesToAverage
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterSamplesToAverage
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterSamplesToAverage";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jint returnValue = getCounterSamplesToAverage(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
COUNTERJNI_LOG(logDEBUG) << "getCounterSamplesToAverageResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterSamplesToAverage
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSamplesToAverage
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterSamplesToAverage";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "SamplesToAverage = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterSamplesToAverage(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: startCounter
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_startCounter
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI startCounter";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
startCounter(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: stopCounter
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_stopCounter
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI stopCounter";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
stopCounter(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: resetCounter
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_resetCounter
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI resetCounter";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
resetCounter(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: getCounter
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounter
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
//COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounter";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
//COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
//COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jint returnValue = getCounter(*javaId, statusPtr);
|
||||
//COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
//COUNTERJNI_LOG(logDEBUG) << "getCounterResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: getCounterPeriod
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterPeriod
|
||||
(JNIEnv *env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterPeriod";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jdouble returnValue = getCounterPeriod(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
COUNTERJNI_LOG(logDEBUG) << "getCounterPeriodResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterMaxPeriod
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterMaxPeriod
|
||||
(JNIEnv * env, jclass, jobject id, jdouble value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterMaxPeriod";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "MaxPeriod = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterMaxPeriod(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterUpdateWhenEmpty
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpdateWhenEmpty
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterMaxPeriod";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "UpdateWhenEmpty = " << (jint)value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterUpdateWhenEmpty(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: getCounterStopped
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterStopped
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterStopped";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getCounterStopped(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
COUNTERJNI_LOG(logDEBUG) << "getCounterStoppedResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: getCounterDirection
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterDirection
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterDirection";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getCounterDirection(*javaId, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
COUNTERJNI_LOG(logDEBUG) << "getCounterDirectionResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CounterJNI
|
||||
* Method: setCounterReverseDirection
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterReverseDirection
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterReverseDirection";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << *javaId;
|
||||
COUNTERJNI_LOG(logDEBUG) << "ReverseDirection = " << (jint)value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setCounterReverseDirection(*javaId, value, statusPtr);
|
||||
COUNTERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
212
wpilibj/wpilibJavaJNI/src/main/native/DIOJNI.cpp
Normal file
212
wpilibj/wpilibJavaJNI/src/main/native/DIOJNI.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_DIOJNI.h"
|
||||
|
||||
#include "HAL/Digital.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel dioJNILogLevel = logDEBUG;
|
||||
|
||||
#define DIOJNI_LOG(level) \
|
||||
if (level > dioJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: initializeDigitalPort
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_initializeDigitalPort
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI initializeDigitalPort";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
void** dioPtr = (void**)new unsigned char[4];
|
||||
*dioPtr = initializeDigitalPort(*javaId, statusPtr);
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
DIOJNI_LOG(logDEBUG) << "DIO Ptr = " << *dioPtr;
|
||||
return env->NewDirectByteBuffer( dioPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: allocateDIO
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI allocateDIO";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = allocateDIO(*javaId, value, statusPtr);
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: freeDIO
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDIO
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI freeDIO";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
freeDIO(*javaId, statusPtr);
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: setDIO
|
||||
* Signature: (Ljava/nio/ByteBuffer;SLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO
|
||||
(JNIEnv *env, jclass, jobject id, jshort value, jobject status)
|
||||
{
|
||||
//DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
//DIOJNI_LOG(logDEBUG) << "Value = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setDIO(*javaId, value, statusPtr);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getDIO
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
//DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIO";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getDIO(*javaId, statusPtr);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
//DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getDIODirection
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIODirection
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: checkDigitalModule
|
||||
* Signature: (B)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_checkDigitalModule
|
||||
(JNIEnv *, jclass, jbyte value)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI checkDigitalModule";
|
||||
DIOJNI_LOG(logDEBUG) << "Module = " << (jint)value;
|
||||
jbyte returnValue = checkDigitalModule( value );
|
||||
DIOJNI_LOG(logDEBUG) << "checkDigitalModuleResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: pulse
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_pulse
|
||||
(JNIEnv *, jclass, jobject, jdouble, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: isPulsing
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isPulsing
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: isAnyPulsing
|
||||
* Signature: (Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsing
|
||||
(JNIEnv *, jclass, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: isAnyPulsingWithModule
|
||||
* Signature: (BLjava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsingWithModule
|
||||
(JNIEnv *, jclass, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getLoopTiming
|
||||
* Signature: (Ljava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing";
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jshort returnValue = getLoopTiming( statusPtr );
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue;
|
||||
return returnValue;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getLoopTimingWithModule
|
||||
* Signature: (BLjava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTimingWithModule
|
||||
(JNIEnv *, jclass, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
259
wpilibj/wpilibJavaJNI/src/main/native/EncoderJNI.cpp
Normal file
259
wpilibj/wpilibJavaJNI/src/main/native/EncoderJNI.cpp
Normal file
@@ -0,0 +1,259 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_EncoderJNI.h"
|
||||
|
||||
#include "HAL/Digital.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel encoderJNILogLevel = logDEBUG;
|
||||
|
||||
#define ENCODERJNI_LOG(level) \
|
||||
if (level > encoderJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: initializeEncoder
|
||||
* Signature: (BIBBIBBLjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEncoder
|
||||
(JNIEnv * env, jclass, jbyte port_a_module, jint port_a_pin, jbyte port_a_analog_trigger, jbyte port_b_module, jint port_b_pin, jbyte port_b_analog_trigger, jbyte reverseDirection, jobject index, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI initializeEncoder";
|
||||
ENCODERJNI_LOG(logDEBUG) << "Module A = " << (jint)port_a_module;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Pin A = " << port_a_pin;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Analog Trigger A = " << (jint)port_a_analog_trigger;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Module B = " << (jint)port_b_module;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Pin B = " << port_b_pin;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Analog Trigger B = " << (jint)port_b_analog_trigger;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Reverse direction = " << (jint)reverseDirection;
|
||||
jint * indexPtr = (jint*)env->GetDirectBufferAddress(index);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
void** encoderPtr = (void**)new unsigned char[4];
|
||||
*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);
|
||||
|
||||
ENCODERJNI_LOG(logDEBUG) << "Index = " << *indexPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "ENCODER Ptr = " << *encoderPtr;
|
||||
return env->NewDirectByteBuffer( encoderPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: freeEncoder
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI freeEncoder";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
freeEncoder(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: startEncoder
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_startEncoder
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI startEncoder";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
startEncoder(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: stopEncoder
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_stopEncoder
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI stopEncoder";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
stopEncoder(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: resetEncoder
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_resetEncoder
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI resetEncoder";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
resetEncoder(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: getEncoder
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoder";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jint returnValue = getEncoder(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "getEncoderResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: getEncoderPeriod
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderPeriod
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderPeriod";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
double returnValue = getEncoderPeriod(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "getEncoderPeriodResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: setEncoderMaxPeriod
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPeriod
|
||||
(JNIEnv * env, jclass, jobject id, jdouble value, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderMaxPeriod";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setEncoderMaxPeriod(*javaId, value, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: getEncoderStopped
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderStopped
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderStopped";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getEncoderStopped(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "getEncoderStoppedResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: getEncoderDirection
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderDirection
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderDirection";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getEncoderDirection(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "getEncoderDirectionResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: setEncoderReverseDirection
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderReverseDirection
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderReverseDirection";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setEncoderReverseDirection(*javaId, value, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: setEncoderSamplesToAverage
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderSamplesToAverage
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderSamplesToAverage";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setEncoderSamplesToAverage(*javaId, value, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
|
||||
* Method: getEncoderSamplesToAverage
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSamplesToAverage
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderSamplesToAverage";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jint returnValue = getEncoderSamplesToAverage(*javaId, statusPtr);
|
||||
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
@@ -0,0 +1,706 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary.h"
|
||||
#include "HAL/HAL.h"
|
||||
//#include "NetworkCommunication/FRCComm.h"
|
||||
//#include "NetworkCommunication/UsageReporting.h"
|
||||
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_nAICalibration_getLSBWeight
|
||||
* Signature: (IILjava/lang/Integer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationAICalibrationGetLSBWeight
|
||||
(JNIEnv *, jclass, jint, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_nAICalibration_getOffset
|
||||
* Signature: (IILjava/lang/Integer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationAICalibrationGetOffset
|
||||
(JNIEnv *, jclass, jint, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getModulePresence
|
||||
* Signature: (IB)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getModulePresence
|
||||
(JNIEnv *, jclass, jint, jbyte)
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getTargetClass
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getTargetClass
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_nLoadOut_getModulePresence
|
||||
* Signature: (IB)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationLoadOutGetModulePresence
|
||||
(JNIEnv *, jclass, jint, jbyte)
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_nLoadOut_getTargetClass
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationLoadOutGetTargetClass
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: report
|
||||
* Signature: (IBBLjava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_report
|
||||
(JNIEnv *, jclass, jint, jbyte, jbyte, jstring)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_nUsageReporting_report
|
||||
* Signature: (BBBLjava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationUsageReportingReport
|
||||
(JNIEnv * paramEnv, jclass, jbyte paramResource, jbyte paramInstanceNumber, jbyte paramContext, jstring paramFeature)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Calling FRCNetworkCommunicationsLibrary report " << "res:"<< (unsigned int)paramResource << " instance:" << (unsigned int)paramInstanceNumber << " context:" << (unsigned int)paramContext << " feature:" << paramFeature;
|
||||
const char * featureStr = paramEnv->GetStringUTFChars(paramFeature, NULL);
|
||||
jint returnValue = HALReport(paramResource, paramInstanceNumber, paramContext, featureStr);
|
||||
paramEnv->ReleaseStringUTFChars(paramFeature,featureStr);
|
||||
return returnValue;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getFPGAHardwareVersion
|
||||
* Signature: (Ljava/nio/ShortBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getFPGAHardwareVersion
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
//
|
||||
// field ids
|
||||
//
|
||||
bool initializeComplete = false;
|
||||
jclass dataClass;
|
||||
jfieldID packetIndexFieldID;
|
||||
jfieldID controlFieldID;
|
||||
jfieldID dsDigitalInFieldID;
|
||||
jfieldID teamIDFieldID;
|
||||
jfieldID dsID_AllianceFieldID;
|
||||
jfieldID dsID_PositionFieldID;
|
||||
jfieldID stick0AxesFieldID;
|
||||
jfieldID stick0ButtonsFieldID;
|
||||
jfieldID stick1AxesFieldID;
|
||||
jfieldID stick1ButtonsFieldID;
|
||||
jfieldID stick2AxesFieldID;
|
||||
jfieldID stick2ButtonsFieldID;
|
||||
jfieldID stick3AxesFieldID;
|
||||
jfieldID stick3ButtonsFieldID;
|
||||
jfieldID analog1FieldID;
|
||||
jfieldID analog2FieldID;
|
||||
jfieldID analog3FieldID;
|
||||
jfieldID analog4FieldID;
|
||||
jfieldID cRIOChecksumFieldID;
|
||||
jfieldID FPGAChecksum0FieldID;
|
||||
jfieldID FPGAChecksum1FieldID;
|
||||
jfieldID FPGAChecksum2FieldID;
|
||||
jfieldID FPGAChecksum3FieldID;
|
||||
jfieldID versionDataFieldID;
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getCommonControlData
|
||||
* Signature: (Ledu/wpi/first/wpilibj/communication/FRCCommonControlData;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getCommonControlData
|
||||
(JNIEnv * env, jclass, jobject controlData)
|
||||
{
|
||||
HALCommonControlData controlDataNative;
|
||||
|
||||
controlDataNative.packetIndex = 0xFF;
|
||||
controlDataNative.control = 0xFF;
|
||||
|
||||
int returnValue = HALGetCommonControlData(&controlDataNative, HAL_WAIT_FOREVER);
|
||||
|
||||
//FILE_LOG(logDEBUG) << "PacketIndex: " << (void*)controlDataNative.packetIndex << " Control: " << (void*)controlDataNative.control << " ReturnValue: " << (void*)returnValue;
|
||||
|
||||
if(!initializeComplete)
|
||||
{
|
||||
// control data class
|
||||
dataClass = (jclass)env->NewGlobalRef(env->GetObjectClass(controlData));
|
||||
//dataClass = env->GetObjectClass(controlData);
|
||||
// public short packetIndex;
|
||||
packetIndexFieldID = env->GetFieldID(dataClass, "packetIndex", "S" );
|
||||
// public byte control;
|
||||
controlFieldID = env->GetFieldID(dataClass, "control", "B" );
|
||||
// public byte dsDigitalIn;
|
||||
dsDigitalInFieldID = env->GetFieldID(dataClass, "dsDigitalIn", "B" );
|
||||
// public short teamID;
|
||||
teamIDFieldID = env->GetFieldID(dataClass, "teamID", "S" );
|
||||
// public byte dsID_Alliance;
|
||||
dsID_AllianceFieldID = env->GetFieldID(dataClass, "dsID_Alliance", "B" );
|
||||
// public byte dsID_Position;
|
||||
dsID_PositionFieldID = env->GetFieldID(dataClass, "dsID_Position", "B" );
|
||||
// public byte[] stick0Axes;
|
||||
stick0AxesFieldID = env->GetFieldID(dataClass, "stick0Axes", "[B" );
|
||||
// public short stick0Buttons;
|
||||
stick0ButtonsFieldID = env->GetFieldID(dataClass, "stick0Buttons", "S" );
|
||||
// public byte[] stick1Axes;
|
||||
stick1AxesFieldID = env->GetFieldID(dataClass, "stick1Axes", "[B" );
|
||||
// public short stick1Buttons;
|
||||
stick1ButtonsFieldID = env->GetFieldID(dataClass, "stick1Buttons", "S" );
|
||||
// public byte[] stick2Axes;
|
||||
stick2AxesFieldID = env->GetFieldID(dataClass, "stick2Axes", "[B" );
|
||||
// public short stick2Buttons;
|
||||
stick2ButtonsFieldID = env->GetFieldID(dataClass, "stick2Buttons", "S" );
|
||||
// public byte[] stick3Axes;
|
||||
stick3AxesFieldID = env->GetFieldID(dataClass, "stick3Axes", "[B" );
|
||||
// public short stick3Buttons;
|
||||
stick3ButtonsFieldID = env->GetFieldID(dataClass, "stick3Buttons", "S" );
|
||||
// public short analog1;
|
||||
analog1FieldID = env->GetFieldID(dataClass, "analog1", "S" );
|
||||
// public short analog2;
|
||||
analog2FieldID = env->GetFieldID(dataClass, "analog2", "S" );
|
||||
// public short analog3;
|
||||
analog3FieldID = env->GetFieldID(dataClass, "analog3", "S" );
|
||||
// public short analog4;
|
||||
analog4FieldID = env->GetFieldID(dataClass, "analog4", "S" );
|
||||
// public long cRIOChecksum;
|
||||
cRIOChecksumFieldID = env->GetFieldID(dataClass, "cRIOChecksum", "J" );
|
||||
// public int FPGAChecksum0;
|
||||
FPGAChecksum0FieldID = env->GetFieldID(dataClass, "FPGAChecksum0", "I" );
|
||||
// public int FPGAChecksum1;
|
||||
FPGAChecksum1FieldID = env->GetFieldID(dataClass, "FPGAChecksum1", "I" );
|
||||
// public int FPGAChecksum2;
|
||||
FPGAChecksum2FieldID = env->GetFieldID(dataClass, "FPGAChecksum2", "I" );
|
||||
// public int FPGAChecksum3;
|
||||
FPGAChecksum3FieldID = env->GetFieldID(dataClass, "FPGAChecksum3", "I" );
|
||||
// public byte[] versionData;
|
||||
versionDataFieldID = env->GetFieldID(dataClass, "versionData", "[B" );
|
||||
|
||||
initializeComplete = true;
|
||||
}
|
||||
|
||||
//FILE_LOG(logDEBUG) << "PacketIndex : " << (short)controlDataNative.packetIndex;
|
||||
env->SetShortField(controlData,packetIndexFieldID, controlDataNative.packetIndex);
|
||||
//FILE_LOG(logDEBUG) << "Control : " << (short)controlDataNative.control;
|
||||
env->SetByteField(controlData,controlFieldID, controlDataNative.control);
|
||||
env->SetByteField(controlData,dsDigitalInFieldID, controlDataNative.dsDigitalIn);
|
||||
env->SetShortField(controlData,teamIDFieldID, controlDataNative.teamID);
|
||||
env->SetByteField(controlData,dsID_AllianceFieldID, controlDataNative.dsID_Alliance);
|
||||
env->SetByteField(controlData,dsID_PositionFieldID, controlDataNative.dsID_Position);
|
||||
|
||||
// process the axes for joystick 0
|
||||
jobject stick0Axes = env->GetObjectField(controlData, stick0AxesFieldID);
|
||||
jbyteArray * stick0AxesPtr = reinterpret_cast<jbyteArray*>(&stick0Axes);
|
||||
jbyte * stick0AxesBytePtr = env->GetByteArrayElements(*stick0AxesPtr,NULL);
|
||||
|
||||
for( short axisCount = 0; axisCount < 6; axisCount++)
|
||||
{
|
||||
stick0AxesBytePtr[axisCount]=controlDataNative.stick0Axes[axisCount];
|
||||
}
|
||||
|
||||
env->ReleaseByteArrayElements(*stick0AxesPtr,stick0AxesBytePtr,0);
|
||||
|
||||
// /** C type : field2_union */
|
||||
// public field2_union field2;
|
||||
// /** Left-most 4 bits are unused */
|
||||
env->SetShortField(controlData,stick0ButtonsFieldID, controlDataNative.stick0Buttons);
|
||||
|
||||
// process the axes for joystick 1
|
||||
jobject stick1Axes = env->GetObjectField(controlData, stick1AxesFieldID);
|
||||
jbyteArray * stick1AxesPtr = reinterpret_cast<jbyteArray*>(&stick1Axes);
|
||||
jbyte * stick1AxesBytePtr = env->GetByteArrayElements(*stick1AxesPtr,NULL);
|
||||
|
||||
for( short axisCount = 0; axisCount < 6; axisCount++)
|
||||
{
|
||||
stick1AxesBytePtr[axisCount]=controlDataNative.stick1Axes[axisCount];
|
||||
}
|
||||
|
||||
env->ReleaseByteArrayElements(*stick1AxesPtr,stick1AxesBytePtr,0);
|
||||
|
||||
// /** C type : field3_union */
|
||||
// public field3_union field3;
|
||||
// /** Left-most 4 bits are unused */
|
||||
env->SetShortField(controlData,stick1ButtonsFieldID, controlDataNative.stick1Buttons);
|
||||
|
||||
// process the axes for joystick 2
|
||||
jobject stick2Axes = env->GetObjectField(controlData, stick2AxesFieldID);
|
||||
jbyteArray * stick2AxesPtr = reinterpret_cast<jbyteArray*>(&stick2Axes);
|
||||
jbyte * stick2AxesBytePtr = env->GetByteArrayElements(*stick2AxesPtr,NULL);
|
||||
|
||||
for( short axisCount = 0; axisCount < 6; axisCount++)
|
||||
{
|
||||
stick2AxesBytePtr[axisCount]=controlDataNative.stick2Axes[axisCount];
|
||||
}
|
||||
|
||||
env->ReleaseByteArrayElements(*stick2AxesPtr,stick2AxesBytePtr,0);
|
||||
|
||||
// /** C type : field4_union */
|
||||
// public field4_union field4;
|
||||
// /** Left-most 4 bits are unused */
|
||||
env->SetShortField(controlData,stick2ButtonsFieldID, controlDataNative.stick2Buttons);
|
||||
|
||||
// process the axes for joystick 3
|
||||
jobject stick3Axes = env->GetObjectField(controlData, stick3AxesFieldID);
|
||||
jbyteArray * stick3AxesPtr = reinterpret_cast<jbyteArray*>(&stick3Axes);
|
||||
jbyte * stick3AxesBytePtr = env->GetByteArrayElements(*stick3AxesPtr,NULL);
|
||||
|
||||
for( short axisCount = 0; axisCount < 6; axisCount++)
|
||||
{
|
||||
stick3AxesBytePtr[axisCount]=controlDataNative.stick3Axes[axisCount];
|
||||
}
|
||||
|
||||
env->ReleaseByteArrayElements(*stick3AxesPtr,stick3AxesBytePtr,0);
|
||||
|
||||
// /** C type : field5_union */
|
||||
// public field5_union field5;
|
||||
// /** Left-most 4 bits are unused */
|
||||
env->SetShortField(controlData,stick3ButtonsFieldID, controlDataNative.stick3Buttons);
|
||||
// /** Analog inputs are 10 bit right-justified */
|
||||
env->SetShortField(controlData,analog1FieldID, controlDataNative.analog1);
|
||||
env->SetShortField(controlData,analog2FieldID, controlDataNative.analog2);
|
||||
env->SetShortField(controlData,analog3FieldID, controlDataNative.analog3);
|
||||
env->SetShortField(controlData,analog4FieldID, controlDataNative.analog4);
|
||||
env->SetLongField(controlData,cRIOChecksumFieldID, controlDataNative.cRIOChecksum);
|
||||
env->SetIntField(controlData,FPGAChecksum0FieldID, controlDataNative.FPGAChecksum0);
|
||||
env->SetIntField(controlData,FPGAChecksum1FieldID, controlDataNative.FPGAChecksum1);
|
||||
env->SetIntField(controlData,FPGAChecksum2FieldID, controlDataNative.FPGAChecksum2);
|
||||
env->SetIntField(controlData,FPGAChecksum3FieldID, controlDataNative.FPGAChecksum3);
|
||||
// /** C type : char[8] */
|
||||
// public byte[] versionData;
|
||||
jobject versionData = env->GetObjectField(controlData, versionDataFieldID);
|
||||
jbyteArray * versionDataPtr = reinterpret_cast<jbyteArray*>(&versionData);
|
||||
jbyte * versionDataBytePtr = env->GetByteArrayElements(*versionDataPtr,NULL);
|
||||
|
||||
for( short byteCount = 0; byteCount < 8; byteCount++)
|
||||
{
|
||||
versionDataBytePtr[byteCount]=controlDataNative.versionData[byteCount];
|
||||
}
|
||||
|
||||
env->ReleaseByteArrayElements(*versionDataPtr,versionDataBytePtr,0);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getRecentCommonControlData
|
||||
* Signature: (Ledu/wpi/first/wpilibj/communication/FRCCommonControlData;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getRecentCommonControlData
|
||||
(JNIEnv *, jclass, jobject, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getRecentStatusData
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getRecentStatusData
|
||||
(JNIEnv *, jclass, jobject, jobject, jobject, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: getDynamicControlData
|
||||
* Signature: (BLjava/nio/ByteBuffer;II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getDynamicControlData
|
||||
(JNIEnv *, jclass, jbyte, jobject, jint, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: setStatusData
|
||||
* Signature: (FBBLjava/lang/String;ILjava/lang/String;II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setStatusData
|
||||
(JNIEnv * env, jclass, jfloat paramBattery, jbyte param1, jbyte param2, jstring paramUserDataHigh, jint param4, jstring paramUserDataLow, jint param6)
|
||||
{
|
||||
//FILE_LOG(logDEBUG) << "Voltage - " << paramBattery;
|
||||
const char * userDataHighStr = env->GetStringUTFChars(paramUserDataHigh, NULL);
|
||||
const char * userDataLowStr = env->GetStringUTFChars(paramUserDataLow, NULL);
|
||||
jint returnValue = HALSetStatusData(paramBattery, param1, param2, userDataHighStr, param4, userDataLowStr, param6, HAL_WAIT_FOREVER );
|
||||
env->ReleaseStringUTFChars(paramUserDataHigh,userDataHighStr);
|
||||
env->ReleaseStringUTFChars(paramUserDataLow,userDataLowStr);
|
||||
return returnValue;
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: setStatusDataFloatAsInt
|
||||
* Signature: (IBBLjava/lang/String;ILjava/lang/String;II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setStatusDataFloatAsInt
|
||||
(JNIEnv *, jclass, jint, jbyte, jbyte, jstring, jint, jstring, jint, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: setErrorData
|
||||
* Signature: (Ljava/lang/String;II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setErrorData
|
||||
(JNIEnv *, jclass, jstring, jint, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: setUserDsLcdData
|
||||
* Signature: (Ljava/lang/String;II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setUserDsLcdData
|
||||
(JNIEnv *, jclass, jstring, jint, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: overrideIOConfig
|
||||
* Signature: (Ljava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_overrideIOConfig
|
||||
(JNIEnv *, jclass, jstring, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: signalResyncActionDone
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_signalResyncActionDone
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: setNewDataOccurRef
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setNewDataOccurRef
|
||||
(JNIEnv *, jclass, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: setResyncOccurRef
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setResyncOccurRef
|
||||
(JNIEnv *, jclass, jint)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_getVersionString
|
||||
* Signature: (Ljava/nio/ByteBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationGetVersionString
|
||||
(JNIEnv *, jclass, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_observeUserProgramStarting
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramStarting
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
HALNetworkCommunicationObserveUserProgramStarting();
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_observeUserProgramDisabled
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramDisabled
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
HALNetworkCommunicationObserveUserProgramDisabled();
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_observeUserProgramAutonomous
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramAutonomous
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
HALNetworkCommunicationObserveUserProgramAutonomous();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_observeUserProgramTeleop
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramTeleop
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
HALNetworkCommunicationObserveUserProgramTeleop();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
||||
* Method: FRC_NetworkCommunication_observeUserProgramTest
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramTest
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
HALNetworkCommunicationObserveUserProgramTest();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: FRCNetworkCommunicationReserve
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationReserve
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
HALNetworkCommunicationReserve();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: setNewDataSem
|
||||
* Signature: ([B)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setNewDataSem
|
||||
(JNIEnv * env, jclass, jobject id )
|
||||
{
|
||||
MUTEX_ID* javaId = (MUTEX_ID*)env->GetDirectBufferAddress(id);
|
||||
FILE_LOG(logDEBUG) << "Mutex Ptr = " << *javaId;
|
||||
HALSetNewDataSem(*javaId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueParameterTest
|
||||
* Signature: (ZBCSIJFD)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueParameterTest
|
||||
(JNIEnv *, jclass, jboolean booleanParam, jbyte byteParam, jchar charParam, jshort shortParam, jint intParam, jlong longParam, jfloat floatParam, jdouble doubleParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Boolean: " << booleanParam;
|
||||
FILE_LOG(logDEBUG) << "Byte : " << byteParam;
|
||||
FILE_LOG(logDEBUG) << "Char : " << charParam;
|
||||
FILE_LOG(logDEBUG) << "Short : " << shortParam;
|
||||
FILE_LOG(logDEBUG) << "Int : " << intParam;
|
||||
FILE_LOG(logDEBUG) << "Long : " << longParam;
|
||||
FILE_LOG(logDEBUG) << "Float : " << floatParam;
|
||||
FILE_LOG(logDEBUG) << "Double : " << doubleParam;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnBooleanTest
|
||||
* Signature: (Z)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnBooleanTest
|
||||
(JNIEnv *, jclass, jboolean booleanParam )
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Boolean: " << booleanParam;
|
||||
return !booleanParam;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnByteTest
|
||||
* Signature: (B)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnByteTest
|
||||
(JNIEnv *, jclass, jbyte byteParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Byte: " << byteParam;
|
||||
return byteParam+1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnCharTest
|
||||
* Signature: (C)C
|
||||
*/
|
||||
JNIEXPORT jchar JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnCharTest
|
||||
(JNIEnv *, jclass, jchar charParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Char: " << charParam;
|
||||
return charParam+1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnShortTest
|
||||
* Signature: (S)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnShortTest
|
||||
(JNIEnv *, jclass, jshort shortParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Short: " << shortParam;
|
||||
return shortParam+1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnIntTest
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnIntTest
|
||||
(JNIEnv *, jclass, jint intParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Int: " << intParam;
|
||||
return intParam+1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnLongTest
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnLongTest
|
||||
(JNIEnv *, jclass, jlong longParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Long: " << longParam;
|
||||
return longParam+1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnFloatTest
|
||||
* Signature: (F)F
|
||||
*/
|
||||
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnFloatTest
|
||||
(JNIEnv *, jclass, jfloat floatParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Float: " << floatParam;
|
||||
return floatParam/100.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIValueReturnDoubleTest
|
||||
* Signature: (D)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIValueReturnDoubleTest
|
||||
(JNIEnv *, jclass, jdouble doubleParam)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Double: " << doubleParam;
|
||||
return doubleParam * 100.0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIObjectReturnString
|
||||
* Signature: (Ljava/lang/String;)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIObjectReturnStringTest
|
||||
(JNIEnv * env, jclass, jstring stringParam)
|
||||
{
|
||||
const char * stringParamLocal = env->GetStringUTFChars(stringParam, NULL);
|
||||
FILE_LOG(logDEBUG) << "String: " << stringParamLocal;
|
||||
env->ReleaseStringUTFChars(stringParam,stringParamLocal);
|
||||
|
||||
char returnStringLocal[] = "this is the return string";
|
||||
|
||||
return env->NewStringUTF(returnStringLocal);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIObjectReturnByteBufferTest
|
||||
* Signature: (Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIObjectReturnByteBufferTest
|
||||
(JNIEnv * env, jclass, jobject byteArrayIn )
|
||||
{
|
||||
jbyte * byteArray = (jbyte*)env->GetDirectBufferAddress(byteArrayIn);
|
||||
FILE_LOG(logDEBUG) << "Ptr: " << (long)byteArray;
|
||||
jlong byteArrayLength = env->GetDirectBufferCapacity(byteArrayIn);
|
||||
FILE_LOG(logDEBUG) << "Capacity: " << byteArrayLength;
|
||||
FILE_LOG(logDEBUG) << "Byte0: " << (short)byteArray[0];
|
||||
FILE_LOG(logDEBUG) << "Byte1: " << (short)byteArray[1];
|
||||
FILE_LOG(logDEBUG) << "Byte2: " << (short)byteArray[2];
|
||||
FILE_LOG(logDEBUG) << "Byte3: " << (short)byteArray[3];
|
||||
|
||||
jbyte * returnByteArray = new jbyte[4];
|
||||
returnByteArray[0] = byteArray[0];
|
||||
returnByteArray[1] = byteArray[1];
|
||||
returnByteArray[2] = byteArray[2];
|
||||
returnByteArray[3] = byteArray[3];
|
||||
|
||||
return env->NewDirectByteBuffer(returnByteArray, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
||||
* Method: JNIObjectAndParamReturnIntBufferTest
|
||||
* Signature: (Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_JNIObjectAndParamReturnIntBufferTest
|
||||
(JNIEnv * env, jclass, jobject intArrayIn)
|
||||
{
|
||||
jint * intArray = (jint*)env->GetDirectBufferAddress(intArrayIn);
|
||||
jbyte * byteArray = (jbyte*)env->GetDirectBufferAddress(intArrayIn);
|
||||
FILE_LOG(logDEBUG) << "Ptr: " << (long)intArray;
|
||||
jlong byteArrayLength = env->GetDirectBufferCapacity(intArrayIn);
|
||||
FILE_LOG(logDEBUG) << "Capacity: " << byteArrayLength;
|
||||
FILE_LOG(logDEBUG) << "Int0: " << intArray[0];
|
||||
FILE_LOG(logDEBUG) << "Byte0: " << (short)byteArray[0];
|
||||
FILE_LOG(logDEBUG) << "Byte1: " << (short)byteArray[1];
|
||||
FILE_LOG(logDEBUG) << "Byte2: " << (short)byteArray[2];
|
||||
FILE_LOG(logDEBUG) << "Byte3: " << (short)byteArray[3];
|
||||
|
||||
// increment the param
|
||||
intArray[0]++;
|
||||
|
||||
jbyte * returnByteArray = new jbyte[4];
|
||||
returnByteArray[0] = byteArray[0];
|
||||
returnByteArray[1] = byteArray[1];
|
||||
returnByteArray[2] = byteArray[2];
|
||||
returnByteArray[3] = byteArray[3];
|
||||
|
||||
return env->NewDirectByteBuffer(returnByteArray, 4);
|
||||
}
|
||||
130
wpilibj/wpilibJavaJNI/src/main/native/HALUtil.cpp
Normal file
130
wpilibj/wpilibJavaJNI/src/main/native/HALUtil.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
#include "edu_wpi_first_wpilibj_hal_HALUtil.h"
|
||||
#include "HAL/HAL.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel halUtilLogLevel = logDEBUG;
|
||||
|
||||
#define HALUTIL_LOG(level) \
|
||||
if (level > halUtilLogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
|
||||
//
|
||||
// indicate JNI version support desired
|
||||
//
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
// set our logging level
|
||||
Log::ReportingLevel() = logDEBUG;
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: initializeMutex
|
||||
* Signature: (I)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMutexNormal
|
||||
(JNIEnv * env, jclass)
|
||||
{
|
||||
HALUTIL_LOG(logDEBUG) << "Calling HALUtil initializeMutex";
|
||||
MUTEX_ID* mutexPtr = (MUTEX_ID*)new unsigned char[4];
|
||||
*mutexPtr = initializeMutexNormal();
|
||||
HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << *mutexPtr;
|
||||
return env->NewDirectByteBuffer( mutexPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: deleteMutex
|
||||
* Signature: (Ljava/nio/ByteBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMutex
|
||||
(JNIEnv * env, jclass, jobject id )
|
||||
{
|
||||
HALUTIL_LOG(logDEBUG) << "Calling HALUtil deleteMutex";
|
||||
MUTEX_ID* javaId = (MUTEX_ID*)env->GetDirectBufferAddress(id);
|
||||
HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << *javaId;
|
||||
deleteMutex( *javaId );
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: takeMutex
|
||||
* Signature: (Ljava/nio/ByteBuffer;I)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMutex
|
||||
(JNIEnv * env, jclass, jobject id)
|
||||
{
|
||||
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil takeMutex";
|
||||
MUTEX_ID* javaId = (MUTEX_ID*)env->GetDirectBufferAddress(id);
|
||||
//HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << *javaId;
|
||||
jbyte returnValue = takeMutex(*javaId);
|
||||
//HALUTIL_LOG(logDEBUG) << "Take Result = " << (void*)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: getFPGAVersion
|
||||
* Signature: (Ljava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAVersion
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGAVersion";
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jshort returnValue = getFPGAVersion( statusPtr );
|
||||
HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
HALUTIL_LOG(logDEBUG) << "FPGAVersion = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: getFPGARevision
|
||||
* Signature: (Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGARevision
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGARevision";
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jint returnValue = getFPGARevision( statusPtr );
|
||||
HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
HALUTIL_LOG(logDEBUG) << "FPGARevision = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: getFPGATime
|
||||
* Signature: (Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGATime
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jlong returnValue = getFPGATime( statusPtr );
|
||||
//HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
//HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;
|
||||
return returnValue;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_HALUtil
|
||||
* Method: getHALErrorMessage
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALErrorMessage
|
||||
(JNIEnv * paramEnv, jclass, jint paramId)
|
||||
{
|
||||
const char * msg = getHALErrorMessage(paramId);
|
||||
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getHALErrorMessage id=" << paramId << " msg=" << msg;
|
||||
return paramEnv->NewStringUTF(msg);
|
||||
}
|
||||
35
wpilibj/wpilibJavaJNI/src/main/native/I2CJNI.cpp
Normal file
35
wpilibj/wpilibJavaJNI/src/main/native/I2CJNI.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_I2CJNI.h"
|
||||
|
||||
|
||||
// set the logging level
|
||||
TLogLevel i2cJNILogLevel = logDEBUG;
|
||||
|
||||
#define I2CJNI_LOG(level) \
|
||||
if (level > i2cJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: doI2CTransaction
|
||||
* Signature: (BBLjava/nio/ByteBuffer;BLjava/nio/ByteBuffer;BLjava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_doI2CTransaction
|
||||
(JNIEnv *, jclass, jbyte, jbyte, jobject, jbyte, jobject, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: doI2CTransactionWithModule
|
||||
* Signature: (BBBLjava/nio/ByteBuffer;BLjava/nio/ByteBuffer;BLjava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_doI2CTransactionWithModule
|
||||
(JNIEnv *, jclass, jbyte, jbyte, jbyte, jobject, jbyte, jobject, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
113
wpilibj/wpilibJavaJNI/src/main/native/InterruptJNI.cpp
Normal file
113
wpilibj/wpilibJavaJNI/src/main/native/InterruptJNI.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_InterruptJNI.h"
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: initializeInterrupts
|
||||
* Signature: (IBLjava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeInterrupts
|
||||
(JNIEnv *, jclass, jint, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: cleanInterrupts
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrupts
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: waitForInterrupt
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterrupt
|
||||
(JNIEnv *, jclass, jobject, jdouble, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: enableInterrupts
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterrupts
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: disableInterrupts
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterrupts
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: readInterruptTimestamp
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readInterruptTimestamp
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: requestInterrupts
|
||||
* Signature: (Ljava/nio/ByteBuffer;BIBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterrupts
|
||||
(JNIEnv *, jclass, jobject, jbyte, jint, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: attachInterruptHandler
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ledu/wpi/first/wpilibj/hal/InterruptJNI/InterruptHandlerFunction;Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler
|
||||
(JNIEnv *, jclass, jobject, jobject, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: setInterruptUpSourceEdge
|
||||
* Signature: (Ljava/nio/ByteBuffer;BBLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_setInterruptUpSourceEdge
|
||||
(JNIEnv *, jclass, jobject, jbyte, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
}
|
||||
25
wpilibj/wpilibJavaJNI/src/main/native/JNIWrapper.cpp
Normal file
25
wpilibj/wpilibJavaJNI/src/main/native/JNIWrapper.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_JNIWrapper.h"
|
||||
|
||||
#include "HAL/HAL.h"
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_JNIWrapper
|
||||
* Method: getPortWithModule
|
||||
* Signature: (BB)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPortWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jbyte pin)
|
||||
{
|
||||
//FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
|
||||
//FILE_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
//FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
|
||||
void** portPtr = (void**)new unsigned char[4];
|
||||
*portPtr = getPortWithModule(module,pin);
|
||||
//FILE_LOG(logDEBUG) << "Port Ptr = " << *portPtr;
|
||||
return env->NewDirectByteBuffer( portPtr, 4);
|
||||
}
|
||||
|
||||
244
wpilibj/wpilibJavaJNI/src/main/native/PWMJNI.cpp
Normal file
244
wpilibj/wpilibJavaJNI/src/main/native/PWMJNI.cpp
Normal file
@@ -0,0 +1,244 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_PWMJNI.h"
|
||||
|
||||
#include "HAL/Digital.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel pwmJNILogLevel = logERROR;
|
||||
|
||||
#define PWMJNI_LOG(level) \
|
||||
if (level > pwmJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWM
|
||||
* Signature: (Ljava/nio/ByteBuffer;SLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWM
|
||||
(JNIEnv * env, jclass, jobject id, jshort value, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << *javaId;
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Value = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setPWM( *javaId, value, statusPtr );
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: getPWM
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_getPWM
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jshort returnValue = getPWM( *javaId, statusPtr );
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
PWMJNI_LOG(logDEBUG) << "Value = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMPeriodScale
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMPeriodScale
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status )
|
||||
{
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << *javaId;
|
||||
PWMJNI_LOG(logDEBUG) << "PeriodScale Value = " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setPWMPeriodScale( *javaId, value, statusPtr );
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: allocatePWM
|
||||
* Signature: (Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWM
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI allocatePWM";
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
void** pwmPtr = (void**)new unsigned char[4];
|
||||
*pwmPtr = allocatePWM(statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *pwmPtr;
|
||||
return env->NewDirectByteBuffer( pwmPtr, 4);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: allocatePWMWithModule
|
||||
* Signature: (BLjava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWMWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI allocatePWMWithModule";
|
||||
PWMJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
void** pwmPtr = (void**)new unsigned char[4];
|
||||
*pwmPtr = allocatePWMWithModule(module, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *pwmPtr;
|
||||
return env->NewDirectByteBuffer( pwmPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: freePWM
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWM
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI freePWM";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
freePWM(*javaId, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: freePWMWithModule
|
||||
* Signature: (BLjava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWMWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jobject id, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI freePWMWithModule";
|
||||
PWMJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
freePWMWithModule(module, *javaId, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMRate
|
||||
* Signature: (DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMRate
|
||||
(JNIEnv * env, jclass, jdouble value, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMRate";
|
||||
PWMJNI_LOG(logDEBUG) << "Rate= " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setPWMRate(value, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMRateWithModule
|
||||
* Signature: (BDLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMRateWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jdouble value, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMRateWithModule";
|
||||
PWMJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
PWMJNI_LOG(logDEBUG) << "Rate= " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setPWMRateWithModule(module, value, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMDutyCycle
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMDutyCycle
|
||||
(JNIEnv * env, jclass, jobject id, jdouble value, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMDutyCycle";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
PWMJNI_LOG(logDEBUG) << "DutyCycle= " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setPWMDutyCycle(*javaId, value, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMDutyCycleWithModule
|
||||
* Signature: (BLjava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMDutyCycleWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jobject id, jdouble value, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMDutyCycleWithModule";
|
||||
PWMJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
PWMJNI_LOG(logDEBUG) << "DutyCycle= " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setPWMDutyCycleWithModule( module, *javaId, value, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMOutputChannel
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMOutputChannel
|
||||
(JNIEnv * env, jclass, jobject id, jint value, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMOutputChannel";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
PWMJNI_LOG(logDEBUG) << "Pin= " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setPWMOutputChannel(*javaId, (uint32_t) value, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
|
||||
* Method: setPWMOutputChannelWithModule
|
||||
* Signature: (BLjava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMOutputChannelWithModule
|
||||
(JNIEnv * env, jclass, jbyte module, jobject id, jint value, jobject status)
|
||||
{
|
||||
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMOutputChannelWithModule";
|
||||
PWMJNI_LOG(logDEBUG) << "Module = " << (jint)module;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << *javaId;
|
||||
PWMJNI_LOG(logDEBUG) << "Pin= " << value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setPWMOutputChannelWithModule( module, *javaId, (uint32_t) value, statusPtr);
|
||||
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
88
wpilibj/wpilibJavaJNI/src/main/native/RelayJNI.cpp
Normal file
88
wpilibj/wpilibJavaJNI/src/main/native/RelayJNI.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_RelayJNI.h"
|
||||
|
||||
#include "HAL/Digital.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel relayJNILogLevel = logDEBUG;
|
||||
|
||||
#define RELAYJNI_LOG(level) \
|
||||
if (level > relayJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_RelayJNI
|
||||
* Method: setRelayForward
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayForward
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI setRelayForward";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setRelayForward(*javaId, value, statusPtr);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_RelayJNI
|
||||
* Method: setRelayReverse
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayReverse
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI setRelayReverse";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
setRelayReverse(*javaId, value, statusPtr);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_RelayJNI
|
||||
* Method: getRelayForward
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayForward
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI getRelayForward";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getRelayForward(*javaId, statusPtr);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
RELAYJNI_LOG(logDEBUG) << "getRelayForwardResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_RelayJNI
|
||||
* Method: getRelayReverse
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayReverse
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI getRelayReverse";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jbyte returnValue = getRelayReverse(*javaId, statusPtr);
|
||||
RELAYJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
RELAYJNI_LOG(logDEBUG) << "getRelayReverseResult = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
289
wpilibj/wpilibJavaJNI/src/main/native/SPIJNI.cpp
Normal file
289
wpilibj/wpilibJavaJNI/src/main/native/SPIJNI.cpp
Normal file
@@ -0,0 +1,289 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_SPIJNI.h"
|
||||
|
||||
|
||||
// set the logging level
|
||||
TLogLevel spiJNILogLevel = logDEBUG;
|
||||
|
||||
#define SPIJNI_LOG(level) \
|
||||
if (level > spiJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: initializeSPI
|
||||
* Signature: (BIBIBILjava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_initializeSPI
|
||||
(JNIEnv *, jclass, jbyte, jint, jbyte, jint, jbyte, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: cleanSPI
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_cleanSPI
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPIBitsPerWord
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPIBitsPerWord
|
||||
(JNIEnv *, jclass, jobject, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: getSPIBitsPerWord
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_getSPIBitsPerWord
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPIClockRate
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPIClockRate
|
||||
(JNIEnv *, jclass, jobject, jdouble, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPIMSBFirst
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPIMSBFirst
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPILSBFirst
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPILSBFirst
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPISampleDataOnFalling
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPISampleDataOnFalling
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPISampleDataOnRising
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPISampleDataOnRising
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPISlaveSelect
|
||||
* Signature: (Ljava/nio/ByteBuffer;BILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPISlaveSelect
|
||||
(JNIEnv *, jclass, jobject, jbyte, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPILatchMode
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPILatchMode
|
||||
(JNIEnv *, jclass, jobject, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: getSPILatchMode
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_getSPILatchMode
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPIFramePolarity
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPIFramePolarity
|
||||
(JNIEnv *, jclass, jobject, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: getSPIFramePolarity
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_getSPIFramePolarity
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPIClockActiveLow
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPIClockActiveLow
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: setSPIClockActiveHigh
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_setSPIClockActiveHigh
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: applySPIConfig
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_applySPIConfig
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: getSPIOutputFIFOAvailable
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_getSPIOutputFIFOAvailable
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: getSPINumReceived
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_getSPINumReceived
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: isSPIDone
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_isSPIDone
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: hadSPIReceiveOverflow
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_hadSPIReceiveOverflow
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: writeSPI
|
||||
* Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_writeSPI
|
||||
(JNIEnv *, jclass, jobject, jint, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: readSPI
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_readSPI
|
||||
(JNIEnv *, jclass, jobject, jbyte, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: resetSPI
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_resetSPI
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: clearSPIReceivedData
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_clearSPIReceivedData
|
||||
(JNIEnv *, jclass, jobject, jobject)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
208
wpilibj/wpilibJavaJNI/src/main/native/WatchdogJNI.cpp
Normal file
208
wpilibj/wpilibJavaJNI/src/main/native/WatchdogJNI.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_WatchdogJNI.h"
|
||||
|
||||
#include "HAL/Watchdog.h"
|
||||
// set the logging level
|
||||
TLogLevel watchdogJNILogLevel = logDEBUG;
|
||||
|
||||
#define WATCHDOGJNI_LOG(level) \
|
||||
if (level > watchdogJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: initializeWatchdog
|
||||
* Signature: (Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_initializeWatchdog
|
||||
(JNIEnv * env, jclass, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog initializeWatchdog";
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
|
||||
jlong statusCapacity = env->GetDirectBufferCapacity(status);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status Capacity = " << statusCapacity;
|
||||
void** watchdogPtr = (void**)new unsigned char[4];
|
||||
*watchdogPtr = initializeWatchdog(statusPtr);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *watchdogPtr;
|
||||
return env->NewDirectByteBuffer( watchdogPtr, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: cleanWatchdog
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_cleanWatchdog
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog cleanWatchdog";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
cleanWatchdog( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: feedWatchdog
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_feedWatchdog
|
||||
(JNIEnv * env, jclass, jobject id, jobject status )
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog feedWatchdog";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jbyte returnValue = feedWatchdog( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "feedWatchdog return = " << (short)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: killWatchdog
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_killWatchdog
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog killWatchdog";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
killWatchdog( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: getWatchdogLastFed
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_getWatchdogLastFed
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog getWatchdogLastFed";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
double returnValue = getWatchdogLastFed( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "LastFed = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: getWatchdogExpiration
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_getWatchdogExpiration
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog getWatchdogExpiration";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
double returnValue = getWatchdogExpiration( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Expiration = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: setWatchdogExpiration
|
||||
* Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_setWatchdogExpiration
|
||||
(JNIEnv * env, jclass, jobject id, jdouble value, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog setWatchdogExpiration";
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Expiration = " << value;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setWatchdogExpiration( *javaId, value, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: getWatchdogEnabled
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_getWatchdogEnabled
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog getWatchdogEnabled";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jbyte returnValue = getWatchdogEnabled( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Enabled = " << (short)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: setWatchdogEnabled
|
||||
* Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_setWatchdogEnabled
|
||||
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog setWatchdogEnabled";
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Enabled = " << (short)value;
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
setWatchdogEnabled( *javaId, value, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: isWatchdogAlive
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_isWatchdogAlive
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog isWatchdogAlive";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jbyte returnValue = isWatchdogAlive( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "IsAlive = " << (short)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_WatchdogJNI
|
||||
* Method: isWatchdogSystemActive
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_WatchdogJNI_isWatchdogSystemActive
|
||||
(JNIEnv * env, jclass, jobject id, jobject status)
|
||||
{
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Calling Watchdog isWatchdogSystemActive";
|
||||
void ** javaId = (void**)env->GetDirectBufferAddress(id);
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Watchdog Ptr = " << *javaId;
|
||||
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
|
||||
jbyte returnValue = isWatchdogSystemActive( *javaId, statusPtr );
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
|
||||
WATCHDOGJNI_LOG(logDEBUG) << "IsActive = " << (short)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user