2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifdef __vxworks
|
|
|
|
|
#include <vxWorks.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _FUNCPTR_DEFINED
|
|
|
|
|
#define _FUNCPTR_DEFINED
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
typedef int (*FUNCPTR)(...);
|
|
|
|
|
/* ptr to function returning int */
|
|
|
|
|
#else
|
|
|
|
|
typedef int (*FUNCPTR) (); /* ptr to function returning int */
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
#endif /* _FUNCPTR_DEFINED */
|
|
|
|
|
|
|
|
|
|
#ifndef _STATUS_DEFINED
|
|
|
|
|
#define _STATUS_DEFINED
|
|
|
|
|
typedef int STATUS;
|
|
|
|
|
#endif /* _STATUS_DEFINED */
|
|
|
|
|
|
|
|
|
|
#ifndef OK
|
|
|
|
|
#define OK 0
|
|
|
|
|
#endif /* OK */
|
|
|
|
|
#ifndef ERROR
|
|
|
|
|
#define ERROR (-1)
|
|
|
|
|
#endif /* ERROR */
|
|
|
|
|
|
|
|
|
|
#ifdef __vxworks
|
|
|
|
|
#define NULL_TASK -1
|
|
|
|
|
typedef int32_t TASK;
|
|
|
|
|
#else
|
|
|
|
|
#define NULL_TASK NULL
|
|
|
|
|
typedef pthread_t* TASK;
|
|
|
|
|
#endif
|
|
|
|
|
|
This commit adds JNI bindings for the C++ Notifier.
The bindings only wrap the HAL interface, rather than the entire C++ Notifier,
as I ran into issues trying to wrap the whole Notifier (all the existing
bindings only wrap HAL components, so wrapping stuff in :wpilibc is
unexplored). As such, the new edu.wpi.first.wpilibj.Notifier is just a
re-implementation of the wpilibc/.../Notifier.cpp.
The purpose of doing this bindings is to allow Java users a better option
for running tasks which require good timing (such as control loops). The
previous method used java.util.Timer to schedule a task, causing various
issues. Although this update does improve things, Java loop timing is still
substantially worse than that of C++, and, even worse, if Java decides to call
the garbage collector at the wrong time then the loop can be delayed by
multiple milliseconds and the next iteration will be shorter to account for it
(although this particular behavior could be updated).
A few notes on individual components:
-the HAL Task.hpp and Task.cpp were modified due to compilation/linkage
issues with the JNI bindings. Nothing substantive changed.
-NotifierJNI was added to the build files for gradle.
-HALUtil was modified to include a function for getting the length of a C
pointer, rather than relying on it being 32-bit.
Change-Id: I966512d8a82c2a438ed8c8bbcc6cdc6ed186d0f2
2015-06-02 14:00:47 -04:00
|
|
|
extern "C" {
|
|
|
|
|
// Note: These constants used to be declared extern and were defined in
|
|
|
|
|
// Task.cpp. This caused issues with the JNI bindings for java, and so the
|
|
|
|
|
// instantiations were moved here.
|
|
|
|
|
const uint32_t VXWORKS_FP_TASK = 0x01000000;
|
|
|
|
|
const int32_t HAL_objLib_OBJ_ID_ERROR = -1; // TODO: update to relevant TaskIDError
|
|
|
|
|
const int32_t HAL_objLib_OBJ_DELETED = -1; // TODO: update to relevant TaskDeletedError
|
|
|
|
|
const int32_t HAL_taskLib_ILLEGAL_OPTIONS = -1; // TODO: update to relevant TaskOptionsError
|
|
|
|
|
const int32_t HAL_memLib_NOT_ENOUGH_MEMORY = -1; // TODO: update to relevant TaskMemoryError
|
|
|
|
|
const int32_t HAL_taskLib_ILLEGAL_PRIORITY = -1; // TODO: update to relevant TaskPriorityError
|
2014-05-02 17:54:01 -04:00
|
|
|
|
|
|
|
|
TASK spawnTask(char * name, int priority, int options, int stackSize, FUNCPTR entryPt,
|
|
|
|
|
uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
|
|
|
|
|
uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8, uint32_t arg9);
|
|
|
|
|
STATUS restartTask(TASK task);
|
|
|
|
|
STATUS deleteTask(TASK task);
|
|
|
|
|
STATUS isTaskReady(TASK task);
|
|
|
|
|
STATUS isTaskSuspended(TASK task);
|
|
|
|
|
STATUS suspendTask(TASK task);
|
|
|
|
|
STATUS resumeTask(TASK task);
|
|
|
|
|
STATUS verifyTaskID(TASK task);
|
|
|
|
|
STATUS setTaskPriority(TASK task, int priority);
|
|
|
|
|
STATUS getTaskPriority(TASK task, int* priority);
|
|
|
|
|
|
This commit adds JNI bindings for the C++ Notifier.
The bindings only wrap the HAL interface, rather than the entire C++ Notifier,
as I ran into issues trying to wrap the whole Notifier (all the existing
bindings only wrap HAL components, so wrapping stuff in :wpilibc is
unexplored). As such, the new edu.wpi.first.wpilibj.Notifier is just a
re-implementation of the wpilibc/.../Notifier.cpp.
The purpose of doing this bindings is to allow Java users a better option
for running tasks which require good timing (such as control loops). The
previous method used java.util.Timer to schedule a task, causing various
issues. Although this update does improve things, Java loop timing is still
substantially worse than that of C++, and, even worse, if Java decides to call
the garbage collector at the wrong time then the loop can be delayed by
multiple milliseconds and the next iteration will be shorter to account for it
(although this particular behavior could be updated).
A few notes on individual components:
-the HAL Task.hpp and Task.cpp were modified due to compilation/linkage
issues with the JNI bindings. Nothing substantive changed.
-NotifierJNI was added to the build files for gradle.
-HALUtil was modified to include a function for getting the length of a C
pointer, rather than relying on it being 32-bit.
Change-Id: I966512d8a82c2a438ed8c8bbcc6cdc6ed186d0f2
2015-06-02 14:00:47 -04:00
|
|
|
}
|