2016-05-25 20:23:37 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-01-01 01:05:57 -07:00
|
|
|
/* Copyright (c) FIRST 2016-2017. All Rights Reserved. */
|
2016-05-25 20:23:37 -07:00
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2017-05-08 20:21:47 -07:00
|
|
|
#include <atomic>
|
2016-12-02 00:32:01 -08:00
|
|
|
#include <chrono>
|
2016-07-10 23:10:05 -07:00
|
|
|
#include <cstdlib>
|
2015-11-15 14:49:50 -08:00
|
|
|
#include <cstring>
|
2016-07-12 10:45:14 -07:00
|
|
|
#include <limits>
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
#include "FRC_NetworkCommunication/FRCComm.h"
|
2016-12-02 00:32:01 -08:00
|
|
|
#include "HAL/DriverStation.h"
|
2016-07-17 19:42:33 -07:00
|
|
|
#include "HAL/cpp/priority_condition_variable.h"
|
|
|
|
|
#include "HAL/cpp/priority_mutex.h"
|
2017-06-30 22:33:43 -04:00
|
|
|
#include "llvm/raw_ostream.h"
|
2015-08-19 11:12:54 -04:00
|
|
|
|
2016-09-06 19:39:28 -07:00
|
|
|
static_assert(sizeof(int32_t) >= sizeof(int),
|
|
|
|
|
"FRC_NetworkComm status variable is larger than 32 bits");
|
|
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
struct HAL_JoystickAxesInt {
|
2016-09-06 19:39:28 -07:00
|
|
|
int16_t count;
|
2016-07-09 00:24:26 -07:00
|
|
|
int16_t axes[HAL_kMaxJoystickAxes];
|
2016-05-21 01:42:16 -07:00
|
|
|
};
|
|
|
|
|
|
2017-05-11 21:25:22 -07:00
|
|
|
static hal::priority_mutex msgMutex;
|
|
|
|
|
static hal::priority_condition_variable newDSDataAvailableCond;
|
|
|
|
|
static hal::priority_mutex newDSDataAvailableMutex;
|
2017-05-08 20:21:47 -07:00
|
|
|
static int newDSDataAvailableCounter{0};
|
2016-07-17 19:42:33 -07:00
|
|
|
|
2015-11-26 00:08:32 -08:00
|
|
|
extern "C" {
|
2016-07-17 19:42:33 -07:00
|
|
|
int32_t HAL_SetErrorData(const char* errors, int32_t errorsLength,
|
2016-08-12 13:45:28 -07:00
|
|
|
int32_t waitMs) {
|
|
|
|
|
return setErrorData(errors, errorsLength, waitMs);
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
|
|
|
|
|
const char* details, const char* location,
|
|
|
|
|
const char* callStack, HAL_Bool printMsg) {
|
|
|
|
|
// Avoid flooding console by keeping track of previous 5 error
|
|
|
|
|
// messages and only printing again if they're longer than 1 second old.
|
|
|
|
|
static constexpr int KEEP_MSGS = 5;
|
2017-05-11 21:25:22 -07:00
|
|
|
std::lock_guard<hal::priority_mutex> lock(msgMutex);
|
2016-08-12 13:45:28 -07:00
|
|
|
static std::string prevMsg[KEEP_MSGS];
|
2016-12-02 00:32:01 -08:00
|
|
|
static std::chrono::time_point<std::chrono::steady_clock>
|
|
|
|
|
prevMsgTime[KEEP_MSGS];
|
|
|
|
|
static bool initialized = false;
|
|
|
|
|
if (!initialized) {
|
|
|
|
|
for (int i = 0; i < KEEP_MSGS; i++) {
|
|
|
|
|
prevMsgTime[i] =
|
|
|
|
|
std::chrono::steady_clock::now() - std::chrono::seconds(2);
|
|
|
|
|
}
|
|
|
|
|
initialized = true;
|
|
|
|
|
}
|
2016-07-17 19:42:33 -07:00
|
|
|
|
2016-12-02 00:32:01 -08:00
|
|
|
auto curTime = std::chrono::steady_clock::now();
|
2016-07-17 19:42:33 -07:00
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < KEEP_MSGS; ++i) {
|
2016-08-12 13:45:28 -07:00
|
|
|
if (prevMsg[i] == details) break;
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
|
|
|
|
int retval = 0;
|
2016-12-02 00:32:01 -08:00
|
|
|
if (i == KEEP_MSGS || (curTime - prevMsgTime[i]) >= std::chrono::seconds(1)) {
|
2016-07-17 19:42:33 -07:00
|
|
|
retval = FRC_NetworkCommunication_sendError(isError, errorCode, isLVCode,
|
|
|
|
|
details, location, callStack);
|
|
|
|
|
if (printMsg) {
|
|
|
|
|
if (location && location[0] != '\0') {
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::errs() << (isError ? "Error" : "Warning") << " at " << location
|
|
|
|
|
<< ": ";
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::errs() << details << "\n";
|
2016-07-17 19:42:33 -07:00
|
|
|
if (callStack && callStack[0] != '\0') {
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::errs() << callStack << "\n";
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i == KEEP_MSGS) {
|
|
|
|
|
// replace the oldest one
|
|
|
|
|
i = 0;
|
2016-12-02 00:32:01 -08:00
|
|
|
auto first = prevMsgTime[0];
|
2016-07-17 19:42:33 -07:00
|
|
|
for (int j = 1; j < KEEP_MSGS; ++j) {
|
2016-08-12 13:45:28 -07:00
|
|
|
if (prevMsgTime[j] < first) {
|
|
|
|
|
first = prevMsgTime[j];
|
2016-07-17 19:42:33 -07:00
|
|
|
i = j;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-12 13:45:28 -07:00
|
|
|
prevMsg[i] = details;
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
2016-08-12 13:45:28 -07:00
|
|
|
prevMsgTime[i] = curTime;
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
2015-11-26 00:08:32 -08:00
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetControlWord(HAL_ControlWord* controlWord) {
|
2016-07-10 16:24:57 -07:00
|
|
|
std::memset(controlWord, 0, sizeof(HAL_ControlWord));
|
|
|
|
|
return FRC_NetworkCommunication_getControlWord(
|
|
|
|
|
reinterpret_cast<ControlWord_t*>(controlWord));
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
2016-07-10 16:24:57 -07:00
|
|
|
HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status) {
|
|
|
|
|
HAL_AllianceStationID allianceStation;
|
|
|
|
|
*status = FRC_NetworkCommunication_getAllianceStation(
|
|
|
|
|
reinterpret_cast<AllianceStationID_t*>(&allianceStation));
|
|
|
|
|
return allianceStation;
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes) {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_JoystickAxesInt axesInt;
|
2016-05-22 21:39:33 -07:00
|
|
|
|
2016-05-21 01:42:16 -07:00
|
|
|
int retVal = FRC_NetworkCommunication_getJoystickAxes(
|
2016-07-10 17:47:44 -07:00
|
|
|
joystickNum, reinterpret_cast<JoystickAxes_t*>(&axesInt),
|
|
|
|
|
HAL_kMaxJoystickAxes);
|
2016-05-22 21:39:33 -07:00
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
// copy integer values to double values
|
2016-05-21 01:42:16 -07:00
|
|
|
axes->count = axesInt.count;
|
2016-05-22 21:39:33 -07:00
|
|
|
// current scaling is -128 to 127, can easily be patched in the future by
|
2016-05-21 01:42:16 -07:00
|
|
|
// changing this function.
|
2016-09-06 19:39:28 -07:00
|
|
|
for (int32_t i = 0; i < axesInt.count; i++) {
|
2016-05-21 01:42:16 -07:00
|
|
|
int8_t value = axesInt.axes[i];
|
|
|
|
|
if (value < 0) {
|
2016-11-20 07:25:03 -08:00
|
|
|
axes->axes[i] = value / 128.0;
|
2016-05-21 01:42:16 -07:00
|
|
|
} else {
|
2016-11-20 07:25:03 -08:00
|
|
|
axes->axes[i] = value / 127.0;
|
2016-05-21 01:42:16 -07:00
|
|
|
}
|
|
|
|
|
}
|
2016-05-22 21:39:33 -07:00
|
|
|
|
2016-05-21 01:42:16 -07:00
|
|
|
return retVal;
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return FRC_NetworkCommunication_getJoystickPOVs(
|
2016-07-10 17:47:44 -07:00
|
|
|
joystickNum, reinterpret_cast<JoystickPOV_t*>(povs),
|
|
|
|
|
HAL_kMaxJoystickPOVs);
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetJoystickButtons(int32_t joystickNum,
|
|
|
|
|
HAL_JoystickButtons* buttons) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return FRC_NetworkCommunication_getJoystickButtons(
|
|
|
|
|
joystickNum, &buttons->buttons, &buttons->count);
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
2016-01-15 13:13:02 -05:00
|
|
|
/**
|
|
|
|
|
* Retrieve the Joystick Descriptor for particular slot
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param desc [out] descriptor (data transfer object) to fill in. desc is
|
|
|
|
|
* filled in regardless of success. In other words, if descriptor is not
|
|
|
|
|
* available, desc is filled in with default values matching the init-values in
|
|
|
|
|
* Java and C++ Driverstation for when caller requests a too-large joystick
|
|
|
|
|
* index.
|
2016-01-15 13:13:02 -05:00
|
|
|
*
|
2016-05-20 17:30:37 -07:00
|
|
|
* @return error code reported from Network Comm back-end. Zero is good,
|
|
|
|
|
* nonzero is bad.
|
2016-01-15 13:13:02 -05:00
|
|
|
*/
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetJoystickDescriptor(int32_t joystickNum,
|
|
|
|
|
HAL_JoystickDescriptor* desc) {
|
2016-05-20 17:30:37 -07:00
|
|
|
desc->isXbox = 0;
|
2016-07-12 10:45:14 -07:00
|
|
|
desc->type = std::numeric_limits<uint8_t>::max();
|
2016-05-20 17:30:37 -07:00
|
|
|
desc->name[0] = '\0';
|
|
|
|
|
desc->axisCount =
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_kMaxJoystickAxes; /* set to the desc->axisTypes's capacity */
|
2016-05-20 17:30:37 -07:00
|
|
|
desc->buttonCount = 0;
|
|
|
|
|
desc->povCount = 0;
|
|
|
|
|
int retval = FRC_NetworkCommunication_getJoystickDesc(
|
2016-07-10 17:47:44 -07:00
|
|
|
joystickNum, &desc->isXbox, &desc->type,
|
|
|
|
|
reinterpret_cast<char*>(&desc->name), &desc->axisCount,
|
|
|
|
|
reinterpret_cast<uint8_t*>(&desc->axisTypes), &desc->buttonCount,
|
2016-05-20 17:30:37 -07:00
|
|
|
&desc->povCount);
|
|
|
|
|
/* check the return, if there is an error and the RIOimage predates FRC2017,
|
|
|
|
|
* then axisCount needs to be cleared */
|
|
|
|
|
if (retval != 0) {
|
|
|
|
|
/* set count to zero so downstream code doesn't decode invalid axisTypes. */
|
|
|
|
|
desc->axisCount = 0;
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetJoystickIsXbox(int32_t joystickNum) {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_JoystickDescriptor joystickDesc;
|
|
|
|
|
if (HAL_GetJoystickDescriptor(joystickNum, &joystickDesc) < 0) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
return joystickDesc.isXbox;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetJoystickType(int32_t joystickNum) {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_JoystickDescriptor joystickDesc;
|
|
|
|
|
if (HAL_GetJoystickDescriptor(joystickNum, &joystickDesc) < 0) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
return joystickDesc.type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
char* HAL_GetJoystickName(int32_t joystickNum) {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_JoystickDescriptor joystickDesc;
|
|
|
|
|
if (HAL_GetJoystickDescriptor(joystickNum, &joystickDesc) < 0) {
|
2016-07-10 17:47:44 -07:00
|
|
|
char* name = static_cast<char*>(std::malloc(1));
|
2016-05-20 17:30:37 -07:00
|
|
|
name[0] = '\0';
|
|
|
|
|
return name;
|
|
|
|
|
} else {
|
|
|
|
|
size_t len = std::strlen(joystickDesc.name);
|
2016-07-10 17:47:44 -07:00
|
|
|
char* name = static_cast<char*>(std::malloc(len + 1));
|
|
|
|
|
std::strncpy(name, joystickDesc.name, len);
|
|
|
|
|
name[len] = '\0';
|
2016-05-20 17:30:37 -07:00
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-30 16:11:16 -07:00
|
|
|
void HAL_FreeJoystickName(char* name) { std::free(name); }
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_GetJoystickAxisType(int32_t joystickNum, int32_t axis) {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_JoystickDescriptor joystickDesc;
|
|
|
|
|
if (HAL_GetJoystickDescriptor(joystickNum, &joystickDesc) < 0) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
return joystickDesc.axisTypes[axis];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t HAL_SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
|
|
|
|
|
int32_t leftRumble, int32_t rightRumble) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return FRC_NetworkCommunication_setJoystickOutputs(joystickNum, outputs,
|
|
|
|
|
leftRumble, rightRumble);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-13 19:25:57 -07:00
|
|
|
double HAL_GetMatchTime(int32_t* status) {
|
2016-07-10 16:24:57 -07:00
|
|
|
float matchTime;
|
|
|
|
|
*status = FRC_NetworkCommunication_getMatchTime(&matchTime);
|
|
|
|
|
return matchTime;
|
2016-05-20 17:30:37 -07:00
|
|
|
}
|
|
|
|
|
|
2016-07-10 16:24:57 -07:00
|
|
|
void HAL_ObserveUserProgramStarting(void) {
|
2016-05-20 17:30:37 -07:00
|
|
|
FRC_NetworkCommunication_observeUserProgramStarting();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 16:24:57 -07:00
|
|
|
void HAL_ObserveUserProgramDisabled(void) {
|
2016-05-20 17:30:37 -07:00
|
|
|
FRC_NetworkCommunication_observeUserProgramDisabled();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 16:24:57 -07:00
|
|
|
void HAL_ObserveUserProgramAutonomous(void) {
|
2016-05-20 17:30:37 -07:00
|
|
|
FRC_NetworkCommunication_observeUserProgramAutonomous();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 16:24:57 -07:00
|
|
|
void HAL_ObserveUserProgramTeleop(void) {
|
2016-05-20 17:30:37 -07:00
|
|
|
FRC_NetworkCommunication_observeUserProgramTeleop();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 16:24:57 -07:00
|
|
|
void HAL_ObserveUserProgramTest(void) {
|
2016-05-20 17:30:37 -07:00
|
|
|
FRC_NetworkCommunication_observeUserProgramTest();
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
2015-11-26 00:08:32 -08:00
|
|
|
|
2017-05-08 20:21:47 -07:00
|
|
|
bool HAL_IsNewControlData(void) {
|
|
|
|
|
// There is a rollover error condition here. At Packet# = n * (uintmax), this
|
|
|
|
|
// will return false when instead it should return true. However, this at a
|
|
|
|
|
// 20ms rate occurs once every 2.7 years of DS connected runtime, so not
|
|
|
|
|
// worth the cycles to check.
|
|
|
|
|
thread_local int lastCount{-1};
|
|
|
|
|
int currentCount = 0;
|
|
|
|
|
{
|
2017-05-11 21:25:22 -07:00
|
|
|
std::unique_lock<hal::priority_mutex> lock(newDSDataAvailableMutex);
|
2017-05-08 20:21:47 -07:00
|
|
|
currentCount = newDSDataAvailableCounter;
|
|
|
|
|
}
|
|
|
|
|
if (lastCount == currentCount) return false;
|
|
|
|
|
lastCount = currentCount;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-17 19:42:33 -07:00
|
|
|
/**
|
|
|
|
|
* Waits for the newest DS packet to arrive. Note that this is a blocking call.
|
|
|
|
|
*/
|
2017-05-08 20:21:47 -07:00
|
|
|
void HAL_WaitForDSData(void) { HAL_WaitForDSDataTimeout(0); }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Waits for the newest DS packet to arrive. If timeout is <= 0, this will wait
|
|
|
|
|
* forever. Otherwise, it will wait until either a new packet, or the timeout
|
|
|
|
|
* time has passed. Returns true on new data, false on timeout.
|
|
|
|
|
*/
|
|
|
|
|
HAL_Bool HAL_WaitForDSDataTimeout(double timeout) {
|
|
|
|
|
auto timeoutTime =
|
|
|
|
|
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
|
|
|
|
|
|
2017-05-11 21:25:22 -07:00
|
|
|
std::unique_lock<hal::priority_mutex> lock(newDSDataAvailableMutex);
|
2017-05-08 20:21:47 -07:00
|
|
|
int currentCount = newDSDataAvailableCounter;
|
|
|
|
|
while (newDSDataAvailableCounter == currentCount) {
|
|
|
|
|
if (timeout > 0) {
|
|
|
|
|
auto timedOut = newDSDataAvailableCond.wait_until(lock, timeoutTime);
|
|
|
|
|
if (timedOut == std::cv_status::timeout) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
newDSDataAvailableCond.wait(lock);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-08 20:21:47 -07:00
|
|
|
// Internal NetComm function to set new packet callback
|
|
|
|
|
extern int NetCommRPCProxy_SetOccurFuncPointer(
|
|
|
|
|
int32_t (*occurFunc)(uint32_t refNum));
|
|
|
|
|
|
|
|
|
|
// Constant number to be used for our occur handle
|
|
|
|
|
constexpr int32_t refNumber = 42;
|
|
|
|
|
|
|
|
|
|
static int32_t newDataOccur(uint32_t refNum) {
|
|
|
|
|
// Since we could get other values, require our specific handle
|
|
|
|
|
// to signal our threads
|
|
|
|
|
if (refNum != refNumber) return 0;
|
2017-05-11 21:25:22 -07:00
|
|
|
std::lock_guard<hal::priority_mutex> lock(newDSDataAvailableMutex);
|
2017-05-08 20:21:47 -07:00
|
|
|
// Nofify all threads
|
|
|
|
|
newDSDataAvailableCounter++;
|
|
|
|
|
newDSDataAvailableCond.notify_all();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Call this to initialize the driver station communication. This will properly
|
|
|
|
|
* handle multiple calls. However note that this CANNOT be called from a library
|
|
|
|
|
* that interfaces with LabVIEW.
|
|
|
|
|
*/
|
2016-07-17 19:42:33 -07:00
|
|
|
void HAL_InitializeDriverStation(void) {
|
2017-05-08 20:21:47 -07:00
|
|
|
static std::atomic_bool initialized{false};
|
2017-05-11 21:25:22 -07:00
|
|
|
static hal::priority_mutex initializeMutex;
|
2017-05-08 20:21:47 -07:00
|
|
|
// Initial check, as if it's true initialization has finished
|
|
|
|
|
if (initialized) return;
|
|
|
|
|
|
2017-05-11 21:25:22 -07:00
|
|
|
std::lock_guard<hal::priority_mutex> lock(initializeMutex);
|
2017-05-08 20:21:47 -07:00
|
|
|
// Second check in case another thread was waiting
|
|
|
|
|
if (initialized) return;
|
|
|
|
|
|
|
|
|
|
// Set up the occur function internally with NetComm
|
|
|
|
|
NetCommRPCProxy_SetOccurFuncPointer(newDataOccur);
|
|
|
|
|
// Set up our occur reference number
|
|
|
|
|
setNewDataOccurRef(refNumber);
|
|
|
|
|
|
|
|
|
|
initialized = true;
|
2016-07-17 19:42:33 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-08 20:21:47 -07:00
|
|
|
/*
|
|
|
|
|
* Releases the DS Mutex to allow proper shutdown of any threads that are
|
|
|
|
|
* waiting on it.
|
|
|
|
|
*/
|
|
|
|
|
void HAL_ReleaseDSMutex(void) { newDataOccur(refNumber); }
|
|
|
|
|
|
2015-11-26 00:08:32 -08:00
|
|
|
} // extern "C"
|