Add format script which invokes clang-format on the C++ source code (#41)

On Windows machines, clang-format.exe must be in the PATH environment variable.
This commit is contained in:
Tyler Veness
2016-05-20 17:30:37 -07:00
committed by Peter Johnson
parent 68690643d2
commit e14e45da76
383 changed files with 13787 additions and 13198 deletions

View File

@@ -5,9 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "HAL/Accelerometer.hpp"
#include <jni.h>
#include "edu_wpi_first_wpilibj_hal_AccelerometerJNI.h"
#include "HAL/Accelerometer.hpp"
extern "C" {
@@ -16,10 +16,10 @@ extern "C" {
* Method: setAccelerometerActive
* Signature: (Z)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_setAccelerometerActive
(JNIEnv *, jclass, jboolean active)
{
setAccelerometerActive(active);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_setAccelerometerActive(
JNIEnv *, jclass, jboolean active) {
setAccelerometerActive(active);
}
/*
@@ -27,10 +27,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_setAccele
* Method: setAccelerometerRange
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_setAccelerometerRange
(JNIEnv *, jclass, jint range)
{
setAccelerometerRange((AccelerometerRange)range);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_setAccelerometerRange(
JNIEnv *, jclass, jint range) {
setAccelerometerRange((AccelerometerRange)range);
}
/*
@@ -38,10 +38,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_setAccele
* Method: getAccelerometerX
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAccelerometerX
(JNIEnv *, jclass)
{
return getAccelerometerX();
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAccelerometerX(
JNIEnv *, jclass) {
return getAccelerometerX();
}
/*
@@ -49,10 +49,10 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAcc
* Method: getAccelerometerY
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAccelerometerY
(JNIEnv *, jclass)
{
return getAccelerometerY();
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAccelerometerY(
JNIEnv *, jclass) {
return getAccelerometerY();
}
/*
@@ -60,10 +60,10 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAcc
* Method: getAccelerometerZ
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAccelerometerZ
(JNIEnv *, jclass)
{
return getAccelerometerZ();
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AccelerometerJNI_getAccelerometerZ(
JNIEnv *, jclass) {
return getAccelerometerZ();
}
} // extern "C"

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_AnalogJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel analogJNILogLevel = logWARNING;
#define ANALOGJNI_LOG(level) \
if (level > analogJNILogLevel) ; \
else Log().Get(level)
#define ANALOGJNI_LOG(level) \
if (level > analogJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,16 +30,16 @@ extern "C" {
* Method: initializeAnalogInputPort
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogInputPort
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
void* analog = initializeAnalogInputPort((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << analog;
CheckStatus(env, status);
return (jlong)analog;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogInputPort(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
int32_t status = 0;
void *analog = initializeAnalogInputPort((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << analog;
CheckStatus(env, status);
return (jlong)analog;
}
/*
@@ -45,11 +47,11 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalo
* Method: freeAnalogInputPort
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_freeAnalogInputPort
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
freeAnalogInputPort((void*)id);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_freeAnalogInputPort(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
freeAnalogInputPort((void *)id);
}
/*
@@ -57,16 +59,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_freeAnalogInputP
* Method: initializeAnalogOutputPort
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogOutputPort
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
void* analog = initializeAnalogOutputPort((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << analog;
CheckStatus(env, status);
return (jlong)analog;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogOutputPort(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
int32_t status = 0;
void *analog = initializeAnalogOutputPort((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << analog;
CheckStatus(env, status);
return (jlong)analog;
}
/*
@@ -74,11 +76,11 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalo
* Method: freeAnalogOutputPort
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_freeAnalogOutputPort
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
freeAnalogOutputPort((void*)id);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_freeAnalogOutputPort(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
freeAnalogOutputPort((void *)id);
}
/*
@@ -86,13 +88,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_freeAnalogOutput
* Method: checkAnalogModule
* Signature: (B)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogModule
(JNIEnv *, jclass, jbyte value)
{
//ANALOGJNI_LOG(logDEBUG) << "Module = " << (jint)value;
jboolean returnValue = checkAnalogModule( value );
//ANALOGJNI_LOG(logDEBUG) << "checkAnalogModuleResult = " << (jint)returnValue;
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogModule(
JNIEnv *, jclass, jbyte value) {
// ANALOGJNI_LOG(logDEBUG) << "Module = " << (jint)value;
jboolean returnValue = checkAnalogModule(value);
// ANALOGJNI_LOG(logDEBUG) << "checkAnalogModuleResult = " <<
// (jint)returnValue;
return returnValue;
}
/*
@@ -100,13 +103,14 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogM
* Method: checkAnalogInputChannel
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogInputChannel
(JNIEnv *, jclass, jint value)
{
//ANALOGJNI_LOG(logDEBUG) << "Channel = " << value;
jboolean returnValue = checkAnalogInputChannel( value );
//ANALOGJNI_LOG(logDEBUG) << "checkAnalogChannelResult = " << (jint)returnValue;
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogInputChannel(
JNIEnv *, jclass, jint value) {
// ANALOGJNI_LOG(logDEBUG) << "Channel = " << value;
jboolean returnValue = checkAnalogInputChannel(value);
// ANALOGJNI_LOG(logDEBUG) << "checkAnalogChannelResult = " <<
// (jint)returnValue;
return returnValue;
}
/*
@@ -114,13 +118,14 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogI
* Method: checkAnalogOutputChannel
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogOutputChannel
(JNIEnv *, jclass, jint value)
{
//ANALOGJNI_LOG(logDEBUG) << "Channel = " << value;
jboolean returnValue = checkAnalogOutputChannel( value );
//ANALOGJNI_LOG(logDEBUG) << "checkAnalogChannelResult = " << (jint)returnValue;
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogOutputChannel(
JNIEnv *, jclass, jint value) {
// ANALOGJNI_LOG(logDEBUG) << "Channel = " << value;
jboolean returnValue = checkAnalogOutputChannel(value);
// ANALOGJNI_LOG(logDEBUG) << "checkAnalogChannelResult = " <<
// (jint)returnValue;
return returnValue;
}
/*
@@ -128,15 +133,14 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_checkAnalogO
* Method: setAnalogOutput
* Signature: (JD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOutput
(JNIEnv * env, jclass, jlong id, jdouble voltage)
{
ANALOGJNI_LOG(logDEBUG) << "Calling setAnalogOutput";
ANALOGJNI_LOG(logDEBUG) << "Voltage = " << voltage;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
setAnalogOutput((void*)id, voltage, &status);
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOutput(
JNIEnv *env, jclass, jlong id, jdouble voltage) {
ANALOGJNI_LOG(logDEBUG) << "Calling setAnalogOutput";
ANALOGJNI_LOG(logDEBUG) << "Voltage = " << voltage;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
setAnalogOutput((void *)id, voltage, &status);
CheckStatus(env, status);
}
/*
@@ -144,13 +148,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOutput
* Method: getAnalogOutput
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOutput
(JNIEnv * env, jclass, jlong id)
{
int32_t status = 0;
double val = getAnalogOutput((void*)id, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOutput(
JNIEnv *env, jclass, jlong id) {
int32_t status = 0;
double val = getAnalogOutput((void *)id, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -158,14 +162,14 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOutp
* Method: setAnalogSampleRate
* Signature: (D)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogSampleRate
(JNIEnv * env, jclass, jdouble value)
{
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << value;
int32_t status = 0;
setAnalogSampleRate( value, &status );
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogSampleRate(
JNIEnv *env, jclass, jdouble value) {
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << value;
int32_t status = 0;
setAnalogSampleRate(value, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -173,15 +177,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogSampleR
* Method: getAnalogSampleRate
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogSampleRate
(JNIEnv * env, jclass)
{
int32_t status = 0;
double returnValue = getAnalogSampleRate( &status );
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogSampleRate(
JNIEnv *env, jclass) {
int32_t status = 0;
double returnValue = getAnalogSampleRate(&status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "SampleRate = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -189,15 +193,15 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogSamp
* Method: setAnalogAverageBits
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogAverageBits
(JNIEnv * env, jclass, jlong id, jint value)
{
ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << value;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
setAnalogAverageBits((void*)id, value, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogAverageBits(
JNIEnv *env, jclass, jlong id, jint value) {
ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << value;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
setAnalogAverageBits((void *)id, value, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -205,16 +209,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogAverage
* Method: getAnalogAverageBits
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageBits
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getAnalogAverageBits((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageBits(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jint returnValue = getAnalogAverageBits((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AverageBits = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -222,15 +226,15 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverage
* Method: setAnalogOversampleBits
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOversampleBits
(JNIEnv * env, jclass, jlong id, jint value)
{
ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << value;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
setAnalogOversampleBits((void*)id, value, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOversampleBits(
JNIEnv *env, jclass, jlong id, jint value) {
ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << value;
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
setAnalogOversampleBits((void *)id, value, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -238,16 +242,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOversam
* Method: getAnalogOversampleBits
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOversampleBits
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getAnalogOversampleBits((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOversampleBits(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jint returnValue = getAnalogOversampleBits((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -255,16 +259,16 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOversam
* Method: getAnalogValue
* Signature: (J)S
*/
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogValue
(JNIEnv * env, jclass, jlong id)
{
//ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jshort returnValue = getAnalogValue((void*)id, &status);
//ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
//ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jshort JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogValue(
JNIEnv *env, jclass, jlong id) {
// ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jshort returnValue = getAnalogValue((void *)id, &status);
// ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
// ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -272,16 +276,16 @@ JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogValue
* Method: getAnalogAverageValue
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageValue
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getAnalogAverageValue((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AverageValue = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageValue(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jint returnValue = getAnalogAverageValue((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AverageValue = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -289,17 +293,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverage
* Method: getAnalogVoltsToValue
* Signature: (JD)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltsToValue
(JNIEnv * env, jclass, jlong id, jdouble voltageValue)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
ANALOGJNI_LOG(logDEBUG) << "VoltageValue = " << voltageValue;
int32_t status = 0;
jint returnValue = getAnalogVoltsToValue((void*)id, voltageValue, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltsToValue(
JNIEnv *env, jclass, jlong id, jdouble voltageValue) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
ANALOGJNI_LOG(logDEBUG) << "VoltageValue = " << voltageValue;
int32_t status = 0;
jint returnValue = getAnalogVoltsToValue((void *)id, voltageValue, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -307,16 +311,16 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltsTo
* Method: getAnalogVoltage
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltage
(JNIEnv * env, jclass, jlong id)
{
//ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jdouble returnValue = getAnalogVoltage((void*)id, &status);
//ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
//ANALOGJNI_LOG(logDEBUG) << "Voltage = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltage(
JNIEnv *env, jclass, jlong id) {
// ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jdouble returnValue = getAnalogVoltage((void *)id, &status);
// ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
// ANALOGJNI_LOG(logDEBUG) << "Voltage = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -324,16 +328,16 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVolt
* Method: getAnalogAverageVoltage
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageVoltage
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
jdouble returnValue = getAnalogAverageVoltage((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AverageVoltage = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageVoltage(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jdouble returnValue = getAnalogAverageVoltage((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AverageVoltage = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -341,17 +345,17 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAver
* Method: getAnalogLSBWeight
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogLSBWeight
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogLSBWeight(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jint returnValue = getAnalogLSBWeight((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogLSBWeight = " << returnValue;
CheckStatus(env, status);
return returnValue;
jint returnValue = getAnalogLSBWeight((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogLSBWeight = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -359,17 +363,16 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogLSBWeig
* Method: getAnalogOffset
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOffset
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOffset(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jint returnValue = getAnalogOffset((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogOffset = " << returnValue;
CheckStatus(env, status);
return returnValue;
jint returnValue = getAnalogOffset((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogOffset = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -377,18 +380,18 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogOffset
* Method: isAccumulatorChannel
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_isAccumulatorChannel
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "isAccumulatorChannel";
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_isAccumulatorChannel(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "isAccumulatorChannel";
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jboolean returnValue = isAccumulatorChannel((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogOffset = " << returnValue;
CheckStatus(env, status);
return returnValue;
jboolean returnValue = isAccumulatorChannel((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogOffset = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -396,14 +399,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_isAccumulato
* Method: initAccumulator
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initAccumulator
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
initAccumulator((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initAccumulator(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
initAccumulator((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -411,15 +413,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initAccumulator
* Method: resetAccumulator
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_resetAccumulator
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_resetAccumulator(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
resetAccumulator((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
resetAccumulator((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -427,15 +429,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_resetAccumulator
* Method: setAccumulatorCenter
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorCenter
(JNIEnv * env, jclass, jlong id, jint center)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorCenter(
JNIEnv *env, jclass, jlong id, jint center) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
setAccumulatorCenter((void*)id, center, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
setAccumulatorCenter((void *)id, center, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -443,15 +445,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorCe
* Method: setAccumulatorDeadband
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorDeadband
(JNIEnv * env, jclass, jlong id, jint deadband)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorDeadband(
JNIEnv *env, jclass, jlong id, jint deadband) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
setAccumulatorDeadband((void*)id, deadband, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
setAccumulatorDeadband((void *)id, deadband, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -459,18 +461,18 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorDe
* Method: getAccumulatorValue
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorValue
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorValue(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jlong returnValue = getAccumulatorValue((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AccumulatorValue = " << returnValue;
CheckStatus(env, status);
jlong returnValue = getAccumulatorValue((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AccumulatorValue = " << returnValue;
CheckStatus(env, status);
return returnValue;
return returnValue;
}
/*
@@ -478,17 +480,17 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorV
* Method: getAccumulatorCount
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorCount
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorCount(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jint returnValue = getAccumulatorCount((void*)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AccumulatorCount = " << returnValue;
CheckStatus(env, status);
return returnValue;
jint returnValue = getAccumulatorCount((void *)id, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AccumulatorCount = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -496,21 +498,21 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorCo
* Method: getAccumulatorOutput
* Signature: (JLjava/nio/LongBuffer;Ljava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorOutput
(JNIEnv * env, jclass, jlong id, jobject value, jobject count)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void*)id;
int32_t status = 0;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorOutput(
JNIEnv *env, jclass, jlong id, jobject value, jobject count) {
ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << (void *)id;
int32_t status = 0;
jlong * valuePtr = (jlong*)env->GetDirectBufferAddress(value);
uint32_t * countPtr = (uint32_t*)env->GetDirectBufferAddress(count);
jlong *valuePtr = (jlong *)env->GetDirectBufferAddress(value);
uint32_t *countPtr = (uint32_t *)env->GetDirectBufferAddress(count);
getAccumulatorOutput((void*)id, valuePtr, countPtr, &status);
getAccumulatorOutput((void *)id, valuePtr, countPtr, &status);
ANALOGJNI_LOG(logDEBUG) << "Value = " << *valuePtr;
ANALOGJNI_LOG(logDEBUG) << "Count = " << *countPtr;
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
ANALOGJNI_LOG(logDEBUG) << "Value = " << *valuePtr;
ANALOGJNI_LOG(logDEBUG) << "Count = " << *countPtr;
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -518,20 +520,21 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorOu
* Method: initializeAnalogTrigger
* Signature: (JLjava/nio/IntBuffer;)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogTrigger
(JNIEnv * env, jclass, jlong id, jobject index)
{
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogTrigger(
JNIEnv *env, jclass, jlong id, jobject index) {
ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
jint * indexPtr = (jint*)env->GetDirectBufferAddress(index);
ANALOGJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr;
jint *indexPtr = (jint *)env->GetDirectBufferAddress(index);
ANALOGJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr;
int32_t status = 0;
void* analogTrigger = initializeAnalogTrigger((void*)id, (uint32_t *)indexPtr, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogTrigger Ptr = " << analogTrigger;
CheckStatus(env, status);
return (jlong)analogTrigger;
int32_t status = 0;
void *analogTrigger =
initializeAnalogTrigger((void *)id, (uint32_t *)indexPtr, &status);
ANALOGJNI_LOG(logDEBUG) << "Status = " << status;
ANALOGJNI_LOG(logDEBUG) << "AnalogTrigger Ptr = " << analogTrigger;
CheckStatus(env, status);
return (jlong)analogTrigger;
}
/*
@@ -539,14 +542,14 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalo
* Method: cleanAnalogTrigger
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_cleanAnalogTrigger
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_cleanAnalogTrigger(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
cleanAnalogTrigger((void*)id, &status);
CheckStatus(env, status);
int32_t status = 0;
cleanAnalogTrigger((void *)id, &status);
CheckStatus(env, status);
}
/*
@@ -554,14 +557,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_cleanAnalogTrigg
* Method: setAnalogTriggerLimitsRaw
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerLimitsRaw
(JNIEnv * env, jclass, jlong id, jint lower, jint upper)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerLimitsRaw(
JNIEnv *env, jclass, jlong id, jint lower, jint upper) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
setAnalogTriggerLimitsRaw((void*)id, lower, upper, &status);
CheckStatus(env, status);
int32_t status = 0;
setAnalogTriggerLimitsRaw((void *)id, lower, upper, &status);
CheckStatus(env, status);
}
/*
@@ -569,14 +572,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger
* Method: setAnalogTriggerLimitsVoltage
* Signature: (JDD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerLimitsVoltage
(JNIEnv * env, jclass, jlong id, jdouble lower, jdouble upper)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerLimitsVoltage(
JNIEnv *env, jclass, jlong id, jdouble lower, jdouble upper) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
setAnalogTriggerLimitsVoltage((void*)id, lower, upper, &status);
CheckStatus(env, status);
int32_t status = 0;
setAnalogTriggerLimitsVoltage((void *)id, lower, upper, &status);
CheckStatus(env, status);
}
/*
@@ -584,14 +587,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger
* Method: setAnalogTriggerAveraged
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerAveraged
(JNIEnv * env, jclass, jlong id, jboolean averaged)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerAveraged(
JNIEnv *env, jclass, jlong id, jboolean averaged) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
setAnalogTriggerAveraged((void*)id, averaged, &status);
CheckStatus(env, status);
int32_t status = 0;
setAnalogTriggerAveraged((void *)id, averaged, &status);
CheckStatus(env, status);
}
/*
@@ -599,14 +602,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger
* Method: setAnalogTriggerFiltered
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerFiltered
(JNIEnv * env, jclass, jlong id, jboolean filtered)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTriggerFiltered(
JNIEnv *env, jclass, jlong id, jboolean filtered) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
setAnalogTriggerFiltered((void*)id, filtered, &status);
CheckStatus(env, status);
int32_t status = 0;
setAnalogTriggerFiltered((void *)id, filtered, &status);
CheckStatus(env, status);
}
/*
@@ -614,15 +617,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogTrigger
* Method: getAnalogTriggerInWindow
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerInWindow
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerInWindow(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
jboolean val = getAnalogTriggerInWindow((void*)id, &status);
CheckStatus(env, status);
return val;
int32_t status = 0;
jboolean val = getAnalogTriggerInWindow((void *)id, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -630,15 +633,15 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTri
* Method: getAnalogTriggerTriggerState
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerTriggerState
(JNIEnv * env, jclass, jlong id)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerTriggerState(
JNIEnv *env, jclass, jlong id) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
jboolean val = getAnalogTriggerTriggerState((void*)id, &status);
CheckStatus(env, status);
return val;
int32_t status = 0;
jboolean val = getAnalogTriggerTriggerState((void *)id, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -646,15 +649,16 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTri
* Method: getAnalogTriggerOutput
* Signature: (JI)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerOutput
(JNIEnv * env, jclass, jlong id, jint type)
{
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void*)id;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogTriggerOutput(
JNIEnv *env, jclass, jlong id, jint type) {
ANALOGJNI_LOG(logDEBUG) << "Analog Trigger Ptr = " << (void *)id;
int32_t status = 0;
jboolean val = getAnalogTriggerOutput((void*)id, (AnalogTriggerType)type, &status);
CheckStatus(env, status);
return val;
int32_t status = 0;
jboolean val =
getAnalogTriggerOutput((void *)id, (AnalogTriggerType)type, &status);
CheckStatus(env, status);
return val;
}
} // extern "C"

View File

@@ -5,23 +5,25 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_can_CANJNI.h"
#include "HAL/CAN.hpp"
#include "FRC_NetworkCommunication/CANSessionMux.h"
#include "HAL/CAN.hpp"
#include "HALUtil.h"
// set the logging level
//TLogLevel canJNILogLevel = logDEBUG;
// TLogLevel canJNILogLevel = logDEBUG;
TLogLevel canJNILogLevel = logERROR;
#define CANJNI_LOG(level) \
if (level > canJNILogLevel) ; \
else Log().Get(level)
#define CANJNI_LOG(level) \
if (level > canJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -30,42 +32,40 @@ extern "C" {
* Method: FRCNetworkCommunicationCANSessionMuxSendMessage
* Signature: (ILjava/nio/ByteBuffer;I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunicationCANSessionMuxSendMessage
(JNIEnv * env, jclass, jint messageID, jobject data, jint periodMs)
{
CANJNI_LOG(logDEBUG) << "Calling CANJNI FRCNetworkCommunicationCANSessionMuxSendMessage";
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunicationCANSessionMuxSendMessage(
JNIEnv *env, jclass, jint messageID, jobject data, jint periodMs) {
CANJNI_LOG(logDEBUG)
<< "Calling CANJNI FRCNetworkCommunicationCANSessionMuxSendMessage";
uint8_t *dataBuffer = (uint8_t *)(data? env->GetDirectBufferAddress(data) : 0);
uint8_t dataSize = (uint8_t)(data? env->GetDirectBufferCapacity(data) : 0);
uint8_t *dataBuffer =
(uint8_t *)(data ? env->GetDirectBufferAddress(data) : 0);
uint8_t dataSize = (uint8_t)(data ? env->GetDirectBufferCapacity(data) : 0);
CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << messageID;
CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << messageID;
if(logDEBUG <= canJNILogLevel)
{
if(dataBuffer)
{
std::ostringstream str;
str << std::setfill('0') << std::hex;
for(int i = 0; i < dataSize; i++)
{
str << std::setw(2) << (int)dataBuffer[i] << ' ';
}
if (logDEBUG <= canJNILogLevel) {
if (dataBuffer) {
std::ostringstream str;
str << std::setfill('0') << std::hex;
for (int i = 0; i < dataSize; i++) {
str << std::setw(2) << (int)dataBuffer[i] << ' ';
}
Log().Get(logDEBUG) << "Data: " << str.str();
}
else
{
CANJNI_LOG(logDEBUG) << "Data: null";
}
Log().Get(logDEBUG) << "Data: " << str.str();
} else {
CANJNI_LOG(logDEBUG) << "Data: null";
}
}
CANJNI_LOG(logDEBUG) << "Period: " << periodMs;
CANJNI_LOG(logDEBUG) << "Period: " << periodMs;
int32_t status = 0;
FRC_NetworkCommunication_CANSessionMux_sendMessage(messageID, dataBuffer, dataSize, periodMs, &status);
int32_t status = 0;
FRC_NetworkCommunication_CANSessionMux_sendMessage(
messageID, dataBuffer, dataSize, periodMs, &status);
CANJNI_LOG(logDEBUG) << "Status: " << status;
CheckCANStatus(env, status, messageID);
CANJNI_LOG(logDEBUG) << "Status: " << status;
CheckCANStatus(env, status, messageID);
}
static uint8_t buffer[8];
@@ -75,38 +75,39 @@ static uint8_t buffer[8];
* Method: FRCNetworkCommunicationCANSessionMuxReceiveMessage
* Signature: (Ljava/nio/IntBuffer;ILjava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;
*/
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunicationCANSessionMuxReceiveMessage
(JNIEnv * env, jclass, jobject messageID, jint messageIDMask, jobject timeStamp)
{
CANJNI_LOG(logDEBUG) << "Calling CANJNI FRCNetworkCommunicationCANSessionMuxReceiveMessage";
JNIEXPORT jobject JNICALL
Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetworkCommunicationCANSessionMuxReceiveMessage(
JNIEnv *env, jclass, jobject messageID, jint messageIDMask,
jobject timeStamp) {
CANJNI_LOG(logDEBUG)
<< "Calling CANJNI FRCNetworkCommunicationCANSessionMuxReceiveMessage";
uint32_t *messageIDPtr = (uint32_t *)env->GetDirectBufferAddress(messageID);
uint32_t *timeStampPtr = (uint32_t *)env->GetDirectBufferAddress(timeStamp);
uint32_t *messageIDPtr = (uint32_t *)env->GetDirectBufferAddress(messageID);
uint32_t *timeStampPtr = (uint32_t *)env->GetDirectBufferAddress(timeStamp);
uint8_t dataSize = 0;
uint8_t dataSize = 0;
int32_t status = 0;
FRC_NetworkCommunication_CANSessionMux_receiveMessage(messageIDPtr, messageIDMask, buffer, &dataSize, timeStampPtr, &status);
int32_t status = 0;
FRC_NetworkCommunication_CANSessionMux_receiveMessage(
messageIDPtr, messageIDMask, buffer, &dataSize, timeStampPtr, &status);
CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << *messageIDPtr;
CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << *messageIDPtr;
if(logDEBUG <= canJNILogLevel)
{
std::ostringstream str;
str << std::setfill('0') << std::hex;
for(int i = 0; i < dataSize; i++)
{
str << std::setw(2) << (int)buffer[i] << ' ';
}
Log().Get(logDEBUG) << "Data: " << str.str();
if (logDEBUG <= canJNILogLevel) {
std::ostringstream str;
str << std::setfill('0') << std::hex;
for (int i = 0; i < dataSize; i++) {
str << std::setw(2) << (int)buffer[i] << ' ';
}
CANJNI_LOG(logDEBUG) << "Timestamp: " << *timeStampPtr;
CANJNI_LOG(logDEBUG) << "Status: " << status;
Log().Get(logDEBUG) << "Data: " << str.str();
}
if (!CheckCANStatus(env, status, *messageIDPtr)) return nullptr;
return env->NewDirectByteBuffer(buffer, dataSize);
CANJNI_LOG(logDEBUG) << "Timestamp: " << *timeStampPtr;
CANJNI_LOG(logDEBUG) << "Status: " << status;
if (!CheckCANStatus(env, status, *messageIDPtr)) return nullptr;
return env->NewDirectByteBuffer(buffer, dataSize);
}
} // extern "C"

View File

@@ -1,14 +1,14 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_CompressorJNI.h"
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "HAL/HAL.hpp"
#include "HALUtil.h"
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_CompressorJNI.h"
extern "C" {
@@ -17,11 +17,11 @@ extern "C" {
* Method: initializeCompressor
* Signature: (B)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_initializeCompressor
(JNIEnv *env, jclass, jbyte module)
{
void* pcm = initializeCompressor(module);
return (jlong)pcm;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_initializeCompressor(
JNIEnv *env, jclass, jbyte module) {
void *pcm = initializeCompressor(module);
return (jlong)pcm;
}
/*
@@ -29,25 +29,24 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_initializeC
* Method: checkCompressorModule
* Signature: (B)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_checkCompressorModule
(JNIEnv *env, jclass, jbyte module)
{
return checkCompressorModule(module);
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_checkCompressorModule(
JNIEnv *env, jclass, jbyte module) {
return checkCompressorModule(module);
}
/*
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
* Method: getCompressor
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressor((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getCompressor((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -55,12 +54,12 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr
* Method: setClosedLoopControl
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoopControl
(JNIEnv *env, jclass, jlong pcm_pointer, jboolean value)
{
int32_t status = 0;
setClosedLoopControl((void*)pcm_pointer, value, &status);
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoopControl(
JNIEnv *env, jclass, jlong pcm_pointer, jboolean value) {
int32_t status = 0;
setClosedLoopControl((void *)pcm_pointer, value, &status);
CheckStatus(env, status);
}
/*
@@ -68,13 +67,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoo
* Method: getClosedLoopControl
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClosedLoopControl
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getClosedLoopControl((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClosedLoopControl(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getClosedLoopControl((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -82,13 +81,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClose
* Method: getPressureSwitch
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPressureSwitch
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getPressureSwitch((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPressureSwitch(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getPressureSwitch((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -96,13 +95,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPress
* Method: getCompressorCurrent
* Signature: (J)F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrent
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
float val = getCompressorCurrent((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrent(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
float val = getCompressorCurrent((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -110,13 +109,13 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompres
* Method: getCompressorCurrentTooHighFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressorCurrentTooHighFault((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getCompressorCurrentTooHighFault((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -124,13 +123,14 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr
* Method: getCompressorCurrentTooHighStickyFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressorCurrentTooHighStickyFault((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val =
getCompressorCurrentTooHighStickyFault((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -138,13 +138,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr
* Method: getCompressorShortedStickyFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressorShortedStickyFault((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getCompressorShortedStickyFault((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -152,13 +152,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr
* Method: getCompressorShortedFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressorShortedFault((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getCompressorShortedFault((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -166,13 +166,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr
* Method: getCompressorNotConnectedStickyFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressorNotConnectedStickyFault((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getCompressorNotConnectedStickyFault((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -180,25 +180,25 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompr
* Method: getCompressorNotConnectedFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
bool val = getCompressorNotConnectedFault((void*)pcm_pointer, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
bool val = getCompressorNotConnectedFault((void *)pcm_pointer, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
* Method: clearAllPCMStickyFaults
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults
(JNIEnv *env, jclass, jlong pcm_pointer)
{
int32_t status = 0;
clearAllPCMStickyFaults((void*)pcm_pointer, &status);
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults(
JNIEnv *env, jclass, jlong pcm_pointer) {
int32_t status = 0;
clearAllPCMStickyFaults((void *)pcm_pointer, &status);
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_CounterJNI.h"
@@ -18,9 +18,11 @@
// set the logging level
TLogLevel counterJNILogLevel = logWARNING;
#define COUNTERJNI_LOG(level) \
if (level > counterJNILogLevel) ; \
else Log().Get(level)
#define COUNTERJNI_LOG(level) \
if (level > counterJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -29,20 +31,20 @@ extern "C" {
* Method: initializeCounter
* Signature: (ILjava/nio/IntBuffer;)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_initializeCounter
(JNIEnv * env, jclass, jint mode, jobject index)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI initializeCounter";
COUNTERJNI_LOG(logDEBUG) << "Mode = " << mode;
jint * indexPtr = (jint*)env->GetDirectBufferAddress(index);
COUNTERJNI_LOG(logDEBUG) << "Index Ptr = " << (uint32_t*)indexPtr;
int32_t status = 0;
void* counter = initializeCounter((Mode)mode, (uint32_t*)indexPtr, &status);
COUNTERJNI_LOG(logDEBUG) << "Index = " << *indexPtr;
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "COUNTER Ptr = " << counter;
CheckStatus(env, status);
return (jlong)counter;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_initializeCounter(
JNIEnv* env, jclass, jint mode, jobject index) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI initializeCounter";
COUNTERJNI_LOG(logDEBUG) << "Mode = " << mode;
jint* indexPtr = (jint*)env->GetDirectBufferAddress(index);
COUNTERJNI_LOG(logDEBUG) << "Index Ptr = " << (uint32_t*)indexPtr;
int32_t status = 0;
void* counter = initializeCounter((Mode)mode, (uint32_t*)indexPtr, &status);
COUNTERJNI_LOG(logDEBUG) << "Index = " << *indexPtr;
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "COUNTER Ptr = " << counter;
CheckStatus(env, status);
return (jlong)counter;
}
/*
@@ -50,15 +52,14 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_initializeCoun
* Method: freeCounter
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_freeCounter
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI freeCounter";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
freeCounter((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_freeCounter(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI freeCounter";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
freeCounter((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -66,16 +67,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_freeCounter
* Method: setCounterAverageSize
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterAverageSize
(JNIEnv * env, jclass, jlong id, jint value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterAverageSize";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "AverageSize = " << value;
int32_t status = 0;
setCounterAverageSize((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterAverageSize(
JNIEnv* env, jclass, jlong id, jint value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterAverageSize";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "AverageSize = " << value;
int32_t status = 0;
setCounterAverageSize((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -83,17 +84,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterAvera
* Method: setCounterUpSource
* Signature: (JIZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSource
(JNIEnv * env, jclass, jlong id, jint pin, jboolean analogTrigger)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Pin = " << pin;
COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger;
int32_t status = 0;
setCounterUpSource((void*)id, pin, analogTrigger, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSource(
JNIEnv* env, jclass, jlong id, jint pin, jboolean analogTrigger) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Pin = " << pin;
COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger;
int32_t status = 0;
setCounterUpSource((void*)id, pin, analogTrigger, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -101,17 +102,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSou
* Method: setCounterUpSourceEdge
* Signature: (JZZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSourceEdge
(JNIEnv * env, jclass, jlong id, jboolean valueRise, jboolean valueFall)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpSourceEdge";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Rise = " << (jint)valueRise;
COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall;
int32_t status = 0;
setCounterUpSourceEdge((void*)id, valueRise, valueFall, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSourceEdge(
JNIEnv* env, jclass, jlong id, jboolean valueRise, jboolean valueFall) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpSourceEdge";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Rise = " << (jint)valueRise;
COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall;
int32_t status = 0;
setCounterUpSourceEdge((void*)id, valueRise, valueFall, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -119,15 +120,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpSou
* Method: clearCounterUpSource
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterUpSource
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI clearCounterUpSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
clearCounterUpSource((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterUpSource(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI clearCounterUpSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
clearCounterUpSource((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -135,21 +136,23 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterUpS
* Method: setCounterDownSource
* Signature: (JIZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownSource
(JNIEnv * env, jclass, jlong id, jint pin, jboolean analogTrigger)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterDownSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Pin = " << pin;
COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger;
int32_t status = 0;
setCounterDownSource((void*)id, pin, analogTrigger, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
if (status == PARAMETER_OUT_OF_RANGE) {
ThrowIllegalArgumentException(env, "Counter only supports DownSource in TwoPulse and ExternalDirection modes.");
return;
}
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownSource(
JNIEnv* env, jclass, jlong id, jint pin, jboolean analogTrigger) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterDownSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Pin = " << pin;
COUNTERJNI_LOG(logDEBUG) << "AnalogTrigger = " << (jint)analogTrigger;
int32_t status = 0;
setCounterDownSource((void*)id, pin, analogTrigger, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
if (status == PARAMETER_OUT_OF_RANGE) {
ThrowIllegalArgumentException(env,
"Counter only supports DownSource in "
"TwoPulse and ExternalDirection modes.");
return;
}
CheckStatus(env, status);
}
/*
@@ -157,17 +160,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownS
* Method: setCounterDownSourceEdge
* Signature: (JZZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownSourceEdge
(JNIEnv * env, jclass, jlong id, jboolean valueRise, jboolean valueFall)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterDownSourceEdge";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Rise = " << (jint)valueRise;
COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall;
int32_t status = 0;
setCounterDownSourceEdge((void*)id, valueRise, valueFall, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownSourceEdge(
JNIEnv* env, jclass, jlong id, jboolean valueRise, jboolean valueFall) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterDownSourceEdge";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "Rise = " << (jint)valueRise;
COUNTERJNI_LOG(logDEBUG) << "Fall = " << (jint)valueFall;
int32_t status = 0;
setCounterDownSourceEdge((void*)id, valueRise, valueFall, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -175,15 +178,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterDownS
* Method: clearCounterDownSource
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterDownSource
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI clearCounterDownSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
clearCounterDownSource((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterDownSource(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI clearCounterDownSource";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
clearCounterDownSource((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -191,15 +194,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_clearCounterDow
* Method: setCounterUpDownMode
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpDownMode
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpDownMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
setCounterUpDownMode((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpDownMode(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterUpDownMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
setCounterUpDownMode((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -207,15 +210,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpDow
* Method: setCounterExternalDirectionMode
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterExternalDirectionMode
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterExternalDirectionMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
setCounterExternalDirectionMode((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterExternalDirectionMode(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG)
<< "Calling COUNTERJNI setCounterExternalDirectionMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
setCounterExternalDirectionMode((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -223,16 +227,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterExter
* Method: setCounterSemiPeriodMode
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSemiPeriodMode
(JNIEnv * env, jclass, jlong id, jboolean value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterSemiPeriodMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "SemiPeriodMode = " << (jint)value;
int32_t status = 0;
setCounterSemiPeriodMode((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSemiPeriodMode(
JNIEnv* env, jclass, jlong id, jboolean value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterSemiPeriodMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "SemiPeriodMode = " << (jint)value;
int32_t status = 0;
setCounterSemiPeriodMode((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -240,16 +244,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSemiP
* Method: setCounterPulseLengthMode
* Signature: (JD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterPulseLengthMode
(JNIEnv * env, jclass, jlong id, jdouble value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterPulseLengthMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "PulseLengthMode = " << value;
int32_t status = 0;
setCounterPulseLengthMode((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterPulseLengthMode(
JNIEnv* env, jclass, jlong id, jdouble value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterPulseLengthMode";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "PulseLengthMode = " << value;
int32_t status = 0;
setCounterPulseLengthMode((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -257,17 +261,18 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterPulse
* Method: getCounterSamplesToAverage
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterSamplesToAverage
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterSamplesToAverage";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getCounterSamplesToAverage((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterSamplesToAverageResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterSamplesToAverage(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterSamplesToAverage";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getCounterSamplesToAverage((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterSamplesToAverageResult = "
<< returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -275,20 +280,20 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterSampl
* Method: setCounterSamplesToAverage
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSamplesToAverage
(JNIEnv * env, jclass, jlong id, jint value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterSamplesToAverage";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "SamplesToAverage = " << value;
int32_t status = 0;
setCounterSamplesToAverage((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
if (status == PARAMETER_OUT_OF_RANGE) {
ThrowBoundaryException(env, value, 1, 127);
return;
}
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSamplesToAverage(
JNIEnv* env, jclass, jlong id, jint value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterSamplesToAverage";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "SamplesToAverage = " << value;
int32_t status = 0;
setCounterSamplesToAverage((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
if (status == PARAMETER_OUT_OF_RANGE) {
ThrowBoundaryException(env, value, 1, 127);
return;
}
CheckStatus(env, status);
}
/*
@@ -296,15 +301,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterSampl
* Method: resetCounter
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_resetCounter
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI resetCounter";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
resetCounter((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_resetCounter(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI resetCounter";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
resetCounter((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -312,17 +316,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_resetCounter
* Method: getCounter
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounter
(JNIEnv * env, jclass, jlong id)
{
//COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounter";
//COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getCounter((void*)id, &status);
//COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
//COUNTERJNI_LOG(logDEBUG) << "getCounterResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounter(
JNIEnv* env, jclass, jlong id) {
// COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounter";
// COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getCounter((void*)id, &status);
// COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
// COUNTERJNI_LOG(logDEBUG) << "getCounterResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -330,17 +333,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounter
* Method: getCounterPeriod
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterPeriod
(JNIEnv *env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterPeriod";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jdouble returnValue = getCounterPeriod((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterPeriodResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterPeriod(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterPeriod";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jdouble returnValue = getCounterPeriod((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterPeriodResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -348,16 +351,16 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterPe
* Method: setCounterMaxPeriod
* Signature: (JD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterMaxPeriod
(JNIEnv * env, jclass, jlong id, jdouble value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterMaxPeriod";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "MaxPeriod = " << value;
int32_t status = 0;
setCounterMaxPeriod((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterMaxPeriod(
JNIEnv* env, jclass, jlong id, jdouble value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterMaxPeriod";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "MaxPeriod = " << value;
int32_t status = 0;
setCounterMaxPeriod((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -365,16 +368,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterMaxPe
* Method: setCounterUpdateWhenEmpty
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpdateWhenEmpty
(JNIEnv * env, jclass, jlong id, jboolean value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterMaxPeriod";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "UpdateWhenEmpty = " << (jint)value;
int32_t status = 0;
setCounterUpdateWhenEmpty((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpdateWhenEmpty(
JNIEnv* env, jclass, jlong id, jboolean value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterMaxPeriod";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "UpdateWhenEmpty = " << (jint)value;
int32_t status = 0;
setCounterUpdateWhenEmpty((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -382,17 +385,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterUpdat
* Method: getCounterStopped
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterStopped
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterStopped";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getCounterStopped((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterStoppedResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterStopped(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterStopped";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getCounterStopped((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterStoppedResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -400,17 +403,18 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterS
* Method: getCounterDirection
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterDirection
(JNIEnv * env, jclass, jlong id)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterDirection";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getCounterDirection((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterDirectionResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterDirection(
JNIEnv* env, jclass, jlong id) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounterDirection";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getCounterDirection((void*)id, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
COUNTERJNI_LOG(logDEBUG) << "getCounterDirectionResult = "
<< (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -418,16 +422,16 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounterD
* Method: setCounterReverseDirection
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterReverseDirection
(JNIEnv * env, jclass, jlong id, jboolean value)
{
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterReverseDirection";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "ReverseDirection = " << (jint)value;
int32_t status = 0;
setCounterReverseDirection((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_CounterJNI_setCounterReverseDirection(
JNIEnv* env, jclass, jlong id, jboolean value) {
COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI setCounterReverseDirection";
COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
COUNTERJNI_LOG(logDEBUG) << "ReverseDirection = " << (jint)value;
int32_t status = 0;
setCounterReverseDirection((void*)id, value, &status);
COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_DIOJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel dioJNILogLevel = logWARNING;
#define DIOJNI_LOG(level) \
if (level > dioJNILogLevel) ; \
else Log().Get(level)
#define DIOJNI_LOG(level) \
if (level > dioJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,17 +30,17 @@ extern "C" {
* Method: initializeDigitalPort
* Signature: (J)J;
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_initializeDigitalPort
(JNIEnv * env, jclass, jlong id)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI initializeDigitalPort";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
void* dio = initializeDigitalPort((void*)id, &status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "DIO Ptr = " << dio;
CheckStatus(env, status);
return (jlong)dio;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_initializeDigitalPort(
JNIEnv *env, jclass, jlong id) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI initializeDigitalPort";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
int32_t status = 0;
void *dio = initializeDigitalPort((void *)id, &status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "DIO Ptr = " << dio;
CheckStatus(env, status);
return (jlong)dio;
}
/*
@@ -46,12 +48,11 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_initializeDigitalP
* Method: freeDigitalPort
* Signature: (J)V;
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDigitalPort
(JNIEnv * env, jclass, jlong id)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI freeDigitalPort";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
freeDigitalPort((void*)id);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDigitalPort(
JNIEnv *env, jclass, jlong id) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI freeDigitalPort";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
freeDigitalPort((void *)id);
}
/*
@@ -59,17 +60,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDigitalPort
* Method: allocateDIO
* Signature: (JZ)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO
(JNIEnv * env, jclass, jlong id, jboolean value)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI allocateDIO";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = allocateDIO((void*)id, value, &status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO(
JNIEnv *env, jclass, jlong id, jboolean value) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI allocateDIO";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
int32_t status = 0;
jboolean returnValue = allocateDIO((void *)id, value, &status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -77,15 +77,14 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO
* Method: freeDIO
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDIO
(JNIEnv * env, jclass, jlong id)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI freeDIO";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
freeDIO((void*)id, &status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDIO(JNIEnv *env, jclass, jlong id) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI freeDIO";
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
int32_t status = 0;
freeDIO((void *)id, &status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -93,16 +92,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDIO
* Method: setDIO
* Signature: (JS)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO
(JNIEnv *env, jclass, jlong id, jshort value)
{
//DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO";
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
//DIOJNI_LOG(logDEBUG) << "Value = " << value;
int32_t status = 0;
setDIO((void*)id, value, &status);
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO(
JNIEnv *env, jclass, jlong id, jshort value) {
// DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO";
// DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
// DIOJNI_LOG(logDEBUG) << "Value = " << value;
int32_t status = 0;
setDIO((void *)id, value, &status);
// DIOJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -110,18 +108,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO
* Method: getDIO
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO
(JNIEnv * env, jclass, jlong id)
{
//DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIO";
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getDIO((void*)id, &status);
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
//DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO(JNIEnv *env, jclass, jlong id) {
// DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIO";
// DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getDIO((void *)id, &status);
// DIOJNI_LOG(logDEBUG) << "Status = " << status;
// DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -129,17 +125,17 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO
* Method: getDIODirection
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIODirection
(JNIEnv *env, jclass, jlong id)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIODirection (RR upd)";
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getDIODirection((void*)id, &status);
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "getDIODirectionResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIODirection(
JNIEnv *env, jclass, jlong id) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIODirection (RR upd)";
// DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getDIODirection((void *)id, &status);
// DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "getDIODirectionResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -147,16 +143,15 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIODirection
* Method: pulse
* Signature: (JD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_pulse
(JNIEnv *env, jclass, jlong id, jdouble value)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI pulse (RR upd)";
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
//DIOJNI_LOG(logDEBUG) << "Value = " << value;
int32_t status = 0;
pulse((void*)id, value, &status);
DIOJNI_LOG(logDEBUG) << "Did it work? Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_pulse(
JNIEnv *env, jclass, jlong id, jdouble value) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI pulse (RR upd)";
// DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
// DIOJNI_LOG(logDEBUG) << "Value = " << value;
int32_t status = 0;
pulse((void *)id, value, &status);
DIOJNI_LOG(logDEBUG) << "Did it work? Status = " << status;
CheckStatus(env, status);
}
/*
@@ -164,19 +159,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_pulse
* Method: isPulsing
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isPulsing
(JNIEnv *env, jclass, jlong id)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isPulsing (RR upd)";
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = isPulsing((void*)id, &status);
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "isPulsingResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_isPulsing(JNIEnv *env, jclass, jlong id) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isPulsing (RR upd)";
// DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = isPulsing((void *)id, &status);
// DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "isPulsingResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -184,16 +176,15 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isPulsing
* Method: isAnyPulsing
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsing
(JNIEnv *env, jclass)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isAnyPulsing (RR upd)";
int32_t status = 0;
jboolean returnValue = isAnyPulsing( &status );
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "isAnyPulsingResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsing(JNIEnv *env, jclass) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isAnyPulsing (RR upd)";
int32_t status = 0;
jboolean returnValue = isAnyPulsing(&status);
// DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "isAnyPulsingResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -201,17 +192,15 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsing
* Method: getLoopTiming
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming
(JNIEnv * env, jclass)
{
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing";
int32_t status = 0;
jshort returnValue = getLoopTiming( &status );
DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jshort JNICALL
Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming(JNIEnv *env, jclass) {
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing";
int32_t status = 0;
jshort returnValue = getLoopTiming(&status);
DIOJNI_LOG(logDEBUG) << "Status = " << status;
DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
} // extern "C"

View File

@@ -15,9 +15,9 @@
* Class: edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI
* Method: setFilterSelect
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_setFilterSelect
(JNIEnv* env, jclass, jlong port_pointer, jint filter_index)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_setFilterSelect(
JNIEnv* env, jclass, jlong port_pointer, jint filter_index) {
int32_t status = 0;
void* digital_port_pointer = reinterpret_cast<void*>(port_pointer);
@@ -29,9 +29,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_set
* Class: edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI
* Method: getFilterSelect
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_getFilterSelect
(JNIEnv *env, jclass, jlong port_pointer)
{
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_getFilterSelect(
JNIEnv* env, jclass, jlong port_pointer) {
int32_t status = 0;
void* digital_port_pointer = reinterpret_cast<void*>(port_pointer);
@@ -44,9 +44,9 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_get
* Class: edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI
* Method: setFilterPeriod
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_setFilterPeriod
(JNIEnv *env, jclass, jint filter_index, jint fpga_cycles)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_setFilterPeriod(
JNIEnv* env, jclass, jint filter_index, jint fpga_cycles) {
int32_t status = 0;
setFilterPeriod(filter_index, fpga_cycles, &status);
@@ -57,9 +57,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_set
* Class: edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI
* Method: getFilterPeriod
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_getFilterPeriod
(JNIEnv *env, jclass, jint filter_index)
{
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_DigitalGlitchFilterJNI_getFilterPeriod(
JNIEnv* env, jclass, jint filter_index) {
int32_t status = 0;
jint result = getFilterPeriod(filter_index, &status);

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_EncoderJNI.h"
@@ -18,9 +18,11 @@
// set the logging level
TLogLevel encoderJNILogLevel = logWARNING;
#define ENCODERJNI_LOG(level) \
if (level > encoderJNILogLevel) ; \
else Log().Get(level)
#define ENCODERJNI_LOG(level) \
if (level > encoderJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -29,29 +31,33 @@ extern "C" {
* Method: initializeEncoder
* Signature: (BIZBIZZLjava/nio/IntBuffer;)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEncoder
(JNIEnv * env, jclass, jbyte port_a_module, jint port_a_pin, jboolean port_a_analog_trigger, jbyte port_b_module, jint port_b_pin, jboolean port_b_analog_trigger, jboolean reverseDirection, jobject index)
{
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;
int32_t status = 0;
void* encoder = initializeEncoder(port_a_module, port_a_pin, port_a_analog_trigger,
port_b_module, port_b_pin, port_b_analog_trigger,
reverseDirection, indexPtr, &status);
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEncoder(
JNIEnv* env, jclass, jbyte port_a_module, jint port_a_pin,
jboolean port_a_analog_trigger, jbyte port_b_module, jint port_b_pin,
jboolean port_b_analog_trigger, jboolean reverseDirection, jobject index) {
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;
int32_t status = 0;
void* encoder = initializeEncoder(
port_a_module, port_a_pin, port_a_analog_trigger, port_b_module,
port_b_pin, port_b_analog_trigger, reverseDirection, indexPtr, &status);
ENCODERJNI_LOG(logDEBUG) << "Index = " << *indexPtr;
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "ENCODER Ptr = " << encoder;
CheckStatus(env, status);
return (jlong)encoder;
ENCODERJNI_LOG(logDEBUG) << "Index = " << *indexPtr;
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "ENCODER Ptr = " << encoder;
CheckStatus(env, status);
return (jlong)encoder;
}
/*
@@ -59,15 +65,14 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEnco
* Method: freeEncoder
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI freeEncoder";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
freeEncoder((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI freeEncoder";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
freeEncoder((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -75,15 +80,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder
* Method: resetEncoder
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_resetEncoder
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI resetEncoder";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
resetEncoder((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_resetEncoder(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI resetEncoder";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
resetEncoder((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -91,17 +95,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_resetEncoder
* Method: getEncoder
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoder";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getEncoder((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoder";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getEncoder((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -109,17 +112,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder
* Method: getEncoderPeriod
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderPeriod
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderPeriod";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
double returnValue = getEncoderPeriod((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderPeriodResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderPeriod(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderPeriod";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
double returnValue = getEncoderPeriod((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderPeriodResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -127,15 +130,15 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderPe
* Method: setEncoderMaxPeriod
* Signature: (JD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPeriod
(JNIEnv * env, jclass, jlong id, jdouble value)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderMaxPeriod";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
setEncoderMaxPeriod((void*)id, value, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPeriod(
JNIEnv* env, jclass, jlong id, jdouble value) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderMaxPeriod";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
setEncoderMaxPeriod((void*)id, value, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -143,17 +146,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPe
* Method: getEncoderStopped
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderStopped
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderStopped";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getEncoderStopped((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderStoppedResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderStopped(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderStopped";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getEncoderStopped((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderStoppedResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -161,17 +164,17 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderS
* Method: getEncoderDirection
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderDirection
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderDirection";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getEncoderDirection((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderDirectionResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderDirection(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderDirection";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getEncoderDirection((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderDirectionResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -179,15 +182,15 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderD
* Method: setEncoderReverseDirection
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderReverseDirection
(JNIEnv * env, jclass, jlong id, jboolean value)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderReverseDirection";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
setEncoderReverseDirection((void*)id, value, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderReverseDirection(
JNIEnv* env, jclass, jlong id, jboolean value) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderReverseDirection";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
setEncoderReverseDirection((void*)id, value, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -195,19 +198,19 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderRever
* Method: setEncoderSamplesToAverage
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderSamplesToAverage
(JNIEnv * env, jclass, jlong id, jint value)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderSamplesToAverage";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
setEncoderSamplesToAverage((void*)id, value, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
if (status == PARAMETER_OUT_OF_RANGE) {
ThrowBoundaryException(env, value, 1, 127);
return;
}
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderSamplesToAverage(
JNIEnv* env, jclass, jlong id, jint value) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderSamplesToAverage";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
setEncoderSamplesToAverage((void*)id, value, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
if (status == PARAMETER_OUT_OF_RANGE) {
ThrowBoundaryException(env, value, 1, 127);
return;
}
CheckStatus(env, status);
}
/*
@@ -215,17 +218,18 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderSampl
* Method: getEncoderSamplesToAverage
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSamplesToAverage
(JNIEnv * env, jclass, jlong id)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderSamplesToAverage";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getEncoderSamplesToAverage((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSamplesToAverage(
JNIEnv* env, jclass, jlong id) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderSamplesToAverage";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
int32_t status = 0;
jint returnValue = getEncoderSamplesToAverage((void*)id, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = "
<< returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -233,19 +237,24 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSampl
* Method: setEncoderIndexSource
* Signature: (JIZZZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderIndexSource
(JNIEnv * env, jclass, jlong id, jint pin, jboolean analogTrigger, jboolean activeHigh, jboolean edgeSensitive)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderIndexSource";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
ENCODERJNI_LOG(logDEBUG) << "Pin = " << pin;
ENCODERJNI_LOG(logDEBUG) << "Analog Trigger = " << (analogTrigger?"true":"false");
ENCODERJNI_LOG(logDEBUG) << "Active High = " << (activeHigh?"true":"false");
ENCODERJNI_LOG(logDEBUG) << "Edge Sensitive = " << (edgeSensitive?"true":"false");
int32_t status = 0;
setEncoderIndexSource((void*)id, pin, analogTrigger, activeHigh, edgeSensitive, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderIndexSource(
JNIEnv* env, jclass, jlong id, jint pin, jboolean analogTrigger,
jboolean activeHigh, jboolean edgeSensitive) {
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderIndexSource";
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
ENCODERJNI_LOG(logDEBUG) << "Pin = " << pin;
ENCODERJNI_LOG(logDEBUG) << "Analog Trigger = "
<< (analogTrigger ? "true" : "false");
ENCODERJNI_LOG(logDEBUG) << "Active High = "
<< (activeHigh ? "true" : "false");
ENCODERJNI_LOG(logDEBUG) << "Edge Sensitive = "
<< (edgeSensitive ? "true" : "false");
int32_t status = 0;
setEncoderIndexSource((void*)id, pin, analogTrigger, activeHigh,
edgeSensitive, &status);
ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -5,12 +5,12 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary.h"
#include "HAL/HAL.hpp"
#include "edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary.h"
//#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HALUtil.h"
@@ -18,330 +18,342 @@
// set the logging level
TLogLevel netCommLogLevel = logWARNING;
#define NETCOMM_LOG(level) \
if (level > netCommLogLevel) ; \
else Log().Get(level)
#define NETCOMM_LOG(level) \
if (level > netCommLogLevel) \
; \
else \
Log().Get(level)
extern "C" {
/*
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
* 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)
{
const char * featureStr = paramEnv->GetStringUTFChars(paramFeature, NULL);
NETCOMM_LOG(logDEBUG) << "Calling FRCNetworkCommunicationsLibrary report " << "res:"<< (unsigned int)paramResource << " instance:" << (unsigned int)paramInstanceNumber << " context:" << (unsigned int)paramContext << " feature:" << featureStr;
jint returnValue = HALReport(paramResource, paramInstanceNumber, paramContext, featureStr);
paramEnv->ReleaseStringUTFChars(paramFeature,featureStr);
return returnValue;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationUsageReportingReport(
JNIEnv *paramEnv, jclass, jbyte paramResource, jbyte paramInstanceNumber,
jbyte paramContext, jstring paramFeature) {
const char *featureStr = paramEnv->GetStringUTFChars(paramFeature, NULL);
NETCOMM_LOG(logDEBUG) << "Calling FRCNetworkCommunicationsLibrary report "
<< "res:" << (unsigned int)paramResource
<< " instance:" << (unsigned int)paramInstanceNumber
<< " context:" << (unsigned int)paramContext
<< " feature:" << featureStr;
jint returnValue =
HALReport(paramResource, paramInstanceNumber, paramContext, featureStr);
paramEnv->ReleaseStringUTFChars(paramFeature, featureStr);
return returnValue;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
* 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();
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramStarting(
JNIEnv *, jclass) {
HALNetworkCommunicationObserveUserProgramStarting();
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
* 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();
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramDisabled(
JNIEnv *, jclass) {
HALNetworkCommunicationObserveUserProgramDisabled();
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
* 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();
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramAutonomous(
JNIEnv *, jclass) {
HALNetworkCommunicationObserveUserProgramAutonomous();
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
* 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();
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramTeleop(
JNIEnv *, jclass) {
HALNetworkCommunicationObserveUserProgramTeleop();
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
* 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();
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramTest(
JNIEnv *, jclass) {
HALNetworkCommunicationObserveUserProgramTest();
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: FRCNetworkCommunicationReserve
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationReserve
(JNIEnv *, jclass)
{
int rv = HALInitialize(0);
assert(1 == rv);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationReserve(
JNIEnv *, jclass) {
int rv = HALInitialize(0);
assert(1 == rv);
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: NativeHALGetControlWord
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeHALGetControlWord
(JNIEnv *, jclass)
{
NETCOMM_LOG(logDEBUG) << "Calling HAL Control Word";
jint controlWord;
HALGetControlWord((HALControlWord*)&controlWord);
return controlWord;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeHALGetControlWord(
JNIEnv *, jclass) {
NETCOMM_LOG(logDEBUG) << "Calling HAL Control Word";
jint controlWord;
HALGetControlWord((HALControlWord *)&controlWord);
return controlWord;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: NativeHALGetAllianceStation
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeHALGetAllianceStation
(JNIEnv *, jclass)
{
NETCOMM_LOG(logDEBUG) << "Calling HAL Alliance Station";
jint allianceStation;
HALGetAllianceStation((HALAllianceStationID*)&allianceStation);
return allianceStation;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeHALGetAllianceStation(
JNIEnv *, jclass) {
NETCOMM_LOG(logDEBUG) << "Calling HAL Alliance Station";
jint allianceStation;
HALGetAllianceStation((HALAllianceStationID *)&allianceStation);
return allianceStation;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickAxes
* Signature: (B)[S
*/
JNIEXPORT jshortArray JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxes
(JNIEnv * env, jclass, jbyte joystickNum)
{
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickAxes";
HALJoystickAxes axes;
HALGetJoystickAxes(joystickNum, &axes);
JNIEXPORT jshortArray JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxes(
JNIEnv *env, jclass, jbyte joystickNum) {
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickAxes";
HALJoystickAxes axes;
HALGetJoystickAxes(joystickNum, &axes);
jshortArray axesArray = env->NewShortArray(axes.count);
env->SetShortArrayRegion(axesArray, 0, axes.count, axes.axes);
jshortArray axesArray = env->NewShortArray(axes.count);
env->SetShortArrayRegion(axesArray, 0, axes.count, axes.axes);
return axesArray;
return axesArray;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickPOVs
* Signature: (B)[S
*/
JNIEXPORT jshortArray JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickPOVs
(JNIEnv * env, jclass, jbyte joystickNum)
{
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickPOVs";
HALJoystickPOVs povs;
HALGetJoystickPOVs(joystickNum, &povs);
JNIEXPORT jshortArray JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickPOVs(
JNIEnv *env, jclass, jbyte joystickNum) {
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickPOVs";
HALJoystickPOVs povs;
HALGetJoystickPOVs(joystickNum, &povs);
jshortArray povsArray = env->NewShortArray(povs.count);
env->SetShortArrayRegion(povsArray, 0, povs.count, povs.povs);
jshortArray povsArray = env->NewShortArray(povs.count);
env->SetShortArrayRegion(povsArray, 0, povs.count, povs.povs);
return povsArray;
return povsArray;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickButtons
* Signature: (B)S
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickButtons
(JNIEnv * env, jclass, jbyte joystickNum, jobject count)
{
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickButtons";
HALJoystickButtons joystickButtons;
HALGetJoystickButtons(joystickNum, &joystickButtons);
jbyte *countPtr = (jbyte*)env->GetDirectBufferAddress(count);
NETCOMM_LOG(logDEBUG) << "Buttons = " << joystickButtons.buttons;
NETCOMM_LOG(logDEBUG) << "Count = " << (jint)joystickButtons.count;
*countPtr = joystickButtons.count;
NETCOMM_LOG(logDEBUG) << "CountBuffer = " << (jint)*countPtr;
return joystickButtons.buttons;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickButtons(
JNIEnv *env, jclass, jbyte joystickNum, jobject count) {
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickButtons";
HALJoystickButtons joystickButtons;
HALGetJoystickButtons(joystickNum, &joystickButtons);
jbyte *countPtr = (jbyte *)env->GetDirectBufferAddress(count);
NETCOMM_LOG(logDEBUG) << "Buttons = " << joystickButtons.buttons;
NETCOMM_LOG(logDEBUG) << "Count = " << (jint)joystickButtons.count;
*countPtr = joystickButtons.count;
NETCOMM_LOG(logDEBUG) << "CountBuffer = " << (jint)*countPtr;
return joystickButtons.buttons;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALSetJoystickOutputs
* Signature: (BISS)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSetJoystickOutputs
(JNIEnv *, jclass, jbyte port, jint outputs, jshort leftRumble, jshort rightRumble)
{
NETCOMM_LOG(logDEBUG) << "Calling HALSetJoystickOutputs on port " << port;
NETCOMM_LOG(logDEBUG) << "Outputs: " << outputs;
NETCOMM_LOG(logDEBUG) << "Left Rumble: " << leftRumble << " Right Rumble: " << rightRumble;
return HALSetJoystickOutputs(port, outputs, leftRumble, rightRumble);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSetJoystickOutputs(
JNIEnv *, jclass, jbyte port, jint outputs, jshort leftRumble,
jshort rightRumble) {
NETCOMM_LOG(logDEBUG) << "Calling HALSetJoystickOutputs on port " << port;
NETCOMM_LOG(logDEBUG) << "Outputs: " << outputs;
NETCOMM_LOG(logDEBUG) << "Left Rumble: " << leftRumble
<< " Right Rumble: " << rightRumble;
return HALSetJoystickOutputs(port, outputs, leftRumble, rightRumble);
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickIsXbox
* Signature: (B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickIsXbox
(JNIEnv *, jclass, jbyte port)
{
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickIsXbox";
return HALGetJoystickIsXbox(port);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickIsXbox(
JNIEnv *, jclass, jbyte port) {
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickIsXbox";
return HALGetJoystickIsXbox(port);
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickType
* Signature: (B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickType
(JNIEnv *, jclass, jbyte port)
{
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickType";
return HALGetJoystickType(port);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickType(
JNIEnv *, jclass, jbyte port) {
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickType";
return HALGetJoystickType(port);
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickName
* Signature: (B)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickName
(JNIEnv * env, jclass, jbyte port)
{
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickName";
char* joystickName = HALGetJoystickName(port);
jstring str = env->NewStringUTF(joystickName);
std::free(joystickName);
return str;
}
JNIEXPORT jstring JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickName(
JNIEnv *env, jclass, jbyte port) {
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickName";
char *joystickName = HALGetJoystickName(port);
jstring str = env->NewStringUTF(joystickName);
std::free(joystickName);
return str;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetJoystickAxisType
* Signature: (BB)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxisType
(JNIEnv *, jclass, jbyte joystickNum, jbyte axis)
{
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickAxisType";
return HALGetJoystickAxisType(joystickNum, axis);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxisType(
JNIEnv *, jclass, jbyte joystickNum, jbyte axis) {
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickAxisType";
return HALGetJoystickAxisType(joystickNum, axis);
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: setNewDataSem
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setNewDataSem
(JNIEnv * env, jclass, jlong id )
{
NETCOMM_LOG(logDEBUG) << "Mutex Ptr = " << (void*)id;
HALSetNewDataSem((MULTIWAIT_ID)id);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setNewDataSem(
JNIEnv *env, jclass, jlong id) {
NETCOMM_LOG(logDEBUG) << "Mutex Ptr = " << (void *)id;
HALSetNewDataSem((MULTIWAIT_ID)id);
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetMatchTime
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetMatchTime
(JNIEnv * env, jclass)
{
jfloat matchTime;
HALGetMatchTime((float*)&matchTime);
return matchTime;
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetMatchTime(
JNIEnv *env, jclass) {
jfloat matchTime;
HALGetMatchTime((float *)&matchTime);
return matchTime;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetSystemActive
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetSystemActive
(JNIEnv * env, jclass)
{
int32_t status = 0;
bool val = HALGetSystemActive(&status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetSystemActive(
JNIEnv *env, jclass) {
int32_t status = 0;
bool val = HALGetSystemActive(&status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALGetBrownedOut
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetBrownedOut
(JNIEnv * env, jclass)
{
int32_t status = 0;
bool val = HALGetBrownedOut(&status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetBrownedOut(
JNIEnv *env, jclass) {
int32_t status = 0;
bool val = HALGetBrownedOut(&status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALSetErrorData
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSetErrorData
(JNIEnv * env, jclass, jstring error)
{
const char * errorStr = env->GetStringUTFChars(error, NULL);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSetErrorData(
JNIEnv *env, jclass, jstring error) {
const char *errorStr = env->GetStringUTFChars(error, NULL);
jsize length = env->GetStringUTFLength(error);
NETCOMM_LOG(logDEBUG) << "Set Error: " << errorStr;
NETCOMM_LOG(logDEBUG) << "Length: " << length;
jint returnValue = HALSetErrorData(errorStr, (jint) length, 0);
env->ReleaseStringUTFChars(error,errorStr);
jint returnValue = HALSetErrorData(errorStr, (jint)length, 0);
env->ReleaseStringUTFChars(error, errorStr);
return returnValue;
}
/*
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
* Method: HALSendError
* Signature: (ZIZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSendError
(JNIEnv * env, jclass, jboolean isError, jint errorCode, jboolean isLVCode, jstring details, jstring location, jstring callStack, jboolean printMsg)
{
const char * detailsStr = env->GetStringUTFChars(details, NULL);
const char * locationStr = env->GetStringUTFChars(location, NULL);
const char * callStackStr = env->GetStringUTFChars(callStack, NULL);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSendError(
JNIEnv *env, jclass, jboolean isError, jint errorCode, jboolean isLVCode,
jstring details, jstring location, jstring callStack, jboolean printMsg) {
const char *detailsStr = env->GetStringUTFChars(details, NULL);
const char *locationStr = env->GetStringUTFChars(location, NULL);
const char *callStackStr = env->GetStringUTFChars(callStack, NULL);
NETCOMM_LOG(logDEBUG) << "Send Error: " << detailsStr;
NETCOMM_LOG(logDEBUG) << "Location: " << locationStr;
NETCOMM_LOG(logDEBUG) << "Call Stack: " << callStackStr;
jint returnValue = HALSendError(isError, errorCode, isLVCode, detailsStr, locationStr, callStackStr, printMsg);
env->ReleaseStringUTFChars(details,detailsStr);
env->ReleaseStringUTFChars(location,locationStr);
env->ReleaseStringUTFChars(callStack,callStackStr);
jint returnValue = HALSendError(isError, errorCode, isLVCode, detailsStr,
locationStr, callStackStr, printMsg);
env->ReleaseStringUTFChars(details, detailsStr);
env->ReleaseStringUTFChars(location, locationStr);
env->ReleaseStringUTFChars(callStack, callStackStr);
return returnValue;
}

View File

@@ -6,23 +6,25 @@
/*----------------------------------------------------------------------------*/
#include "HALUtil.h"
#include <jni.h>
#include <assert.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_HALUtil.h"
#include "FRC_NetworkCommunication/CANSessionMux.h"
#include "HAL/HAL.hpp"
#include "errno.h"
#include <jni.h>
#include <string.h>
#include <cstring>
#include <string>
#include "FRC_NetworkCommunication/CANSessionMux.h"
#include "HAL/HAL.hpp"
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_HALUtil.h"
#include "errno.h"
// set the logging level
TLogLevel halUtilLogLevel = logWARNING;
#define HALUTIL_LOG(level) \
if (level > halUtilLogLevel) ; \
else Log().Get(level)
#define HALUTIL_LOG(level) \
if (level > halUtilLogLevel) \
; \
else \
Log().Get(level)
#define kRioStatusOffset -63000
#define kRioStatusSuccess 0
@@ -43,7 +45,7 @@ static jclass canMessageNotAllowedExCls = nullptr;
static jclass canNotInitializedExCls = nullptr;
static jclass uncleanStatusExCls = nullptr;
static void GetStackTrace(JNIEnv *env, std::string& res, std::string& func) {
static void GetStackTrace(JNIEnv *env, std::string &res, std::string &func) {
// create a throwable
static jmethodID constructorId = nullptr;
if (!constructorId)
@@ -89,7 +91,7 @@ static void GetStackTrace(JNIEnv *env, std::string& res, std::string& func) {
}
// add a line to res
//res += " at ";
// res += " at ";
const char *tmp = env->GetStringUTFChars(stackElementString, nullptr);
res += tmp;
res += '\n';
@@ -212,8 +214,7 @@ extern "C" {
//
// indicate JNI version support desired and load classes
//
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
jvm = vm;
// set our logging level
@@ -292,8 +293,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_VERSION_1_6;
}
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
{
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
JNIEnv *env;
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK)
return;
@@ -305,7 +305,8 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
if (boundaryExCls) env->DeleteGlobalRef(boundaryExCls);
if (canInvalidBufferExCls) env->DeleteGlobalRef(canInvalidBufferExCls);
if (canMessageNotFoundExCls) env->DeleteGlobalRef(canMessageNotFoundExCls);
if (canMessageNotAllowedExCls) env->DeleteGlobalRef(canMessageNotAllowedExCls);
if (canMessageNotAllowedExCls)
env->DeleteGlobalRef(canMessageNotAllowedExCls);
if (canNotInitializedExCls) env->DeleteGlobalRef(canNotInitializedExCls);
if (uncleanStatusExCls) env->DeleteGlobalRef(uncleanStatusExCls);
jvm = nullptr;
@@ -316,9 +317,9 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
* Method: initializeMutex
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMutexNormal
(JNIEnv * env, jclass)
{
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMutexNormal(
JNIEnv *env, jclass) {
HALUTIL_LOG(logDEBUG) << "Calling HALUtil initializeMutex";
MUTEX_ID mutex = initializeMutexNormal();
HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << mutex;
@@ -330,9 +331,8 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMutexNo
* Method: deleteMutex
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMutex
(JNIEnv * env, jclass, jlong id )
{
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMutex(
JNIEnv *env, jclass, jlong id) {
HALUTIL_LOG(logDEBUG) << "Calling HALUtil deleteMutex";
HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << (MUTEX_ID)id;
deleteMutex((MUTEX_ID)id);
@@ -343,11 +343,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMutex
* Method: takeMutex
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMutex
(JNIEnv * env, jclass, jlong id)
{
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil takeMutex";
//HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << (MUTEX_ID)id;
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMutex(
JNIEnv *env, jclass, jlong id) {
// HALUTIL_LOG(logDEBUG) << "Calling HALUtil takeMutex";
// HALUTIL_LOG(logDEBUG) << "Mutex Ptr = " << (MUTEX_ID)id;
takeMutex((MUTEX_ID)id);
}
@@ -356,9 +355,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMutex
* Method: initializeMultiWait
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMultiWait
(JNIEnv * env, jclass)
{
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMultiWait(
JNIEnv *env, jclass) {
HALUTIL_LOG(logDEBUG) << "Calling HALUtil initializeMultiWait";
MULTIWAIT_ID multiWait = initializeMultiWait();
HALUTIL_LOG(logDEBUG) << "MultiWait Ptr = " << multiWait;
@@ -370,9 +369,8 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_initializeMultiWa
* Method: deleteMultiWait
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMultiWait
(JNIEnv * env, jclass, jlong id)
{
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMultiWait(
JNIEnv *env, jclass, jlong id) {
HALUTIL_LOG(logDEBUG) << "Calling HALUtil deleteMultiWait";
HALUTIL_LOG(logDEBUG) << "MultiWait Ptr = " << (MULTIWAIT_ID)id;
deleteMultiWait((MULTIWAIT_ID)id);
@@ -383,9 +381,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_deleteMultiWait
* Method: takeMultiWait
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMultiWait
(JNIEnv * env, jclass, jlong multiWaitId, jlong mutexId)
{
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMultiWait(
JNIEnv *env, jclass, jlong multiWaitId, jlong mutexId) {
takeMultiWait((MULTIWAIT_ID)multiWaitId, (MUTEX_ID)mutexId);
}
@@ -394,9 +391,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_takeMultiWait
* Method: getFPGAVersion
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAVersion
(JNIEnv * env, jclass)
{
JNIEXPORT jshort JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAVersion(JNIEnv *env, jclass) {
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGAVersion";
int32_t status = 0;
jshort returnValue = getFPGAVersion(&status);
@@ -411,9 +407,8 @@ JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAVersion
* Method: getFPGARevision
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGARevision
(JNIEnv * env, jclass)
{
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGARevision(JNIEnv *env, jclass) {
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGARevision";
int32_t status = 0;
jint returnValue = getFPGARevision(&status);
@@ -428,14 +423,13 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGARevision
* Method: getFPGATime
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGATime
(JNIEnv * env, jclass)
{
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGATime(JNIEnv *env, jclass) {
// HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
int32_t status = 0;
jlong returnValue = getFPGATime(&status);
//HALUTIL_LOG(logDEBUG) << "Status = " << status;
//HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;
// HALUTIL_LOG(logDEBUG) << "Status = " << status;
// HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
@@ -445,14 +439,13 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGATime
* Method: getFPGAButton
* Signature: ()I
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAButton
(JNIEnv * env, jclass)
{
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAButton(JNIEnv *env, jclass) {
// HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
int32_t status = 0;
jboolean returnValue = getFPGAButton(&status);
//HALUTIL_LOG(logDEBUG) << "Status = " << status;
//HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;
// HALUTIL_LOG(logDEBUG) << "Status = " << status;
// HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
@@ -462,11 +455,12 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getFPGAButton
* 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;
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);
}
@@ -475,9 +469,8 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALErrorMess
* Method: getHALErrno
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALErrno
(JNIEnv *, jclass)
{
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALErrno(JNIEnv *, jclass) {
return errno;
}
@@ -486,11 +479,11 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALErrno
* Method: getHALstrerror
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALstrerror
(JNIEnv * env, jclass, jint errorCode)
{
const char * msg = strerror(errno);
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getHALstrerror errorCode=" << errorCode << " msg=" << msg;
JNIEXPORT jstring JNICALL Java_edu_wpi_first_wpilibj_hal_HALUtil_getHALstrerror(
JNIEnv *env, jclass, jint errorCode) {
const char *msg = strerror(errno);
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getHALstrerror errorCode="
<< errorCode << " msg=" << msg;
return env->NewStringUTF(msg);
}

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_I2CJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel i2cJNILogLevel = logWARNING;
#define I2CJNI_LOG(level) \
if (level > i2cJNILogLevel) ; \
else Log().Get(level)
#define I2CJNI_LOG(level) \
if (level > i2cJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,15 +30,14 @@ extern "C" {
* Method: i2cInitialize
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize
(JNIEnv * env, jclass, jbyte value)
{
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CInititalize";
I2CJNI_LOG(logDEBUG) << "Port: " << (jint) value;
int32_t status = 0;
i2CInitialize(value, &status);
I2CJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize(
JNIEnv* env, jclass, jbyte value) {
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CInititalize";
I2CJNI_LOG(logDEBUG) << "Port: " << (jint)value;
int32_t status = 0;
i2CInitialize(value, &status);
I2CJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -44,24 +45,26 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize
* Method: i2CTransaction
* Signature: (BBLjava/nio/ByteBuffer;BLjava/nio/ByteBuffer;B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransaction
(JNIEnv * env, jclass, jbyte port, jbyte address, jobject dataToSend, jbyte sendSize, jobject dataReceived, jbyte receiveSize)
{
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CTransaction";
I2CJNI_LOG(logDEBUG) << "Port = " << (jint)port;
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t*)env->GetDirectBufferAddress(dataToSend);
}
I2CJNI_LOG(logDEBUG) << "DataToSendPtr = " << (jint*)dataToSendPtr;
I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)sendSize;
uint8_t* dataReceivedPtr = (uint8_t*)env->GetDirectBufferAddress(dataReceived);
I2CJNI_LOG(logDEBUG) << "DataReceivedPtr = " << (jint*)dataReceivedPtr;
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << (jint)receiveSize;
jint returnValue = i2CTransaction(port, address, dataToSendPtr, sendSize, dataReceivedPtr, receiveSize);
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue;
return returnValue;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransaction(
JNIEnv* env, jclass, jbyte port, jbyte address, jobject dataToSend,
jbyte sendSize, jobject dataReceived, jbyte receiveSize) {
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CTransaction";
I2CJNI_LOG(logDEBUG) << "Port = " << (jint)port;
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t*)env->GetDirectBufferAddress(dataToSend);
}
I2CJNI_LOG(logDEBUG) << "DataToSendPtr = " << (jint*)dataToSendPtr;
I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)sendSize;
uint8_t* dataReceivedPtr =
(uint8_t*)env->GetDirectBufferAddress(dataReceived);
I2CJNI_LOG(logDEBUG) << "DataReceivedPtr = " << (jint*)dataReceivedPtr;
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << (jint)receiveSize;
jint returnValue = i2CTransaction(port, address, dataToSendPtr, sendSize,
dataReceivedPtr, receiveSize);
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue;
return returnValue;
}
/*
@@ -69,23 +72,22 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransaction
* Method: i2CWrite
* Signature: (BBLjava/nio/ByteBuffer;B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CWrite
(JNIEnv * env, jclass, jbyte port, jbyte address, jobject dataToSend, jbyte sendSize)
{
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CWrite";
I2CJNI_LOG(logDEBUG) << "Port = " << (jint)port;
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t*)env->GetDirectBufferAddress(dataToSend);
}
I2CJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)dataToSend;
jint returnValue = i2CWrite(port, address, dataToSendPtr, sendSize);
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)returnValue;
return returnValue;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CWrite(
JNIEnv* env, jclass, jbyte port, jbyte address, jobject dataToSend,
jbyte sendSize) {
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CWrite";
I2CJNI_LOG(logDEBUG) << "Port = " << (jint)port;
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t*)env->GetDirectBufferAddress(dataToSend);
}
I2CJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)dataToSend;
jint returnValue = i2CWrite(port, address, dataToSendPtr, sendSize);
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)returnValue;
return returnValue;
}
/*
@@ -93,18 +95,19 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CWrite
* Method: i2CRead
* Signature: (BBLjava/nio/ByteBuffer;B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead
(JNIEnv * env, jclass, jbyte port, jbyte address, jobject dataReceived, jbyte receiveSize)
{
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CRead";
I2CJNI_LOG(logDEBUG) << "Port = " << port;
I2CJNI_LOG(logDEBUG) << "Address = " << address;
uint8_t* dataReceivedPtr = (uint8_t*)env->GetDirectBufferAddress(dataReceived);
I2CJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << receiveSize;
jint returnValue = i2CRead(port, address, dataReceivedPtr, receiveSize);
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue;
return returnValue;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead(
JNIEnv* env, jclass, jbyte port, jbyte address, jobject dataReceived,
jbyte receiveSize) {
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CRead";
I2CJNI_LOG(logDEBUG) << "Port = " << port;
I2CJNI_LOG(logDEBUG) << "Address = " << address;
uint8_t* dataReceivedPtr =
(uint8_t*)env->GetDirectBufferAddress(dataReceived);
I2CJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << receiveSize;
jint returnValue = i2CRead(port, address, dataReceivedPtr, receiveSize);
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue;
return returnValue;
}
/*
@@ -112,11 +115,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead
* Method: i2CClose
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CClose
(JNIEnv *, jclass, jbyte value)
{
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CClose";
i2CClose(value);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CClose(JNIEnv*, jclass, jbyte value) {
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CClose";
i2CClose(value);
}
} // extern "C"

View File

@@ -5,24 +5,26 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include <atomic>
#include <condition_variable>
#include <mutex>
#include <thread>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_InterruptJNI.h"
#include "HAL/Interrupts.hpp"
#include "HALUtil.h"
#include "SafeThread.h"
#include "edu_wpi_first_wpilibj_hal_InterruptJNI.h"
TLogLevel interruptJNILogLevel = logERROR;
#define INTERRUPTJNI_LOG(level) \
if (level > interruptJNILogLevel) ; \
else Log().Get(level)
#define INTERRUPTJNI_LOG(level) \
if (level > interruptJNILogLevel) \
; \
else \
Log().Get(level)
// Thread where callbacks are actually performed.
//
@@ -74,7 +76,7 @@ void InterruptJNI::SetFunc(JNIEnv* env, jobject func, jmethodID mid,
}
void InterruptThreadJNI::Main() {
JNIEnv *env;
JNIEnv* env;
JavaVMAttachArgs args;
args.version = JNI_VERSION_1_2;
args.name = const_cast<char*>("Interrupt");
@@ -119,9 +121,9 @@ extern "C" {
* Method: initializeInterrupts
* Signature: (IZ)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeInterrupts
(JNIEnv * env, jclass, jint interruptIndex, jboolean watcher)
{
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeInterrupts(
JNIEnv* env, jclass, jint interruptIndex, jboolean watcher) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI initializeInterrupts";
INTERRUPTJNI_LOG(logDEBUG) << "interruptIndex = " << interruptIndex;
INTERRUPTJNI_LOG(logDEBUG) << "watcher = " << (bool)watcher;
@@ -136,15 +138,14 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeIn
return (jlong)interrupt;
}
/*
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
* Method: cleanInterrupts
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrupts
(JNIEnv * env, jclass, jlong interrupt_pointer)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrupts(
JNIEnv* env, jclass, jlong interrupt_pointer) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI cleanInterrupts";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -161,9 +162,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrup
* Method: waitForInterrupt
* Signature: (JD)V
*/
JNIEXPORT int JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterrupt
(JNIEnv * env, jclass, jlong interrupt_pointer, jdouble timeout, jboolean ignorePrevious)
{
JNIEXPORT int JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterrupt(
JNIEnv* env, jclass, jlong interrupt_pointer, jdouble timeout,
jboolean ignorePrevious) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI waitForInterrupt";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -182,9 +184,9 @@ JNIEXPORT int JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterru
* Method: enableInterrupts
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterrupts
(JNIEnv * env, jclass, jlong interrupt_pointer)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterrupts(
JNIEnv* env, jclass, jlong interrupt_pointer) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI enableInterrupts";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -201,9 +203,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterru
* Method: disableInterrupts
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterrupts
(JNIEnv * env, jclass, jlong interrupt_pointer)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterrupts(
JNIEnv* env, jclass, jlong interrupt_pointer) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI disableInterrupts";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -220,9 +222,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterr
* Method: readRisingTimestamp
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRisingTimestamp
(JNIEnv * env, jclass, jlong interrupt_pointer)
{
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRisingTimestamp(
JNIEnv* env, jclass, jlong interrupt_pointer) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readRisingTimestamp";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -239,9 +241,9 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRising
* Method: readFallingTimestamp
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallingTimestamp
(JNIEnv * env, jclass, jlong interrupt_pointer)
{
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallingTimestamp(
JNIEnv* env, jclass, jlong interrupt_pointer) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readFallingTimestamp";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -258,14 +260,16 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallin
* Method: requestInterrupts
* Signature: (JBIZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterrupts
(JNIEnv * env, jclass, jlong interrupt_pointer, jbyte routing_module, jint routing_pin, jboolean routing_analog_trigger)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterrupts(
JNIEnv* env, jclass, jlong interrupt_pointer, jbyte routing_module,
jint routing_pin, jboolean routing_analog_trigger) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI requestInterrupts";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
INTERRUPTJNI_LOG(logDEBUG) << "routing module = " << (jint)routing_module;
INTERRUPTJNI_LOG(logDEBUG) << "routing pin = " << routing_pin;
INTERRUPTJNI_LOG(logDEBUG) << "routing analog trigger = " << (jint)routing_analog_trigger;
INTERRUPTJNI_LOG(logDEBUG) << "routing analog trigger = "
<< (jint)routing_analog_trigger;
int32_t status = 0;
requestInterrupts((void*)interrupt_pointer, (uint8_t)routing_module,
@@ -278,11 +282,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterr
/*
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
* Method: attachInterruptHandler
* Signature: (JLedu/wpi/first/wpilibj/hal/InterruptJNI/InterruptHandlerFunction;Ljava/nio/ByteBuffer;)V
* Signature:
* (JLedu/wpi/first/wpilibj/hal/InterruptJNI/InterruptHandlerFunction;Ljava/nio/ByteBuffer;)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler
(JNIEnv * env, jclass, jlong interrupt_pointer, jobject handler, jobject param)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler(
JNIEnv* env, jclass, jlong interrupt_pointer, jobject handler,
jobject param) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI attachInterruptHandler";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
@@ -320,9 +326,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterru
* Method: setInterruptUpSourceEdge
* Signature: (JZZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_setInterruptUpSourceEdge
(JNIEnv * env, jclass, jlong interrupt_pointer, jboolean risingEdge, jboolean fallingEdge)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_setInterruptUpSourceEdge(
JNIEnv* env, jclass, jlong interrupt_pointer, jboolean risingEdge,
jboolean fallingEdge) {
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI setInterruptUpSourceEdge";
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
INTERRUPTJNI_LOG(logDEBUG) << "Rising Edge = " << (bool)risingEdge;

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_JNIWrapper.h"
@@ -20,15 +20,15 @@ extern "C" {
* Method: getPortWithModule
* Signature: (BB)J
*/
JNIEXPORT jlong 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* port = getPortWithModule(module, pin);
//FILE_LOG(logDEBUG) << "Port Ptr = " << port;
return (jlong)port;
JNIEXPORT jlong 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* port = getPortWithModule(module, pin);
// FILE_LOG(logDEBUG) << "Port Ptr = " << port;
return (jlong)port;
}
/*
@@ -36,15 +36,14 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPortWithMod
* Method: getPort
* Signature: (BB)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPort
(JNIEnv * env, jclass, jbyte pin)
{
//FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
//FILE_LOG(logDEBUG) << "Module = " << (jint)module;
//FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
void* port = getPort(pin);
//FILE_LOG(logDEBUG) << "Port Ptr = " << port;
return (jlong)port;
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPort(
JNIEnv* env, jclass, jbyte pin) {
// FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
// FILE_LOG(logDEBUG) << "Module = " << (jint)module;
// FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
void* port = getPort(pin);
// FILE_LOG(logDEBUG) << "Port Ptr = " << port;
return (jlong)port;
}
/*
@@ -52,14 +51,13 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPort
* Method: freePort
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_freePort
(JNIEnv * env, jclass, jlong id)
{
//FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
//FILE_LOG(logDEBUG) << "Module = " << (jint)module;
//FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
freePort((void*)id);
//FILE_LOG(logDEBUG) << "Port Ptr = " << port;
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_freePort(
JNIEnv* env, jclass, jlong id) {
// FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
// FILE_LOG(logDEBUG) << "Module = " << (jint)module;
// FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
freePort((void*)id);
// FILE_LOG(logDEBUG) << "Port Ptr = " << port;
}
} // extern "C"

View File

@@ -5,26 +5,28 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "HAL/Notifier.hpp"
#include <assert.h>
#include <jni.h>
#include <stdio.h>
#include <atomic>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <thread>
#include <stdio.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_NotifierJNI.h"
#include "HAL/Notifier.hpp"
#include "HALUtil.h"
#include "Log.hpp"
#include "SafeThread.h"
#include "edu_wpi_first_wpilibj_hal_NotifierJNI.h"
// set the logging level
TLogLevel notifierJNILogLevel = logWARNING;
#define NOTIFIERJNI_LOG(level) \
if (level > notifierJNILogLevel) ; \
else Log().Get(level)
#define NOTIFIERJNI_LOG(level) \
if (level > notifierJNILogLevel) \
; \
else \
Log().Get(level)
// Thread where callbacks are actually performed.
//
@@ -50,7 +52,7 @@ class NotifierThreadJNI : public SafeThread {
class NotifierJNI : public SafeThreadOwner<NotifierThreadJNI> {
public:
void SetFunc(JNIEnv* env, jobject func, jmethodID mid);
void SetFunc(JNIEnv *env, jobject func, jmethodID mid);
void Notify(uint64_t currentTime) {
auto thr = GetThread();
@@ -61,7 +63,7 @@ class NotifierJNI : public SafeThreadOwner<NotifierThreadJNI> {
}
};
void NotifierJNI::SetFunc(JNIEnv* env, jobject func, jmethodID mid) {
void NotifierJNI::SetFunc(JNIEnv *env, jobject func, jmethodID mid) {
auto thr = GetThread();
if (!thr) return;
// free global reference
@@ -75,9 +77,9 @@ void NotifierThreadJNI::Main() {
JNIEnv *env;
JavaVMAttachArgs args;
args.version = JNI_VERSION_1_2;
args.name = const_cast<char*>("Notifier");
args.name = const_cast<char *>("Notifier");
args.group = nullptr;
jint rs = jvm->AttachCurrentThreadAsDaemon((void**)&env, &args);
jint rs = jvm->AttachCurrentThreadAsDaemon((void **)&env, &args);
if (rs != JNI_OK) return;
std::unique_lock<std::mutex> lock(m_mutex);
@@ -104,8 +106,8 @@ void NotifierThreadJNI::Main() {
jvm->DetachCurrentThread();
}
void notifierHandler(uint64_t currentTimeInt, void* param) {
((NotifierJNI*)param)->Notify(currentTimeInt);
void notifierHandler(uint64_t currentTimeInt, void *param) {
((NotifierJNI *)param)->Notify(currentTimeInt);
}
extern "C" {
@@ -115,9 +117,9 @@ extern "C" {
* Method: initializeNotifier
* Signature: (Ljava/lang/Runnable;)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeNotifier
(JNIEnv *env, jclass, jobject func)
{
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeNotifier(
JNIEnv *env, jclass, jobject func) {
NOTIFIERJNI_LOG(logDEBUG) << "Calling NOTIFIERJNI initializeNotifier";
jclass cls = env->GetObjectClass(func);
@@ -135,7 +137,7 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeNot
// each notifier runs in its own thread; this is so if one takes too long
// to execute, it doesn't keep the others from running
NotifierJNI* notify = new NotifierJNI;
NotifierJNI *notify = new NotifierJNI;
notify->Start();
notify->SetFunc(env, func, mid);
int32_t status = 0;
@@ -157,17 +159,16 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeNot
* Method: cleanNotifier
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_cleanNotifier
(JNIEnv *env, jclass, jlong notifierPtr)
{
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_cleanNotifier(
JNIEnv *env, jclass, jlong notifierPtr) {
NOTIFIERJNI_LOG(logDEBUG) << "Calling NOTIFIERJNI cleanNotifier";
NOTIFIERJNI_LOG(logDEBUG) << "Notifier Ptr = " << (void *)notifierPtr;
int32_t status = 0;
NotifierJNI* notify =
(NotifierJNI*)getNotifierParam((void*)notifierPtr, &status);
cleanNotifier((void*)notifierPtr, &status);
NotifierJNI *notify =
(NotifierJNI *)getNotifierParam((void *)notifierPtr, &status);
cleanNotifier((void *)notifierPtr, &status);
NOTIFIERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
delete notify;
@@ -178,9 +179,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_cleanNotifier
* Method: updateNotifierAlarm
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_updateNotifierAlarm
(JNIEnv *env, jclass cls, jlong notifierPtr, jlong triggerTime)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_NotifierJNI_updateNotifierAlarm(
JNIEnv *env, jclass cls, jlong notifierPtr, jlong triggerTime) {
NOTIFIERJNI_LOG(logDEBUG) << "Calling NOTIFIERJNI updateNotifierAlarm";
NOTIFIERJNI_LOG(logDEBUG) << "Notifier Ptr = " << (void *)notifierPtr;
@@ -188,7 +189,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_updateNotifier
NOTIFIERJNI_LOG(logDEBUG) << "triggerTime = " << triggerTime;
int32_t status = 0;
updateNotifierAlarm((void*)notifierPtr, (uint64_t)triggerTime, &status);
updateNotifierAlarm((void *)notifierPtr, (uint64_t)triggerTime, &status);
NOTIFIERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
@@ -198,15 +199,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_updateNotifier
* Method: stopNotifierAlarm
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_stopNotifierAlarm
(JNIEnv *env, jclass cls, jlong notifierPtr)
{
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_NotifierJNI_stopNotifierAlarm(
JNIEnv *env, jclass cls, jlong notifierPtr) {
NOTIFIERJNI_LOG(logDEBUG) << "Calling NOTIFIERJNI stopNotifierAlarm";
NOTIFIERJNI_LOG(logDEBUG) << "Notifier Ptr = " << (void *)notifierPtr;
int32_t status = 0;
stopNotifierAlarm((void*)notifierPtr, &status);
stopNotifierAlarm((void *)notifierPtr, &status);
NOTIFIERJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}

View File

@@ -5,9 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "edu_wpi_first_wpilibj_hal_PDPJNI.h"
#include "HAL/PDP.hpp"
#include "HALUtil.h"
#include "edu_wpi_first_wpilibj_hal_PDPJNI.h"
extern "C" {
@@ -16,22 +16,21 @@ extern "C" {
* Method: getPDPTemperature
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_initializePDP
(JNIEnv *, jclass, jint module)
{
initializePDP(module);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_initializePDP(
JNIEnv *, jclass, jint module) {
initializePDP(module);
}
/*
* Class: edu_wpi_first_wpilibj_hal_PDPJNI
* Method: getPDPTemperature
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTemperature
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
double temperature = getPDPTemperature(module, &status);
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTemperature(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
double temperature = getPDPTemperature(module, &status);
CheckStatus(env, status, false);
return temperature;
}
@@ -41,11 +40,10 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTemperatur
* Method: getPDPVoltage
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPVoltage
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
double voltage = getPDPVoltage(module, &status);
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPVoltage(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
double voltage = getPDPVoltage(module, &status);
CheckStatus(env, status, false);
return voltage;
}
@@ -55,11 +53,11 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPVoltage
* Method: getPDPChannelCurrent
* Signature: (BI)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPChannelCurrent
(JNIEnv *env, jclass, jbyte channel, jint module)
{
int32_t status = 0;
double current = getPDPChannelCurrent(module, channel, &status);
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPChannelCurrent(
JNIEnv *env, jclass, jbyte channel, jint module) {
int32_t status = 0;
double current = getPDPChannelCurrent(module, channel, &status);
CheckStatus(env, status, false);
return current;
}
@@ -69,11 +67,11 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPChannelCur
* Method: getPDPTotalCurrent
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalCurrent
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
double current = getPDPTotalCurrent(module, &status);
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalCurrent(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
double current = getPDPTotalCurrent(module, &status);
CheckStatus(env, status, false);
return current;
}
@@ -83,11 +81,11 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalCurre
* Method: getPDPTotalPower
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalPower
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
double power = getPDPTotalPower(module, &status);
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalPower(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
double power = getPDPTotalPower(module, &status);
CheckStatus(env, status, false);
return power;
}
@@ -97,26 +95,25 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalPower
* Method: resetPDPTotalEnergy
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalEnergy
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
double energy = getPDPTotalEnergy(module, &status);
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalEnergy(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
double energy = getPDPTotalEnergy(module, &status);
CheckStatus(env, status, false);
return energy;
}
/*
* Class: edu_wpi_first_wpilibj_hal_PDPJNI
* Method: resetPDPTotalEnergy
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_resetPDPTotalEnergy
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
resetPDPTotalEnergy(module, &status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_resetPDPTotalEnergy(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
resetPDPTotalEnergy(module, &status);
CheckStatus(env, status, false);
}
@@ -125,11 +122,11 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_resetPDPTotalEnergy
* Method: clearStickyFaults
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_clearPDPStickyFaults
(JNIEnv *env, jclass, jint module)
{
int32_t status = 0;
clearPDPStickyFaults(module, &status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_PDPJNI_clearPDPStickyFaults(
JNIEnv *env, jclass, jint module) {
int32_t status = 0;
clearPDPStickyFaults(module, &status);
CheckStatus(env, status, false);
}

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_PWMJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel pwmJNILogLevel = logWARNING;
#define PWMJNI_LOG(level) \
if (level > pwmJNILogLevel) ; \
else Log().Get(level)
#define PWMJNI_LOG(level) \
if (level > pwmJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,17 +30,17 @@ extern "C" {
* Method: allocatePWMChannel
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWMChannel
(JNIEnv * env, jclass, jlong id)
{
PWMJNI_LOG(logDEBUG) << "Calling DIOJNI allocatePWMChannel";
PWMJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = allocatePWMChannel((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
PWMJNI_LOG(logDEBUG) << "allocatePWMChannelResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWMChannel(
JNIEnv* env, jclass, jlong id) {
PWMJNI_LOG(logDEBUG) << "Calling DIOJNI allocatePWMChannel";
PWMJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = allocatePWMChannel((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
PWMJNI_LOG(logDEBUG) << "allocatePWMChannelResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -46,15 +48,14 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWMChan
* Method: freePWMChannel
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWMChannel
(JNIEnv * env, jclass, jlong id)
{
PWMJNI_LOG(logDEBUG) << "Calling DIOJNI freePWMChannel";
PWMJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
freePWMChannel((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWMChannel(
JNIEnv* env, jclass, jlong id) {
PWMJNI_LOG(logDEBUG) << "Calling DIOJNI freePWMChannel";
PWMJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
freePWMChannel((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -62,15 +63,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWMChannel
* Method: setPWM
* Signature: (JS)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWM
(JNIEnv * env, jclass, jlong id, jshort value)
{
PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "PWM Value = " << value;
int32_t status = 0;
setPWM((void*)id, value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWM(
JNIEnv* env, jclass, jlong id, jshort value) {
PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "PWM Value = " << value;
int32_t status = 0;
setPWM((void*)id, value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -78,16 +78,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWM
* Method: getPWM
* Signature: (J)S
*/
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_getPWM
(JNIEnv * env, jclass, jlong id)
{
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
int32_t status = 0;
jshort returnValue = getPWM((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
PWMJNI_LOG(logDEBUG) << "Value = " << returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jshort JNICALL
Java_edu_wpi_first_wpilibj_hal_PWMJNI_getPWM(JNIEnv* env, jclass, jlong id) {
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
int32_t status = 0;
jshort returnValue = getPWM((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
PWMJNI_LOG(logDEBUG) << "Value = " << returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -95,14 +94,13 @@ JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_getPWM
* Method: latchPWMZero
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_latchPWMZero
(JNIEnv * env, jclass, jlong id)
{
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
int32_t status = 0;
latchPWMZero((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_latchPWMZero(
JNIEnv* env, jclass, jlong id) {
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
int32_t status = 0;
latchPWMZero((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -110,15 +108,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_latchPWMZero
* Method: setPWMPeriodScale
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMPeriodScale
(JNIEnv * env, jclass, jlong id, jint value)
{
PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "PeriodScale Value = " << value;
int32_t status = 0;
setPWMPeriodScale((void*)id, value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMPeriodScale(
JNIEnv* env, jclass, jlong id, jint value) {
PWMJNI_LOG(logDEBUG) << "DigitalPort Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "PeriodScale Value = " << value;
int32_t status = 0;
setPWMPeriodScale((void*)id, value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -126,16 +123,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMPeriodScale
* Method: allocatePWM
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWM
(JNIEnv * env, jclass)
{
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI allocatePWM";
int32_t status = 0;
void* pwm = allocatePWM(&status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << pwm;
CheckStatus(env, status);
return (jlong)pwm;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWM(JNIEnv* env, jclass) {
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI allocatePWM";
int32_t status = 0;
void* pwm = allocatePWM(&status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << pwm;
CheckStatus(env, status);
return (jlong)pwm;
}
/*
@@ -143,15 +139,14 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWM
* Method: freePWM
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWM
(JNIEnv * env, jclass, jlong id)
{
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI freePWM";
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
int32_t status = 0;
freePWM((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWM(JNIEnv* env, jclass, jlong id) {
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI freePWM";
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
int32_t status = 0;
freePWM((void*)id, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -159,15 +154,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWM
* Method: setPWMRate
* Signature: (D)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMRate
(JNIEnv * env, jclass, jdouble value)
{
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMRate";
PWMJNI_LOG(logDEBUG) << "Rate= " << value;
int32_t status = 0;
setPWMRate(value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMRate(
JNIEnv* env, jclass, jdouble value) {
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMRate";
PWMJNI_LOG(logDEBUG) << "Rate= " << value;
int32_t status = 0;
setPWMRate(value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -175,16 +169,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMRate
* Method: setPWMDutyCycle
* Signature: (JD)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMDutyCycle
(JNIEnv * env, jclass, jlong id, jdouble value)
{
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMDutyCycle";
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "DutyCycle= " << value;
int32_t status = 0;
setPWMDutyCycle((void*)id, value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMDutyCycle(
JNIEnv* env, jclass, jlong id, jdouble value) {
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMDutyCycle";
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "DutyCycle= " << value;
int32_t status = 0;
setPWMDutyCycle((void*)id, value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -192,16 +185,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMDutyCycle
* Method: setPWMOutputChannel
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMOutputChannel
(JNIEnv * env, jclass, jlong id, jint value)
{
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMOutputChannel";
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "Pin= " << value;
int32_t status = 0;
setPWMOutputChannel((void*)id, (uint32_t) value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_PWMJNI_setPWMOutputChannel(
JNIEnv* env, jclass, jlong id, jint value) {
PWMJNI_LOG(logDEBUG) << "Calling PWMJNI setPWMOutputChannel";
PWMJNI_LOG(logDEBUG) << "PWM Ptr = " << (void*)id;
PWMJNI_LOG(logDEBUG) << "Pin= " << value;
int32_t status = 0;
setPWMOutputChannel((void*)id, (uint32_t)value, &status);
PWMJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -5,10 +5,10 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "edu_wpi_first_wpilibj_hal_PowerJNI.h"
#include "HAL/Power.hpp"
#include <jni.h>
#include "HALUtil.h"
#include "edu_wpi_first_wpilibj_hal_PowerJNI.h"
extern "C" {
@@ -17,11 +17,10 @@ extern "C" {
* Method: getVinVoltage
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinVoltage
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getVinVoltage(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinVoltage(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getVinVoltage(&status);
CheckStatus(env, status);
return val;
}
@@ -31,11 +30,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinVoltage
* Method: getVinCurrent
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinCurrent
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getVinCurrent(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinCurrent(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getVinCurrent(&status);
CheckStatus(env, status);
return val;
}
@@ -45,11 +43,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getVinCurrent
* Method: getUserVoltage6V
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage6V
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getUserVoltage6V(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage6V(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getUserVoltage6V(&status);
CheckStatus(env, status);
return val;
}
@@ -59,11 +56,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage6
* Method: getUserCurrent6V
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent6V
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getUserCurrent6V(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent6V(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getUserCurrent6V(&status);
CheckStatus(env, status);
return val;
}
@@ -73,11 +69,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent6
* Method: getUserActive6V
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive6V
(JNIEnv * env, jclass)
{
int32_t status = 0;
bool val = getUserActive6V(&status);
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive6V(JNIEnv* env, jclass) {
int32_t status = 0;
bool val = getUserActive6V(&status);
CheckStatus(env, status);
return val;
}
@@ -87,11 +82,11 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive
* Method: getUserCurrentFaults6V
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFaults6V
(JNIEnv * env, jclass)
{
int32_t status = 0;
int val = getUserCurrentFaults6V(&status);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFaults6V(
JNIEnv* env, jclass) {
int32_t status = 0;
int val = getUserCurrentFaults6V(&status);
CheckStatus(env, status);
return val;
}
@@ -101,11 +96,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFau
* Method: getUserVoltage5V
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage5V
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getUserVoltage5V(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage5V(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getUserVoltage5V(&status);
CheckStatus(env, status);
return val;
}
@@ -115,11 +109,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage5
* Method: getUserCurrent5V
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent5V
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getUserCurrent5V(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent5V(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getUserCurrent5V(&status);
CheckStatus(env, status);
return val;
}
@@ -129,11 +122,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent5
* Method: getUserActive5V
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive5V
(JNIEnv * env, jclass)
{
int32_t status = 0;
bool val = getUserActive5V(&status);
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive5V(JNIEnv* env, jclass) {
int32_t status = 0;
bool val = getUserActive5V(&status);
CheckStatus(env, status);
return val;
}
@@ -143,11 +135,11 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive
* Method: getUserCurrentFaults5V
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFaults5V
(JNIEnv * env, jclass)
{
int32_t status = 0;
int val = getUserCurrentFaults5V(&status);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFaults5V(
JNIEnv* env, jclass) {
int32_t status = 0;
int val = getUserCurrentFaults5V(&status);
CheckStatus(env, status);
return val;
}
@@ -157,11 +149,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFau
* Method: getUserVoltage3V3
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage3V3
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getUserVoltage3V3(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage3V3(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getUserVoltage3V3(&status);
CheckStatus(env, status);
return val;
}
@@ -171,11 +162,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserVoltage3
* Method: getUserCurrent3V3
* Signature: ()F
*/
JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent3V3
(JNIEnv * env, jclass)
{
int32_t status = 0;
float val = getUserCurrent3V3(&status);
JNIEXPORT jfloat JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent3V3(JNIEnv* env, jclass) {
int32_t status = 0;
float val = getUserCurrent3V3(&status);
CheckStatus(env, status);
return val;
}
@@ -185,11 +175,10 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrent3
* Method: getUserActive3V3
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive3V3
(JNIEnv * env, jclass)
{
int32_t status = 0;
bool val = getUserActive3V3(&status);
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive3V3(JNIEnv* env, jclass) {
int32_t status = 0;
bool val = getUserActive3V3(&status);
CheckStatus(env, status);
return val;
}
@@ -199,11 +188,11 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserActive
* Method: getUserCurrentFaults3V3
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFaults3V3
(JNIEnv * env, jclass)
{
int32_t status = 0;
int val = getUserCurrentFaults3V3(&status);
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFaults3V3(
JNIEnv* env, jclass) {
int32_t status = 0;
int val = getUserCurrentFaults3V3(&status);
CheckStatus(env, status);
return val;
}

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_RelayJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel relayJNILogLevel = logWARNING;
#define RELAYJNI_LOG(level) \
if (level > relayJNILogLevel) ; \
else Log().Get(level)
#define RELAYJNI_LOG(level) \
if (level > relayJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,16 +30,15 @@ extern "C" {
* Method: setRelayForward
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayForward
(JNIEnv * env, jclass, jlong id, jboolean value)
{
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI setRelayForward";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value;
int32_t status = 0;
setRelayForward((void*)id, value, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayForward(
JNIEnv* env, jclass, jlong id, jboolean value) {
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI setRelayForward";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value;
int32_t status = 0;
setRelayForward((void*)id, value, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -45,16 +46,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayForward
* Method: setRelayReverse
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayReverse
(JNIEnv * env, jclass, jlong id, jboolean value)
{
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI setRelayReverse";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value;
int32_t status = 0;
setRelayReverse((void*)id, value, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayReverse(
JNIEnv* env, jclass, jlong id, jboolean value) {
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI setRelayReverse";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
RELAYJNI_LOG(logDEBUG) << "Flag = " << (jint)value;
int32_t status = 0;
setRelayReverse((void*)id, value, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -62,17 +62,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_setRelayReverse
* Method: getRelayForward
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayForward
(JNIEnv * env, jclass, jlong id)
{
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI getRelayForward";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getRelayForward((void*)id, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
RELAYJNI_LOG(logDEBUG) << "getRelayForwardResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayForward(
JNIEnv* env, jclass, jlong id) {
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI getRelayForward";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getRelayForward((void*)id, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
RELAYJNI_LOG(logDEBUG) << "getRelayForwardResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
/*
@@ -80,17 +80,17 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayForwa
* Method: getRelayReverse
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayReverse
(JNIEnv * env, jclass, jlong id)
{
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI getRelayReverse";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getRelayReverse((void*)id, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
RELAYJNI_LOG(logDEBUG) << "getRelayReverseResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_RelayJNI_getRelayReverse(
JNIEnv* env, jclass, jlong id) {
RELAYJNI_LOG(logDEBUG) << "Calling RELAYJNI getRelayReverse";
RELAYJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
int32_t status = 0;
jboolean returnValue = getRelayReverse((void*)id, &status);
RELAYJNI_LOG(logDEBUG) << "Status = " << status;
RELAYJNI_LOG(logDEBUG) << "getRelayReverseResult = " << (jint)returnValue;
CheckStatus(env, status);
return returnValue;
}
} // extern "C"

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_SPIJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel spiJNILogLevel = logWARNING;
#define SPIJNI_LOG(level) \
if (level > spiJNILogLevel) ; \
else Log().Get(level)
#define SPIJNI_LOG(level) \
if (level > spiJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,15 +30,14 @@ extern "C" {
* Method: spiInitialize
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize
(JNIEnv * env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitialize";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
spiInitialize(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitialize";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
spiInitialize(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -44,22 +45,23 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize
* Method: spiTransaction
* Signature: (BLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction
(JNIEnv * env, jclass, jbyte port, jobject dataToSend, jobject dataReceived, jbyte size)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransaction";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t*)env->GetDirectBufferAddress(dataToSend);
}
uint8_t* dataReceivedPtr = (uint8_t*)env->GetDirectBufferAddress(dataReceived);
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
jint retVal = spiTransaction(port, dataToSendPtr, dataReceivedPtr, size);
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
return retVal;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction(
JNIEnv *env, jclass, jbyte port, jobject dataToSend, jobject dataReceived,
jbyte size) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransaction";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
uint8_t *dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t *)env->GetDirectBufferAddress(dataToSend);
}
uint8_t *dataReceivedPtr =
(uint8_t *)env->GetDirectBufferAddress(dataReceived);
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
jint retVal = spiTransaction(port, dataToSendPtr, dataReceivedPtr, size);
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
return retVal;
}
/*
@@ -67,53 +69,49 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction
* Method: spiWrite
* Signature: (BLjava/nio/ByteBuffer;B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite
(JNIEnv * env, jclass, jbyte port, jobject dataToSend, jbyte size)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiWrite";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t*)env->GetDirectBufferAddress(dataToSend);
}
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
jint retVal = spiWrite(port, dataToSendPtr, size);
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
return retVal;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite(
JNIEnv *env, jclass, jbyte port, jobject dataToSend, jbyte size) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiWrite";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
uint8_t *dataToSendPtr = nullptr;
if (dataToSend != 0) {
dataToSendPtr = (uint8_t *)env->GetDirectBufferAddress(dataToSend);
}
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
jint retVal = spiWrite(port, dataToSendPtr, size);
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
return retVal;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
* Method: spiRead
* Signature: (BLjava/nio/ByteBuffer;B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead
(JNIEnv * env, jclass, jbyte port, jobject dataReceived, jbyte size)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiRead";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
uint8_t* dataReceivedPtr = (uint8_t*)env->GetDirectBufferAddress(dataReceived);
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
jint retVal = spiRead(port, (uint8_t*)dataReceivedPtr, size);
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
return retVal;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead(
JNIEnv *env, jclass, jbyte port, jobject dataReceived, jbyte size) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiRead";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
uint8_t *dataReceivedPtr =
(uint8_t *)env->GetDirectBufferAddress(dataReceived);
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
jint retVal = spiRead(port, (uint8_t *)dataReceivedPtr, size);
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
return retVal;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
* Method: spiClose
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose
(JNIEnv *, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiClose";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
spiClose(port);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose(JNIEnv *, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiClose";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
spiClose(port);
}
/*
@@ -121,13 +119,12 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose
* Method: spiSetSpeed
* Signature: (BI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed
(JNIEnv *, jclass, jbyte port, jint speed)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetSpeed";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
SPIJNI_LOG(logDEBUG) << "Speed = " << (jint) speed;
spiSetSpeed(port, speed);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed(
JNIEnv *, jclass, jbyte port, jint speed) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetSpeed";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
SPIJNI_LOG(logDEBUG) << "Speed = " << (jint)speed;
spiSetSpeed(port, speed);
}
/*
@@ -135,15 +132,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed
* Method: spiSetOpts
* Signature: (BIII)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts
(JNIEnv *, jclass, jbyte port, jint msb_first, jint sample_on_trailing, jint clk_idle_high)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetOpts";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
SPIJNI_LOG(logDEBUG) << "msb_first = " << msb_first;
SPIJNI_LOG(logDEBUG) << "sample_on_trailing = " << sample_on_trailing;
SPIJNI_LOG(logDEBUG) << "clk_idle_high = " << clk_idle_high;
spiSetOpts(port, msb_first, sample_on_trailing, clk_idle_high);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts(
JNIEnv *, jclass, jbyte port, jint msb_first, jint sample_on_trailing,
jint clk_idle_high) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetOpts";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
SPIJNI_LOG(logDEBUG) << "msb_first = " << msb_first;
SPIJNI_LOG(logDEBUG) << "sample_on_trailing = " << sample_on_trailing;
SPIJNI_LOG(logDEBUG) << "clk_idle_high = " << clk_idle_high;
spiSetOpts(port, msb_first, sample_on_trailing, clk_idle_high);
}
/*
@@ -151,15 +148,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts
* Method: spiSetChipSelectActiveHigh
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh
(JNIEnv * env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveHigh";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
spiSetChipSelectActiveHigh(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveHigh";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
spiSetChipSelectActiveHigh(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -167,15 +164,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectAct
* Method: spiSetChipSelectActiveLow
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow
(JNIEnv * env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveLow";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
spiSetChipSelectActiveLow(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveLow";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
spiSetChipSelectActiveLow(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -183,25 +180,26 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectAct
* Method: spiInitAccumulator
* Signature: (BIIBIIBBZZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAccumulator
(JNIEnv *env, jclass, jbyte port, jint period, jint cmd, jbyte xferSize, jint validMask, jint validValue, jbyte dataShift, jbyte dataSize, jboolean isSigned, jboolean bigEndian)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitAccumulator";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
SPIJNI_LOG(logDEBUG) << "Period = " << period;
SPIJNI_LOG(logDEBUG) << "Cmd = " << cmd;
SPIJNI_LOG(logDEBUG) << "XferSize = " << (jint) xferSize;
SPIJNI_LOG(logDEBUG) << "ValidMask = " << validMask;
SPIJNI_LOG(logDEBUG) << "ValidValue = " << validValue;
SPIJNI_LOG(logDEBUG) << "DataShift = " << (jint) dataShift;
SPIJNI_LOG(logDEBUG) << "DataSize = " << (jint) dataSize;
SPIJNI_LOG(logDEBUG) << "IsSigned = " << (jint) isSigned;
SPIJNI_LOG(logDEBUG) << "BigEndian = " << (jint) bigEndian;
int32_t status = 0;
spiInitAccumulator(port, period, cmd, xferSize, validMask, validValue,
dataShift, dataSize, isSigned, bigEndian, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAccumulator(
JNIEnv *env, jclass, jbyte port, jint period, jint cmd, jbyte xferSize,
jint validMask, jint validValue, jbyte dataShift, jbyte dataSize,
jboolean isSigned, jboolean bigEndian) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitAccumulator";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
SPIJNI_LOG(logDEBUG) << "Period = " << period;
SPIJNI_LOG(logDEBUG) << "Cmd = " << cmd;
SPIJNI_LOG(logDEBUG) << "XferSize = " << (jint)xferSize;
SPIJNI_LOG(logDEBUG) << "ValidMask = " << validMask;
SPIJNI_LOG(logDEBUG) << "ValidValue = " << validValue;
SPIJNI_LOG(logDEBUG) << "DataShift = " << (jint)dataShift;
SPIJNI_LOG(logDEBUG) << "DataSize = " << (jint)dataSize;
SPIJNI_LOG(logDEBUG) << "IsSigned = " << (jint)isSigned;
SPIJNI_LOG(logDEBUG) << "BigEndian = " << (jint)bigEndian;
int32_t status = 0;
spiInitAccumulator(port, period, cmd, xferSize, validMask, validValue,
dataShift, dataSize, isSigned, bigEndian, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -209,15 +207,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAccumulator
* Method: spiFreeAccumulator
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAccumulator
(JNIEnv *env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiFreeAccumulator";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
spiFreeAccumulator(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAccumulator(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiFreeAccumulator";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
spiFreeAccumulator(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -225,15 +222,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAccumulator
* Method: spiResetAccumulator
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiResetAccumulator
(JNIEnv *env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiResetAccumulator";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
spiResetAccumulator(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiResetAccumulator(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiResetAccumulator";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
spiResetAccumulator(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -241,16 +238,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiResetAccumulator
* Method: spiSetAccumulatorCenter
* Signature: (BI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorCenter
(JNIEnv *env, jclass, jbyte port, jint center)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAccumulatorCenter";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
SPIJNI_LOG(logDEBUG) << "Center = " << center;
int32_t status = 0;
spiSetAccumulatorCenter(port, center, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorCenter(
JNIEnv *env, jclass, jbyte port, jint center) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAccumulatorCenter";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
SPIJNI_LOG(logDEBUG) << "Center = " << center;
int32_t status = 0;
spiSetAccumulatorCenter(port, center, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -258,16 +255,16 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorCe
* Method: spiSetAccumulatorDeadband
* Signature: (BI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorDeadband
(JNIEnv *env, jclass, jbyte port, jint deadband)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAccumulatorDeadband";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
SPIJNI_LOG(logDEBUG) << "Deadband = " << deadband;
int32_t status = 0;
spiSetAccumulatorDeadband(port, deadband, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorDeadband(
JNIEnv *env, jclass, jbyte port, jint deadband) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAccumulatorDeadband";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
SPIJNI_LOG(logDEBUG) << "Deadband = " << deadband;
int32_t status = 0;
spiSetAccumulatorDeadband(port, deadband, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -275,17 +272,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorDe
* Method: spiGetAccumulatorLastValue
* Signature: (B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorLastValue
(JNIEnv *env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorLastValue";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
jint retVal = spiGetAccumulatorLastValue(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorLastValue(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorLastValue";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
jint retVal = spiGetAccumulatorLastValue(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
}
/*
@@ -293,17 +290,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorLa
* Method: spiGetAccumulatorValue
* Signature: (B)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorValue
(JNIEnv *env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorValue";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
jlong retVal = spiGetAccumulatorValue(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorValue(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorValue";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
jlong retVal = spiGetAccumulatorValue(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
}
/*
@@ -311,17 +308,17 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorV
* Method: spiGetAccumulatorCount
* Signature: (B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorCount
(JNIEnv *env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorCount";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
jint retVal = spiGetAccumulatorCount(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorCount(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorCount";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
jint retVal = spiGetAccumulatorCount(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
}
/*
@@ -329,17 +326,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorCo
* Method: spiGetAccumulatorAverage
* Signature: (B)D
*/
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorAverage
(JNIEnv *env, jclass, jbyte port)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorAverage";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
jdouble retVal = spiGetAccumulatorAverage(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorAverage(
JNIEnv *env, jclass, jbyte port) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorAverage";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
jdouble retVal = spiGetAccumulatorAverage(port, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
CheckStatus(env, status);
return retVal;
}
/*
@@ -347,22 +344,22 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulato
* Method: spiGetAccumulatorOutput
* Signature: (BLjava/nio/LongBuffer;Ljava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorOutput
(JNIEnv *env, jclass, jbyte port, jobject value, jobject count)
{
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorOutput";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorOutput(
JNIEnv *env, jclass, jbyte port, jobject value, jobject count) {
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorOutput";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
jlong * valuePtr = (jlong*)env->GetDirectBufferAddress(value);
uint32_t * countPtr = (uint32_t*)env->GetDirectBufferAddress(count);
jlong *valuePtr = (jlong *)env->GetDirectBufferAddress(value);
uint32_t *countPtr = (uint32_t *)env->GetDirectBufferAddress(count);
spiGetAccumulatorOutput(port, valuePtr, countPtr, &status);
spiGetAccumulatorOutput(port, valuePtr, countPtr, &status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "Value = " << *valuePtr;
SPIJNI_LOG(logDEBUG) << "Count = " << *countPtr;
CheckStatus(env, status);
SPIJNI_LOG(logDEBUG) << "Status = " << status;
SPIJNI_LOG(logDEBUG) << "Value = " << *valuePtr;
SPIJNI_LOG(logDEBUG) << "Count = " << *countPtr;
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -7,7 +7,7 @@
#include "SafeThread.h"
//using namespace nt;
// using namespace nt;
void detail::SafeThreadOwnerBase::Start(SafeThread* thr) {
SafeThread* curthr = nullptr;

View File

@@ -13,7 +13,7 @@
#include <mutex>
#include <thread>
//namespace nt {
// namespace nt {
// Base class for SafeThreadOwner threads.
class SafeThread {

View File

@@ -5,8 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_SerialPortJNI.h"
@@ -17,9 +17,11 @@
// set the logging level
TLogLevel serialJNILogLevel = logWARNING;
#define SERIALJNI_LOG(level) \
if (level > serialJNILogLevel) ; \
else Log().Get(level)
#define SERIALJNI_LOG(level) \
if (level > serialJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -28,15 +30,15 @@ extern "C" {
* Method: serialInitializePort
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialInitializePort
(JNIEnv * env, jclass, jbyte port)
{
SERIALJNI_LOG(logDEBUG) << "Calling Serial Initialize";
SERIALJNI_LOG(logDEBUG) << "Port = " << (jint) port;
int32_t status = 0;
serialInitializePort(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialInitializePort(
JNIEnv* env, jclass, jbyte port) {
SERIALJNI_LOG(logDEBUG) << "Calling Serial Initialize";
SERIALJNI_LOG(logDEBUG) << "Port = " << (jint)port;
int32_t status = 0;
serialInitializePort(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -44,15 +46,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialInitia
* Method: serialSetBaudRate
* Signature: (BI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetBaudRate
(JNIEnv * env, jclass, jbyte port, jint rate)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Baud Rate";
SERIALJNI_LOG(logDEBUG) << "Baud: " << rate;
int32_t status = 0;
serialSetBaudRate(port, rate, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetBaudRate(
JNIEnv* env, jclass, jbyte port, jint rate) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Baud Rate";
SERIALJNI_LOG(logDEBUG) << "Baud: " << rate;
int32_t status = 0;
serialSetBaudRate(port, rate, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -60,15 +62,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetBau
* Method: serialSetDataBits
* Signature: (BB)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetDataBits
(JNIEnv * env, jclass, jbyte port, jbyte bits)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Data Bits";
SERIALJNI_LOG(logDEBUG) << "Data Bits: " << bits;
int32_t status = 0;
serialSetDataBits(port, bits, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetDataBits(
JNIEnv* env, jclass, jbyte port, jbyte bits) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Data Bits";
SERIALJNI_LOG(logDEBUG) << "Data Bits: " << bits;
int32_t status = 0;
serialSetDataBits(port, bits, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -76,15 +78,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetDat
* Method: serialSetParity
* Signature: (BB)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetParity
(JNIEnv * env, jclass, jbyte port, jbyte parity)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Parity";
SERIALJNI_LOG(logDEBUG) << "Parity: " << parity;
int32_t status = 0;
serialSetParity(port, parity, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetParity(
JNIEnv* env, jclass, jbyte port, jbyte parity) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Parity";
SERIALJNI_LOG(logDEBUG) << "Parity: " << parity;
int32_t status = 0;
serialSetParity(port, parity, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -92,15 +94,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetPar
* Method: serialSetStopBits
* Signature: (BB)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetStopBits
(JNIEnv * env, jclass, jbyte port, jbyte bits)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Stop Bits";
SERIALJNI_LOG(logDEBUG) << "Stop Bits: " << bits;
int32_t status = 0;
serialSetStopBits(port, bits, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetStopBits(
JNIEnv* env, jclass, jbyte port, jbyte bits) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Stop Bits";
SERIALJNI_LOG(logDEBUG) << "Stop Bits: " << bits;
int32_t status = 0;
serialSetStopBits(port, bits, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -108,15 +110,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetSto
* Method: serialSetWriteMode
* Signature: (BB)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWriteMode
(JNIEnv * env, jclass, jbyte port, jbyte mode)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Mode";
SERIALJNI_LOG(logDEBUG) << "Write mode: " << mode;
int32_t status = 0;
serialSetWriteMode(port, mode, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWriteMode(
JNIEnv* env, jclass, jbyte port, jbyte mode) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Mode";
SERIALJNI_LOG(logDEBUG) << "Write mode: " << mode;
int32_t status = 0;
serialSetWriteMode(port, mode, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -124,15 +126,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWri
* Method: serialSetFlowControl
* Signature: (BB)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetFlowControl
(JNIEnv * env, jclass, jbyte port, jbyte flow)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Flow Control";
SERIALJNI_LOG(logDEBUG) << "Flow Control: " << flow;
int32_t status = 0;
serialSetFlowControl(port, flow, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetFlowControl(
JNIEnv* env, jclass, jbyte port, jbyte flow) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Flow Control";
SERIALJNI_LOG(logDEBUG) << "Flow Control: " << flow;
int32_t status = 0;
serialSetFlowControl(port, flow, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -140,15 +142,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetFlo
* Method: serialSetTimeout
* Signature: (BF)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetTimeout
(JNIEnv * env, jclass, jbyte port, jfloat timeout)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Timeout";
SERIALJNI_LOG(logDEBUG) << "Timeout: " << timeout;
int32_t status = 0;
serialSetTimeout(port, timeout, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetTimeout(
JNIEnv* env, jclass, jbyte port, jfloat timeout) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Timeout";
SERIALJNI_LOG(logDEBUG) << "Timeout: " << timeout;
int32_t status = 0;
serialSetTimeout(port, timeout, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -156,15 +158,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetTim
* Method: serialEnableTermination
* Signature: (BC)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialEnableTermination
(JNIEnv * env, jclass, jbyte port, jchar terminator)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Enable Termination";
SERIALJNI_LOG(logDEBUG) << "Terminator: " << terminator;
int32_t status = 0;
serialEnableTermination(port, terminator, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialEnableTermination(
JNIEnv* env, jclass, jbyte port, jchar terminator) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Enable Termination";
SERIALJNI_LOG(logDEBUG) << "Terminator: " << terminator;
int32_t status = 0;
serialEnableTermination(port, terminator, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -172,14 +174,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialEnable
* Method: serialDisableTermination
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialDisableTermination
(JNIEnv * env, jclass, jbyte port)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Disable termination";
int32_t status = 0;
serialDisableTermination(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialDisableTermination(
JNIEnv* env, jclass, jbyte port) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Disable termination";
int32_t status = 0;
serialDisableTermination(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -187,15 +189,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialDisabl
* Method: serialSetReadBufferSize
* Signature: (BI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetReadBufferSize
(JNIEnv * env, jclass, jbyte port, jint size)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Read Buffer Size";
SERIALJNI_LOG(logDEBUG) << "Size: " << size;
int32_t status = 0;
serialSetReadBufferSize(port, size, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetReadBufferSize(
JNIEnv* env, jclass, jbyte port, jint size) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Read Buffer Size";
SERIALJNI_LOG(logDEBUG) << "Size: " << size;
int32_t status = 0;
serialSetReadBufferSize(port, size, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -203,15 +205,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetRea
* Method: serialSetWriteBufferSize
* Signature: (BI)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWriteBufferSize
(JNIEnv * env, jclass, jbyte port, jint size)
{
SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Buffer Size";
SERIALJNI_LOG(logDEBUG) << "Size: " << size;
int32_t status = 0;
serialSetWriteBufferSize(port, size, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWriteBufferSize(
JNIEnv* env, jclass, jbyte port, jint size) {
SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Buffer Size";
SERIALJNI_LOG(logDEBUG) << "Size: " << size;
int32_t status = 0;
serialSetWriteBufferSize(port, size, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -219,15 +221,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWri
* Method: serialGetBytesRecieved
* Signature: (B)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetBytesRecieved
(JNIEnv * env, jclass, jbyte port)
{
SERIALJNI_LOG(logDEBUG) << "Serial Get Bytes Received";
int32_t status = 0;
jint retVal = serialGetBytesReceived(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
return retVal;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetBytesRecieved(
JNIEnv* env, jclass, jbyte port) {
SERIALJNI_LOG(logDEBUG) << "Serial Get Bytes Received";
int32_t status = 0;
jint retVal = serialGetBytesReceived(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
return retVal;
}
/*
@@ -235,18 +237,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetByt
* Method: serialRead
* Signature: (BLjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead
(JNIEnv * env, jclass, jbyte port, jobject dataReceived, jint size)
{
SERIALJNI_LOG(logDEBUG) << "Serial Read";
jbyte * dataReceivedPtr = NULL;
dataReceivedPtr = (jbyte*)env->GetDirectBufferAddress(dataReceived);
int32_t status = 0;
jint retVal = serialRead(port, (char*)dataReceivedPtr, size, &status);
SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
return retVal;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead(
JNIEnv* env, jclass, jbyte port, jobject dataReceived, jint size) {
SERIALJNI_LOG(logDEBUG) << "Serial Read";
jbyte* dataReceivedPtr = NULL;
dataReceivedPtr = (jbyte*)env->GetDirectBufferAddress(dataReceived);
int32_t status = 0;
jint retVal = serialRead(port, (char*)dataReceivedPtr, size, &status);
SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
return retVal;
}
/*
@@ -254,35 +255,33 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead
* Method: serialWrite
* Signature: (BLjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialWrite
(JNIEnv * env, jclass, jbyte port, jobject dataToSend, jint size)
{
SERIALJNI_LOG(logDEBUG) << "Serial Write";
jbyte * dataToSendPtr = NULL;
if(dataToSend != 0){
dataToSendPtr = (jbyte*)env->GetDirectBufferAddress(dataToSend);
}
int32_t status = 0;
jint retVal = serialWrite(port, (const char*)dataToSendPtr, size, &status);
SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
return retVal;
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialWrite(
JNIEnv* env, jclass, jbyte port, jobject dataToSend, jint size) {
SERIALJNI_LOG(logDEBUG) << "Serial Write";
jbyte* dataToSendPtr = NULL;
if (dataToSend != 0) {
dataToSendPtr = (jbyte*)env->GetDirectBufferAddress(dataToSend);
}
int32_t status = 0;
jint retVal = serialWrite(port, (const char*)dataToSendPtr, size, &status);
SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
return retVal;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SerialPortJNI
* Method: serialFlush
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialFlush
(JNIEnv * env, jclass, jbyte port)
{
SERIALJNI_LOG(logDEBUG) << "Serial Flush";
int32_t status = 0;
serialFlush(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialFlush(
JNIEnv* env, jclass, jbyte port) {
SERIALJNI_LOG(logDEBUG) << "Serial Flush";
int32_t status = 0;
serialFlush(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -290,14 +289,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialFlush
* Method: serialClear
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClear
(JNIEnv * env, jclass, jbyte port)
{
SERIALJNI_LOG(logDEBUG) << "Serial Clear";
int32_t status = 0;
serialClear(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClear(
JNIEnv* env, jclass, jbyte port) {
SERIALJNI_LOG(logDEBUG) << "Serial Clear";
int32_t status = 0;
serialClear(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
/*
@@ -305,14 +303,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClear
* Method: serialClose
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClose
(JNIEnv * env, jclass, jbyte port)
{
SERIALJNI_LOG(logDEBUG) << "Serial Close";
int32_t status = 0;
serialClose(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClose(
JNIEnv* env, jclass, jbyte port) {
SERIALJNI_LOG(logDEBUG) << "Serial Close";
int32_t status = 0;
serialClose(port, &status);
SERIALJNI_LOG(logDEBUG) << "Status = " << status;
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -6,8 +6,8 @@
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "Log.hpp"
#include "HAL/HAL.hpp"
#include "Log.hpp"
#include "edu_wpi_first_wpilibj_hal_SolenoidJNI.h"
@@ -15,9 +15,11 @@
TLogLevel solenoidJNILogLevel = logERROR;
#define SOLENOIDJNI_LOG(level) \
if (level > solenoidJNILogLevel) ; \
else Log().Get(level)
#define SOLENOIDJNI_LOG(level) \
if (level > solenoidJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
@@ -26,26 +28,30 @@ extern "C" {
* Method: initializeSolenoidPort
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSolenoidPort
(JNIEnv *env, jclass, jlong port_pointer)
{
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)port_pointer;
char *aschars = (char *)port_pointer;
SOLENOIDJNI_LOG(logDEBUG) << '\t' << (int)aschars[0] << '\t' << (int)aschars[1] << std::endl;
int32_t status = 0;
void* solenoid_port_pointer = initializeSolenoidPort((void*)port_pointer, &status);
SOLENOIDJNI_LOG(logDEBUG) << "Status = " << status;
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = " << solenoid_port_pointer;
int *asints = (int *)solenoid_port_pointer;
SOLENOIDJNI_LOG(logDEBUG) << '\t' << asints[0] << '\t' << asints[1] << std::endl;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSolenoidPort(
JNIEnv *env, jclass, jlong port_pointer) {
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
CheckStatus(env, status);
return (jlong)solenoid_port_pointer;
SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)port_pointer;
char *aschars = (char *)port_pointer;
SOLENOIDJNI_LOG(logDEBUG) << '\t' << (int)aschars[0] << '\t'
<< (int)aschars[1] << std::endl;
int32_t status = 0;
void *solenoid_port_pointer =
initializeSolenoidPort((void *)port_pointer, &status);
SOLENOIDJNI_LOG(logDEBUG) << "Status = " << status;
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = "
<< solenoid_port_pointer;
int *asints = (int *)solenoid_port_pointer;
SOLENOIDJNI_LOG(logDEBUG) << '\t' << asints[0] << '\t' << asints[1]
<< std::endl;
CheckStatus(env, status);
return (jlong)solenoid_port_pointer;
}
/*
@@ -53,13 +59,13 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSol
* Method: freeSolenoidPort
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_freeSolenoidPort
(JNIEnv *env, jclass, jlong id)
{
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_freeSolenoidPort(
JNIEnv *env, jclass, jlong id) {
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
freeSolenoidPort((void*)id);
SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void *)id;
freeSolenoidPort((void *)id);
}
/*
@@ -67,12 +73,12 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_freeSolenoidPo
* Method: getPortWithModule
* Signature: (BB)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPortWithModule
(JNIEnv *env, jclass, jbyte module, jbyte channel)
{
void* port_pointer = getPortWithModule(module, channel);
return (jlong)port_pointer;
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPortWithModule(
JNIEnv *env, jclass, jbyte module, jbyte channel) {
void *port_pointer = getPortWithModule(module, channel);
return (jlong)port_pointer;
}
/*
@@ -80,16 +86,16 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPortWithMo
* Method: setSolenoid
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_setSolenoid
(JNIEnv *env, jclass, jlong solenoid_port, jboolean value)
{
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI SetSolenoid";
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = " << (void*)solenoid_port;
int32_t status = 0;
setSolenoid((void*)solenoid_port, value, &status);
CheckStatus(env, status);
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_setSolenoid(
JNIEnv *env, jclass, jlong solenoid_port, jboolean value) {
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI SetSolenoid";
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = "
<< (void *)solenoid_port;
int32_t status = 0;
setSolenoid((void *)solenoid_port, value, &status);
CheckStatus(env, status);
}
/*
@@ -97,13 +103,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_setSolenoid
* Method: getSolenoid
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
jboolean val = getSolenoid((void*)solenoid_port, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid(
JNIEnv *env, jclass, jlong solenoid_port) {
int32_t status = 0;
jboolean val = getSolenoid((void *)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -111,13 +117,13 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoi
* Method: getAllSolenoids
* Signature: (J)Z
*/
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoids
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
jbyte val = getAllSolenoids((void*)solenoid_port, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jbyte JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoids(
JNIEnv *env, jclass, jlong solenoid_port) {
int32_t status = 0;
jbyte val = getAllSolenoids((void *)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
@@ -125,51 +131,51 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoi
* Method: getPCMSolenoidBlackList
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
jint val = getPCMSolenoidBlackList((void*)solenoid_port, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList(
JNIEnv *env, jclass, jlong solenoid_port) {
int32_t status = 0;
jint val = getPCMSolenoidBlackList((void *)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getPCMSolenoidVoltageStickyFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
bool val = getPCMSolenoidVoltageStickyFault((void*)solenoid_port, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault(
JNIEnv *env, jclass, jlong solenoid_port) {
int32_t status = 0;
bool val = getPCMSolenoidVoltageStickyFault((void *)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getPCMSolenoidVoltageFault
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
bool val = getPCMSolenoidVoltageFault((void*)solenoid_port, &status);
CheckStatus(env, status);
return val;
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault(
JNIEnv *env, jclass, jlong solenoid_port) {
int32_t status = 0;
bool val = getPCMSolenoidVoltageFault((void *)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: clearAllPCMStickyFaults
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
clearAllPCMStickyFaults_sol((void*)solenoid_port, &status);
CheckStatus(env, status);
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults(
JNIEnv *env, jclass, jlong solenoid_port) {
int32_t status = 0;
clearAllPCMStickyFaults_sol((void *)solenoid_port, &status);
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -5,29 +5,59 @@
/* the project. */
/*----------------------------------------------------------------------------*/
IMAQdxError NI_FUNC IMAQdxGetAttributeU32(IMAQdxSession id, const char* name, uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeI64(IMAQdxSession id, const char* name, Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeF64(IMAQdxSession id, const char* name, float64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeString(IMAQdxSession id, const char* name, char value[IMAQDX_MAX_API_STRING_LENGTH]);
IMAQdxError NI_FUNC IMAQdxGetAttributeEnum(IMAQdxSession id, const char* name, IMAQdxEnumItem* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeBool(IMAQdxSession id, const char* name, bool32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeU32(IMAQdxSession id, const char* name,
uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeI64(IMAQdxSession id, const char* name,
Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeF64(IMAQdxSession id, const char* name,
float64* value);
IMAQdxError NI_FUNC
IMAQdxGetAttributeString(IMAQdxSession id, const char* name,
char value[IMAQDX_MAX_API_STRING_LENGTH]);
IMAQdxError NI_FUNC IMAQdxGetAttributeEnum(IMAQdxSession id, const char* name,
IMAQdxEnumItem* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeBool(IMAQdxSession id, const char* name,
bool32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMinimumU32(IMAQdxSession id, const char* name, uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMinimumI64(IMAQdxSession id, const char* name, Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMinimumF64(IMAQdxSession id, const char* name, float64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMinimumU32(IMAQdxSession id,
const char* name,
uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMinimumI64(IMAQdxSession id,
const char* name,
Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMinimumF64(IMAQdxSession id,
const char* name,
float64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMaximumU32(IMAQdxSession id, const char* name, uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMaximumI64(IMAQdxSession id, const char* name, Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMaximumF64(IMAQdxSession id, const char* name, float64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMaximumU32(IMAQdxSession id,
const char* name,
uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMaximumI64(IMAQdxSession id,
const char* name,
Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeMaximumF64(IMAQdxSession id,
const char* name,
float64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeIncrementU32(IMAQdxSession id, const char* name, uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeIncrementI64(IMAQdxSession id, const char* name, Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeIncrementF64(IMAQdxSession id, const char* name, float64* value);
IMAQdxError NI_FUNC IMAQdxSetAttributeU32(IMAQdxSession id, const char* name, uInt32 value);
IMAQdxError NI_FUNC IMAQdxSetAttributeI64(IMAQdxSession id, const char* name, Int64 value);
IMAQdxError NI_FUNC IMAQdxSetAttributeF64(IMAQdxSession id, const char* name, float64 value);
IMAQdxError NI_FUNC IMAQdxSetAttributeString(IMAQdxSession id, const char* name, const char* value);
IMAQdxError NI_FUNC IMAQdxSetAttributeEnum(IMAQdxSession id, const char* name, const IMAQdxEnumItem* value);
IMAQdxError NI_FUNC IMAQdxSetAttributeBool(IMAQdxSession id, const char* name, bool32 value);
IMAQdxError NI_FUNC IMAQdxGetAttributeIncrementU32(IMAQdxSession id,
const char* name,
uInt32* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeIncrementI64(IMAQdxSession id,
const char* name,
Int64* value);
IMAQdxError NI_FUNC IMAQdxGetAttributeIncrementF64(IMAQdxSession id,
const char* name,
float64* value);
IMAQdxError NI_FUNC IMAQdxSetAttributeU32(IMAQdxSession id, const char* name,
uInt32 value);
IMAQdxError NI_FUNC IMAQdxSetAttributeI64(IMAQdxSession id, const char* name,
Int64 value);
IMAQdxError NI_FUNC IMAQdxSetAttributeF64(IMAQdxSession id, const char* name,
float64 value);
IMAQdxError NI_FUNC IMAQdxSetAttributeString(IMAQdxSession id, const char* name,
const char* value);
IMAQdxError NI_FUNC IMAQdxSetAttributeEnum(IMAQdxSession id, const char* name,
const IMAQdxEnumItem* value);
IMAQdxError NI_FUNC IMAQdxSetAttributeBool(IMAQdxSession id, const char* name,
bool32 value);