2016-01-02 03:02:34 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2014-01-06 09:27:51 -05:00
|
|
|
#include <assert.h>
|
2016-05-20 17:30:37 -07:00
|
|
|
#include <jni.h>
|
2014-05-02 17:54:01 -04:00
|
|
|
#include "Log.hpp"
|
2014-01-06 09:27:51 -05:00
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#include "HAL/HAL.hpp"
|
2016-05-20 17:30:37 -07:00
|
|
|
#include "edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary.h"
|
2014-01-06 09:27:51 -05:00
|
|
|
//#include "NetworkCommunication/FRCComm.h"
|
|
|
|
|
//#include "NetworkCommunication/UsageReporting.h"
|
2015-11-01 09:11:52 -08:00
|
|
|
#include "HALUtil.h"
|
2014-01-06 09:27:51 -05:00
|
|
|
|
2014-05-30 10:08:29 -04:00
|
|
|
// set the logging level
|
|
|
|
|
TLogLevel netCommLogLevel = logWARNING;
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
#define NETCOMM_LOG(level) \
|
|
|
|
|
if (level > netCommLogLevel) \
|
|
|
|
|
; \
|
|
|
|
|
else \
|
|
|
|
|
Log().Get(level)
|
2014-05-30 10:08:29 -04:00
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
extern "C" {
|
2014-01-06 09:27:51 -05:00
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRC_NetworkCommunication_nUsageReporting_report
|
|
|
|
|
* Signature: (BBBLjava/lang/String;)I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRC_NetworkCommunication_observeUserProgramStarting
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramStarting(
|
|
|
|
|
JNIEnv *, jclass) {
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramStarting();
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRC_NetworkCommunication_observeUserProgramDisabled
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramDisabled(
|
|
|
|
|
JNIEnv *, jclass) {
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramDisabled();
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRC_NetworkCommunication_observeUserProgramAutonomous
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramAutonomous(
|
|
|
|
|
JNIEnv *, jclass) {
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramAutonomous();
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRC_NetworkCommunication_observeUserProgramTeleop
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramTeleop(
|
|
|
|
|
JNIEnv *, jclass) {
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramTeleop();
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRC_NetworkCommunication_observeUserProgramTest
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationObserveUserProgramTest(
|
|
|
|
|
JNIEnv *, jclass) {
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramTest();
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-01-06 09:27:51 -05:00
|
|
|
* Method: FRCNetworkCommunicationReserve
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_FRCNetworkCommunicationReserve(
|
|
|
|
|
JNIEnv *, jclass) {
|
|
|
|
|
int rv = HALInitialize(0);
|
|
|
|
|
assert(1 == rv);
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
|
2014-08-06 11:29:15 -04:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-08-06 11:29:15 -04:00
|
|
|
* Method: NativeHALGetControlWord
|
|
|
|
|
* Signature: ()I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
2014-08-06 11:29:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-08-06 11:29:15 -04:00
|
|
|
* Method: NativeHALGetAllianceStation
|
|
|
|
|
* Signature: ()I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
2014-08-06 11:29:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-08-06 11:29:15 -04:00
|
|
|
* Method: HALGetJoystickAxes
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
* Signature: (B[S)B
|
2014-08-06 11:29:15 -04:00
|
|
|
*/
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
JNIEXPORT jbyte JNICALL
|
2016-05-20 17:30:37 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxes(
|
2016-05-21 01:42:16 -07:00
|
|
|
JNIEnv * env, jclass, jbyte joystickNum, jfloatArray axesArray) {
|
2016-05-20 17:30:37 -07:00
|
|
|
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickAxes";
|
|
|
|
|
HALJoystickAxes axes;
|
|
|
|
|
HALGetJoystickAxes(joystickNum, &axes);
|
2014-08-06 11:29:15 -04:00
|
|
|
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
jsize javaSize = env->GetArrayLength(axesArray);
|
|
|
|
|
if (axes.count > javaSize)
|
|
|
|
|
{
|
|
|
|
|
ThrowIllegalArgumentException(env, "Native array size larger then passed in java array size");
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-21 01:42:16 -07:00
|
|
|
env->SetFloatArrayRegion(axesArray, 0, axes.count, axes.axes);
|
2014-08-06 11:29:15 -04:00
|
|
|
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
return axes.count;
|
2014-08-06 11:29:15 -04:00
|
|
|
}
|
|
|
|
|
|
2014-10-17 14:46:25 -04:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-10-17 14:46:25 -04:00
|
|
|
* Method: HALGetJoystickPOVs
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
* Signature: (B[S)B
|
2014-10-17 14:46:25 -04:00
|
|
|
*/
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
JNIEXPORT jbyte JNICALL
|
2016-05-20 17:30:37 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickPOVs(
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
JNIEnv * env, jclass, jbyte joystickNum, jshortArray povsArray) {
|
2016-05-20 17:30:37 -07:00
|
|
|
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickPOVs";
|
|
|
|
|
HALJoystickPOVs povs;
|
|
|
|
|
HALGetJoystickPOVs(joystickNum, &povs);
|
2014-10-17 14:46:25 -04:00
|
|
|
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
jsize javaSize = env->GetArrayLength(povsArray);
|
|
|
|
|
if (povs.count > javaSize)
|
|
|
|
|
{
|
|
|
|
|
ThrowIllegalArgumentException(env, "Native array size larger then passed in java array size");
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
env->SetShortArrayRegion(povsArray, 0, povs.count, povs.povs);
|
2014-10-17 14:46:25 -04:00
|
|
|
|
Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
Currently, about 5ms of every 20ms loop the DS thread would hold
the mutex, while grabbing data. During this time, and call to grab
joystick data would be blocked. This change grabs the joystick data
to a cache, and then grabs the mutex and moves the data references
around. This is much more efficient then the old code, and gives
teams more of their teleop loop time back for use.
Another major change this does is use preallocated arrays when entering
the JNI. Previously every JNI DS call would allocate an entire new array.
With a GC'd language where those arrays go on the heap, thats a problem,
and creates tons of garbage. That garbage is no longer created anymore,
as all arrays and byte buffers sent to JNI in the DS are preallocated.
In addition, GetJoystickName was always returning joystick 0 data, which
this fixes.
2016-05-21 00:41:15 -07:00
|
|
|
return povs.count;
|
2014-10-17 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
2014-08-06 11:29:15 -04:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-08-06 11:29:15 -04:00
|
|
|
* Method: HALGetJoystickButtons
|
|
|
|
|
* Signature: (B)S
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
2014-08-06 11:29:15 -04:00
|
|
|
}
|
|
|
|
|
|
2014-12-05 12:24:50 -05:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-12-05 12:24:50 -05:00
|
|
|
* Method: HALSetJoystickOutputs
|
|
|
|
|
* Signature: (BISS)I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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);
|
2014-12-05 12:24:50 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-15 12:34:57 -04:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2015-06-15 12:34:57 -04:00
|
|
|
* Method: HALGetJoystickIsXbox
|
|
|
|
|
* Signature: (B)I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickIsXbox(
|
|
|
|
|
JNIEnv *, jclass, jbyte port) {
|
|
|
|
|
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickIsXbox";
|
|
|
|
|
return HALGetJoystickIsXbox(port);
|
|
|
|
|
}
|
2015-06-15 12:34:57 -04:00
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2015-06-15 12:34:57 -04:00
|
|
|
* Method: HALGetJoystickType
|
|
|
|
|
* Signature: (B)I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickType(
|
|
|
|
|
JNIEnv *, jclass, jbyte port) {
|
|
|
|
|
NETCOMM_LOG(logDEBUG) << "Calling HALGetJoystickType";
|
|
|
|
|
return HALGetJoystickType(port);
|
|
|
|
|
}
|
2015-06-15 12:34:57 -04:00
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2015-06-15 12:34:57 -04:00
|
|
|
* Method: HALGetJoystickName
|
|
|
|
|
* Signature: (B)Ljava/lang/String;
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
|
|
|
|
}
|
2015-06-15 12:34:57 -04:00
|
|
|
|
2014-01-06 09:27:51 -05:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2015-12-13 17:40:58 -08:00
|
|
|
* Method: HALGetJoystickAxisType
|
|
|
|
|
* Signature: (BB)I
|
2014-01-06 09:27:51 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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);
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2015-12-13 17:40:58 -08:00
|
|
|
* Method: setNewDataSem
|
|
|
|
|
* Signature: (J)V
|
2014-01-06 09:27:51 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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);
|
2014-01-06 09:27:51 -05:00
|
|
|
}
|
2014-10-20 17:19:28 -04:00
|
|
|
|
2014-11-21 10:37:29 -05:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-11-21 10:37:29 -05:00
|
|
|
|
|
|
|
|
* Method: HALGetMatchTime
|
|
|
|
|
* Signature: ()F
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT jfloat JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetMatchTime(
|
|
|
|
|
JNIEnv *env, jclass) {
|
|
|
|
|
jfloat matchTime;
|
|
|
|
|
HALGetMatchTime((float *)&matchTime);
|
|
|
|
|
return matchTime;
|
2014-11-21 10:37:29 -05:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 10:56:25 -05:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-11-18 10:56:25 -05:00
|
|
|
* Method: HALGetSystemActive
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: ()Z
|
2014-11-18 10:56:25 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
2014-11-18 10:56:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-11-18 10:56:25 -05:00
|
|
|
* Method: HALGetBrownedOut
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: ()Z
|
2014-11-18 10:56:25 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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;
|
2014-11-18 10:56:25 -05:00
|
|
|
}
|
|
|
|
|
|
2014-10-20 17:19:28 -04:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2014-10-20 17:19:28 -04:00
|
|
|
* Method: HALSetErrorData
|
|
|
|
|
* Signature: (Ljava/lang/String;)I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALSetErrorData(
|
|
|
|
|
JNIEnv *env, jclass, jstring error) {
|
|
|
|
|
const char *errorStr = env->GetStringUTFChars(error, NULL);
|
2014-10-20 17:19:28 -04:00
|
|
|
jsize length = env->GetStringUTFLength(error);
|
2015-08-19 11:12:54 -04:00
|
|
|
|
2014-10-20 17:19:28 -04:00
|
|
|
NETCOMM_LOG(logDEBUG) << "Set Error: " << errorStr;
|
|
|
|
|
NETCOMM_LOG(logDEBUG) << "Length: " << length;
|
2016-05-20 17:30:37 -07:00
|
|
|
jint returnValue = HALSetErrorData(errorStr, (jint)length, 0);
|
|
|
|
|
env->ReleaseStringUTFChars(error, errorStr);
|
2014-10-20 17:19:28 -04:00
|
|
|
return returnValue;
|
|
|
|
|
}
|
2015-08-19 11:12:54 -04:00
|
|
|
|
2016-02-04 22:29:11 -08:00
|
|
|
/*
|
2016-05-20 17:30:37 -07:00
|
|
|
* Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary
|
2016-02-04 22:29:11 -08:00
|
|
|
* Method: HALSendError
|
|
|
|
|
* Signature: (ZIZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)I
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
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);
|
2016-02-04 22:29:11 -08:00
|
|
|
|
|
|
|
|
NETCOMM_LOG(logDEBUG) << "Send Error: " << detailsStr;
|
|
|
|
|
NETCOMM_LOG(logDEBUG) << "Location: " << locationStr;
|
|
|
|
|
NETCOMM_LOG(logDEBUG) << "Call Stack: " << callStackStr;
|
2016-05-20 17:30:37 -07:00
|
|
|
jint returnValue = HALSendError(isError, errorCode, isLVCode, detailsStr,
|
|
|
|
|
locationStr, callStackStr, printMsg);
|
|
|
|
|
env->ReleaseStringUTFChars(details, detailsStr);
|
|
|
|
|
env->ReleaseStringUTFChars(location, locationStr);
|
|
|
|
|
env->ReleaseStringUTFChars(callStack, callStackStr);
|
2016-02-04 22:29:11 -08:00
|
|
|
return returnValue;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
} // extern "C"
|