Files
allwpilib/hal/src/main/native/cpp/jni/HAL.cpp

166 lines
3.0 KiB
C++
Raw Normal View History

// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/HAL.h"
#include <jni.h>
2018-05-13 17:09:56 -07:00
#include <cassert>
#include <cstring>
#include <fmt/format.h>
2018-05-13 17:09:56 -07:00
#include <wpi/jni_util.h>
#include "HALUtil.h"
#include "edu_wpi_first_hal_HAL.h"
#include "hal/DriverStation.h"
#include "hal/Main.h"
using namespace hal;
using namespace wpi::java;
extern "C" {
/*
* Class: edu_wpi_first_hal_HAL
2018-05-13 17:09:56 -07:00
* Method: initialize
* Signature: (II)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_HAL_initialize
2018-05-13 17:09:56 -07:00
(JNIEnv*, jclass, jint timeout, jint mode)
{
return HAL_Initialize(timeout, mode);
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: shutdown
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_shutdown
(JNIEnv*, jclass)
{
return HAL_Shutdown();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: hasMain
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_HAL_hasMain
(JNIEnv*, jclass)
{
return HAL_HasMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: runMain
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_runMain
(JNIEnv*, jclass)
{
HAL_RunMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: exitMain
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_exitMain
(JNIEnv*, jclass)
{
HAL_ExitMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: simPeriodicBeforeNative
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_simPeriodicBeforeNative
(JNIEnv*, jclass)
{
HAL_SimPeriodicBefore();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: simPeriodicAfterNative
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_simPeriodicAfterNative
(JNIEnv*, jclass)
{
HAL_SimPeriodicAfter();
}
/*
* Class: edu_wpi_first_hal_HAL
2018-05-13 17:09:56 -07:00
* Method: getSystemActive
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_HAL_getSystemActive
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass)
{
int32_t status = 0;
bool val = HAL_GetSystemActive(&status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_hal_HAL
2018-05-13 17:09:56 -07:00
* Method: getBrownedOut
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_HAL_getBrownedOut
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass)
{
int32_t status = 0;
bool val = HAL_GetBrownedOut(&status);
CheckStatus(env, status);
return val;
}
2018-04-29 13:29:07 -07:00
/*
* Class: edu_wpi_first_hal_HAL
2018-04-29 13:29:07 -07:00
* Method: getPortWithModule
* Signature: (BB)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_HAL_getPortWithModule
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jbyte module, jbyte channel)
{
2018-04-29 13:29:07 -07:00
HAL_PortHandle port = HAL_GetPortWithModule(module, channel);
return (jint)port;
}
/*
* Class: edu_wpi_first_hal_HAL
2018-04-29 13:29:07 -07:00
* Method: getPort
* Signature: (B)I
*/
2018-05-13 17:09:56 -07:00
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_HAL_getPort
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jbyte channel)
{
2018-04-29 13:29:07 -07:00
HAL_PortHandle port = HAL_GetPort(channel);
return (jint)port;
}
} // extern "C"