2020-12-26 14:12:05 -08:00
|
|
|
// 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.
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/DriverStation.h"
|
2016-09-14 20:52:06 -07:00
|
|
|
|
2016-10-09 11:46:01 -07:00
|
|
|
#include <chrono>
|
2020-11-15 13:48:54 -05:00
|
|
|
#include <string>
|
2021-05-26 17:44:18 -07:00
|
|
|
#include <string_view>
|
2020-11-15 13:48:54 -05:00
|
|
|
#include <type_traits>
|
2016-10-09 11:46:01 -07:00
|
|
|
|
2019-11-08 22:53:20 -08:00
|
|
|
#include <hal/DriverStation.h>
|
|
|
|
|
#include <hal/HALBase.h>
|
2018-07-20 00:03:45 -07:00
|
|
|
#include <hal/Power.h>
|
2018-01-18 23:17:28 -08:00
|
|
|
#include <networktables/NetworkTable.h>
|
|
|
|
|
#include <networktables/NetworkTableEntry.h>
|
|
|
|
|
#include <networktables/NetworkTableInstance.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2021-04-18 20:35:29 -07:00
|
|
|
#include "frc/Errors.h"
|
2018-12-29 16:19:23 -08:00
|
|
|
#include "frc/MotorSafety.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/Timer.h"
|
2014-01-06 10:12:21 -05:00
|
|
|
|
2017-11-09 19:59:29 -08:00
|
|
|
namespace frc {
|
2020-11-15 13:48:54 -05:00
|
|
|
// A simple class which caches the previous value written to an NT entry
|
|
|
|
|
// Used to prevent redundant, repeated writes of the same value
|
|
|
|
|
template <class T>
|
|
|
|
|
class MatchDataSenderEntry {
|
|
|
|
|
public:
|
|
|
|
|
MatchDataSenderEntry(const std::shared_ptr<nt::NetworkTable>& table,
|
2021-05-26 17:44:18 -07:00
|
|
|
std::string_view key, const T& initialVal) {
|
2020-11-27 22:06:08 -08:00
|
|
|
static_assert(std::is_same_v<T, bool> || std::is_same_v<T, double> ||
|
|
|
|
|
std::is_same_v<T, std::string>,
|
|
|
|
|
"Invalid type for MatchDataSenderEntry - must be "
|
|
|
|
|
"to bool, double or std::string");
|
2020-11-15 13:48:54 -05:00
|
|
|
|
|
|
|
|
ntEntry = table->GetEntry(key);
|
2020-11-27 22:06:08 -08:00
|
|
|
if constexpr (std::is_same_v<T, bool>) {
|
2020-11-15 13:48:54 -05:00
|
|
|
ntEntry.ForceSetBoolean(initialVal);
|
2020-11-27 22:06:08 -08:00
|
|
|
} else if constexpr (std::is_same_v<T, double>) {
|
2020-11-15 13:48:54 -05:00
|
|
|
ntEntry.ForceSetDouble(initialVal);
|
2020-11-27 22:06:08 -08:00
|
|
|
} else if constexpr (std::is_same_v<T, std::string>) {
|
2020-11-15 13:48:54 -05:00
|
|
|
ntEntry.ForceSetString(initialVal);
|
|
|
|
|
}
|
|
|
|
|
prevVal = initialVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Set(const T& val) {
|
|
|
|
|
if (val != prevVal) {
|
|
|
|
|
SetValue(val);
|
|
|
|
|
prevVal = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
nt::NetworkTableEntry ntEntry;
|
|
|
|
|
T prevVal;
|
|
|
|
|
|
|
|
|
|
void SetValue(bool val) { ntEntry.SetBoolean(val); }
|
|
|
|
|
void SetValue(double val) { ntEntry.SetDouble(val); }
|
2021-05-26 17:44:18 -07:00
|
|
|
void SetValue(std::string_view val) { ntEntry.SetString(val); }
|
2020-11-15 13:48:54 -05:00
|
|
|
};
|
2018-01-18 23:17:28 -08:00
|
|
|
|
|
|
|
|
class MatchDataSender {
|
|
|
|
|
public:
|
|
|
|
|
std::shared_ptr<nt::NetworkTable> table;
|
2020-11-15 13:48:54 -05:00
|
|
|
MatchDataSenderEntry<std::string> typeMetaData;
|
|
|
|
|
MatchDataSenderEntry<std::string> gameSpecificMessage;
|
|
|
|
|
MatchDataSenderEntry<std::string> eventName;
|
|
|
|
|
MatchDataSenderEntry<double> matchNumber;
|
|
|
|
|
MatchDataSenderEntry<double> replayNumber;
|
|
|
|
|
MatchDataSenderEntry<double> matchType;
|
|
|
|
|
MatchDataSenderEntry<bool> alliance;
|
|
|
|
|
MatchDataSenderEntry<double> station;
|
|
|
|
|
MatchDataSenderEntry<double> controlWord;
|
|
|
|
|
|
|
|
|
|
MatchDataSender()
|
|
|
|
|
: table(nt::NetworkTableInstance::GetDefault().GetTable("FMSInfo")),
|
|
|
|
|
typeMetaData(table, ".type", "FMSInfo"),
|
|
|
|
|
gameSpecificMessage(table, "GameSpecificMessage", ""),
|
|
|
|
|
eventName(table, "EventName", ""),
|
|
|
|
|
matchNumber(table, "MatchNumber", 0.0),
|
|
|
|
|
replayNumber(table, "ReplayNumber", 0.0),
|
|
|
|
|
matchType(table, "MatchType", 0.0),
|
|
|
|
|
alliance(table, "IsRedAlliance", true),
|
|
|
|
|
station(table, "StationNumber", 1.0),
|
|
|
|
|
controlWord(table, "FMSControlData", 0.0) {}
|
2018-01-18 23:17:28 -08:00
|
|
|
};
|
2017-11-09 19:59:29 -08:00
|
|
|
} // namespace frc
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
static constexpr auto kJoystickUnpluggedMessageInterval = 1_s;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2020-07-13 21:57:54 -07:00
|
|
|
static int& GetDSLastCount() {
|
|
|
|
|
// 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{0};
|
|
|
|
|
return lastCount;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
DriverStation::~DriverStation() {
|
2014-08-14 00:07:02 -07:00
|
|
|
m_isRunning = false;
|
2017-11-28 19:12:05 -08:00
|
|
|
// Trigger a DS mutex release in case there is no driver station running.
|
|
|
|
|
HAL_ReleaseDSMutex();
|
2016-11-01 20:12:08 -07:00
|
|
|
m_dsThread.join();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
DriverStation& DriverStation::GetInstance() {
|
2016-06-19 00:13:18 -07:00
|
|
|
static DriverStation instance;
|
|
|
|
|
return instance;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2017-10-27 21:45:56 -07:00
|
|
|
bool DriverStation::GetStickButton(int stick, int button) {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
if (button <= 0) {
|
2017-10-27 21:45:56 -07:00
|
|
|
ReportJoystickUnpluggedError(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Button {} index out of range; indexes begin at 1", button);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickButtons buttons;
|
|
|
|
|
HAL_GetJoystickButtons(stick, &buttons);
|
|
|
|
|
|
|
|
|
|
if (button > buttons.count) {
|
2017-10-27 21:45:56 -07:00
|
|
|
ReportJoystickUnpluggedWarning(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Button {} missing (max {}), check if all controllers are "
|
|
|
|
|
"plugged in",
|
|
|
|
|
button, buttons.count);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
return buttons.buttons & 1 << (button - 1);
|
2017-10-27 21:45:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::GetStickButtonPressed(int stick, int button) {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
if (button <= 0) {
|
2017-10-27 21:45:56 -07:00
|
|
|
ReportJoystickUnpluggedError(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Button {} index out of range; indexes begin at 1", button);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickButtons buttons;
|
|
|
|
|
HAL_GetJoystickButtons(stick, &buttons);
|
|
|
|
|
|
|
|
|
|
if (button > buttons.count) {
|
2017-10-27 21:45:56 -07:00
|
|
|
ReportJoystickUnpluggedWarning(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Button {} missing (max {}), check if all controllers are "
|
|
|
|
|
"plugged in",
|
|
|
|
|
button, buttons.count);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-07-07 19:17:14 -07:00
|
|
|
std::unique_lock lock(m_buttonEdgeMutex);
|
2017-10-27 21:45:56 -07:00
|
|
|
// If button was pressed, clear flag and return true
|
|
|
|
|
if (m_joystickButtonsPressed[stick] & 1 << (button - 1)) {
|
|
|
|
|
m_joystickButtonsPressed[stick] &= ~(1 << (button - 1));
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::GetStickButtonReleased(int stick, int button) {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-12-07 01:31:14 -05:00
|
|
|
if (button <= 0) {
|
2017-10-27 21:45:56 -07:00
|
|
|
ReportJoystickUnpluggedError(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Button {} index out of range; indexes begin at 1", button);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickButtons buttons;
|
|
|
|
|
HAL_GetJoystickButtons(stick, &buttons);
|
|
|
|
|
|
|
|
|
|
if (button > buttons.count) {
|
2017-10-27 21:45:56 -07:00
|
|
|
ReportJoystickUnpluggedWarning(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Button {} missing (max {}), check if all controllers are "
|
|
|
|
|
"plugged in",
|
|
|
|
|
button, buttons.count);
|
2017-10-27 21:45:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-07-07 19:17:14 -07:00
|
|
|
std::unique_lock lock(m_buttonEdgeMutex);
|
2017-10-27 21:45:56 -07:00
|
|
|
// If button was released, clear flag and return true
|
|
|
|
|
if (m_joystickButtonsReleased[stick] & 1 << (button - 1)) {
|
|
|
|
|
m_joystickButtonsReleased[stick] &= ~(1 << (button - 1));
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double DriverStation::GetStickAxis(int stick, int axis) {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2018-05-16 00:13:52 -07:00
|
|
|
return 0.0;
|
|
|
|
|
}
|
2018-12-07 01:31:14 -05:00
|
|
|
if (axis < 0 || axis >= HAL_kMaxJoystickAxes) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickAxis, "axis {} out of range", axis);
|
2018-05-16 00:13:52 -07:00
|
|
|
return 0.0;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickAxes axes;
|
|
|
|
|
HAL_GetJoystickAxes(stick, &axes);
|
|
|
|
|
|
|
|
|
|
if (axis >= axes.count) {
|
2018-05-16 00:13:52 -07:00
|
|
|
ReportJoystickUnpluggedWarning(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick Axis {} missing (max {}), check if all controllers are "
|
|
|
|
|
"plugged in",
|
|
|
|
|
axis, axes.count);
|
2016-11-20 07:25:03 -08:00
|
|
|
return 0.0;
|
2016-07-14 20:50:38 -07:00
|
|
|
}
|
|
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
return axes.axes[axis];
|
2014-12-05 20:13:23 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetStickPOV(int stick, int pov) {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2016-07-14 20:50:38 -07:00
|
|
|
return -1;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-12-07 01:31:14 -05:00
|
|
|
if (pov < 0 || pov >= HAL_kMaxJoystickPOVs) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickAxis, "POV {} out of range", pov);
|
2018-05-16 00:13:52 -07:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickPOVs povs;
|
|
|
|
|
HAL_GetJoystickPOVs(stick, &povs);
|
|
|
|
|
|
|
|
|
|
if (pov >= povs.count) {
|
2018-05-16 00:13:52 -07:00
|
|
|
ReportJoystickUnpluggedWarning(
|
2021-05-24 23:36:26 -07:00
|
|
|
"Joystick POV {} missing (max {}), check if all controllers are "
|
|
|
|
|
"plugged in",
|
|
|
|
|
pov, povs.count);
|
2016-07-14 20:50:38 -07:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
return povs.povs[pov];
|
2015-06-15 12:34:57 -04:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetStickButtons(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2016-07-14 20:50:38 -07:00
|
|
|
return 0;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickButtons buttons;
|
|
|
|
|
HAL_GetJoystickButtons(stick, &buttons);
|
|
|
|
|
|
|
|
|
|
return buttons.buttons;
|
2015-06-15 12:34:57 -04:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetStickAxisCount(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2016-07-14 20:50:38 -07:00
|
|
|
return 0;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickAxes axes;
|
|
|
|
|
HAL_GetJoystickAxes(stick, &axes);
|
|
|
|
|
|
|
|
|
|
return axes.count;
|
2015-06-15 12:34:57 -04:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetStickPOVCount(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2015-06-25 15:07:55 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickPOVs povs;
|
|
|
|
|
HAL_GetJoystickPOVs(stick, &povs);
|
|
|
|
|
|
|
|
|
|
return povs.count;
|
2014-12-05 20:13:23 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetStickButtonCount(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2015-06-25 15:07:55 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickButtons buttons;
|
|
|
|
|
HAL_GetJoystickButtons(stick, &buttons);
|
|
|
|
|
|
|
|
|
|
return buttons.count;
|
2014-12-05 20:13:23 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
bool DriverStation::GetJoystickIsXbox(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2016-07-14 20:50:38 -07:00
|
|
|
return false;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickDescriptor descriptor;
|
|
|
|
|
HAL_GetJoystickDescriptor(stick, &descriptor);
|
|
|
|
|
|
|
|
|
|
return static_cast<bool>(descriptor.isXbox);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetJoystickType(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2015-06-25 15:07:55 -04:00
|
|
|
return -1;
|
|
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickDescriptor descriptor;
|
|
|
|
|
HAL_GetJoystickDescriptor(stick, &descriptor);
|
|
|
|
|
|
|
|
|
|
return static_cast<int>(descriptor.type);
|
2014-10-17 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
std::string DriverStation::GetJoystickName(int stick) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickDescriptor descriptor;
|
|
|
|
|
HAL_GetJoystickDescriptor(stick, &descriptor);
|
|
|
|
|
|
|
|
|
|
return descriptor.name;
|
2014-12-18 10:57:11 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetJoystickAxisType(int stick, int axis) const {
|
2018-05-16 00:13:52 -07:00
|
|
|
if (stick < 0 || stick >= kJoystickPorts) {
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
2016-07-14 20:50:38 -07:00
|
|
|
return -1;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2018-05-16 00:13:52 -07:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_JoystickDescriptor descriptor;
|
|
|
|
|
HAL_GetJoystickDescriptor(stick, &descriptor);
|
|
|
|
|
|
|
|
|
|
return static_cast<bool>(descriptor.axisTypes);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 14:11:10 -05:00
|
|
|
bool DriverStation::IsJoystickConnected(int stick) const {
|
|
|
|
|
return GetStickAxisCount(stick) > 0 || GetStickButtonCount(stick) > 0 ||
|
|
|
|
|
GetStickPOVCount(stick) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool DriverStation::IsEnabled() const {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2015-06-25 15:07:55 -04:00
|
|
|
return controlWord.enabled && controlWord.dsAttached;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool DriverStation::IsDisabled() const {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2015-06-25 15:07:55 -04:00
|
|
|
return !(controlWord.enabled && controlWord.dsAttached);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2019-07-16 09:18:23 -05:00
|
|
|
bool DriverStation::IsEStopped() const {
|
|
|
|
|
HAL_ControlWord controlWord;
|
|
|
|
|
HAL_GetControlWord(&controlWord);
|
|
|
|
|
return controlWord.eStop;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool DriverStation::IsAutonomous() const {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2015-06-25 15:07:55 -04:00
|
|
|
return controlWord.autonomous;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2020-08-29 16:32:19 -04:00
|
|
|
bool DriverStation::IsAutonomousEnabled() const {
|
|
|
|
|
HAL_ControlWord controlWord;
|
|
|
|
|
HAL_GetControlWord(&controlWord);
|
|
|
|
|
return controlWord.autonomous && controlWord.enabled;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool DriverStation::IsOperatorControl() const {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2015-06-25 15:07:55 -04:00
|
|
|
return !(controlWord.autonomous || controlWord.test);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2020-08-29 16:32:19 -04:00
|
|
|
bool DriverStation::IsOperatorControlEnabled() const {
|
|
|
|
|
HAL_ControlWord controlWord;
|
|
|
|
|
HAL_GetControlWord(&controlWord);
|
|
|
|
|
return !controlWord.autonomous && !controlWord.test && controlWord.enabled;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool DriverStation::IsTest() const {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2015-06-25 15:07:55 -04:00
|
|
|
return controlWord.test;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool DriverStation::IsDSAttached() const {
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2015-06-25 15:07:55 -04:00
|
|
|
return controlWord.dsAttached;
|
2014-11-18 10:56:25 -05:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 21:57:54 -07:00
|
|
|
bool DriverStation::IsNewControlData() const {
|
|
|
|
|
std::unique_lock lock(m_waitForDataMutex);
|
|
|
|
|
int& lastCount = GetDSLastCount();
|
|
|
|
|
int currentCount = m_waitForDataCounter;
|
2020-12-28 12:58:06 -08:00
|
|
|
if (lastCount == currentCount) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-07-13 21:57:54 -07:00
|
|
|
lastCount = currentCount;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-07-14 20:50:38 -07:00
|
|
|
|
|
|
|
|
bool DriverStation::IsFMSAttached() const {
|
|
|
|
|
HAL_ControlWord controlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&controlWord);
|
2016-07-14 20:50:38 -07:00
|
|
|
return controlWord.fmsAttached;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-09 19:59:29 -08:00
|
|
|
std::string DriverStation::GetGameSpecificMessage() const {
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_MatchInfo info;
|
|
|
|
|
HAL_GetMatchInfo(&info);
|
|
|
|
|
return std::string(reinterpret_cast<char*>(info.gameSpecificMessage),
|
|
|
|
|
info.gameSpecificMessageSize);
|
2017-11-09 19:59:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string DriverStation::GetEventName() const {
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_MatchInfo info;
|
|
|
|
|
HAL_GetMatchInfo(&info);
|
|
|
|
|
return info.eventName;
|
2017-11-09 19:59:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DriverStation::MatchType DriverStation::GetMatchType() const {
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_MatchInfo info;
|
|
|
|
|
HAL_GetMatchInfo(&info);
|
|
|
|
|
return static_cast<DriverStation::MatchType>(info.matchType);
|
2017-11-09 19:59:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DriverStation::GetMatchNumber() const {
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_MatchInfo info;
|
|
|
|
|
HAL_GetMatchInfo(&info);
|
|
|
|
|
return info.matchNumber;
|
2017-11-09 19:59:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DriverStation::GetReplayNumber() const {
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_MatchInfo info;
|
|
|
|
|
HAL_GetMatchInfo(&info);
|
|
|
|
|
return info.replayNumber;
|
2017-11-09 19:59:29 -08:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
DriverStation::Alliance DriverStation::GetAlliance() const {
|
2016-07-10 16:24:57 -07:00
|
|
|
int32_t status = 0;
|
|
|
|
|
auto allianceStationID = HAL_GetAllianceStation(&status);
|
2015-06-25 15:07:55 -04:00
|
|
|
switch (allianceStationID) {
|
2016-07-09 00:24:26 -07:00
|
|
|
case HAL_AllianceStationID_kRed1:
|
|
|
|
|
case HAL_AllianceStationID_kRed2:
|
|
|
|
|
case HAL_AllianceStationID_kRed3:
|
2015-06-25 15:07:55 -04:00
|
|
|
return kRed;
|
2016-07-09 00:24:26 -07:00
|
|
|
case HAL_AllianceStationID_kBlue1:
|
|
|
|
|
case HAL_AllianceStationID_kBlue2:
|
|
|
|
|
case HAL_AllianceStationID_kBlue3:
|
2015-06-25 15:07:55 -04:00
|
|
|
return kBlue;
|
|
|
|
|
default:
|
|
|
|
|
return kInvalid;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int DriverStation::GetLocation() const {
|
2016-07-10 16:24:57 -07:00
|
|
|
int32_t status = 0;
|
|
|
|
|
auto allianceStationID = HAL_GetAllianceStation(&status);
|
2015-06-25 15:07:55 -04:00
|
|
|
switch (allianceStationID) {
|
2016-07-09 00:24:26 -07:00
|
|
|
case HAL_AllianceStationID_kRed1:
|
|
|
|
|
case HAL_AllianceStationID_kBlue1:
|
2015-06-25 15:07:55 -04:00
|
|
|
return 1;
|
2016-07-09 00:24:26 -07:00
|
|
|
case HAL_AllianceStationID_kRed2:
|
|
|
|
|
case HAL_AllianceStationID_kBlue2:
|
2015-06-25 15:07:55 -04:00
|
|
|
return 2;
|
2016-07-09 00:24:26 -07:00
|
|
|
case HAL_AllianceStationID_kRed3:
|
|
|
|
|
case HAL_AllianceStationID_kBlue3:
|
2015-06-25 15:07:55 -04:00
|
|
|
return 3;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
void DriverStation::WaitForData() {
|
2021-05-28 22:06:59 -07:00
|
|
|
WaitForData(0_s);
|
2020-12-28 12:58:06 -08:00
|
|
|
}
|
2016-10-09 11:46:01 -07:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
bool DriverStation::WaitForData(units::second_t timeout) {
|
|
|
|
|
auto timeoutTime = std::chrono::steady_clock::now() +
|
|
|
|
|
std::chrono::steady_clock::duration{timeout};
|
2018-01-18 21:54:33 -08:00
|
|
|
|
2019-07-07 19:17:14 -07:00
|
|
|
std::unique_lock lock(m_waitForDataMutex);
|
2020-07-13 21:57:54 -07:00
|
|
|
int& lastCount = GetDSLastCount();
|
2018-01-18 21:54:33 -08:00
|
|
|
int currentCount = m_waitForDataCounter;
|
2020-07-13 21:57:54 -07:00
|
|
|
if (lastCount != currentCount) {
|
|
|
|
|
lastCount = currentCount;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-01-18 21:54:33 -08:00
|
|
|
while (m_waitForDataCounter == currentCount) {
|
2021-05-28 22:06:59 -07:00
|
|
|
if (timeout > 0_s) {
|
2018-01-18 21:54:33 -08:00
|
|
|
auto timedOut = m_waitForDataCond.wait_until(lock, timeoutTime);
|
|
|
|
|
if (timedOut == std::cv_status::timeout) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
m_waitForDataCond.wait(lock);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-13 21:57:54 -07:00
|
|
|
lastCount = m_waitForDataCounter;
|
2018-01-18 21:54:33 -08:00
|
|
|
return true;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
double DriverStation::GetMatchTime() const {
|
2021-06-08 21:18:59 -07:00
|
|
|
int32_t status = 0;
|
2016-07-10 16:24:57 -07:00
|
|
|
return HAL_GetMatchTime(&status);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
2014-10-20 17:19:28 -04:00
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double DriverStation::GetBatteryVoltage() const {
|
2016-07-14 20:50:38 -07:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double voltage = HAL_GetVinVoltage(&status);
|
2021-05-23 19:33:33 -07:00
|
|
|
FRC_CheckErrorStatus(status, "{}", "getVinVoltage");
|
2016-07-14 20:50:38 -07:00
|
|
|
|
|
|
|
|
return voltage;
|
2016-02-04 22:29:11 -08:00
|
|
|
}
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2019-11-05 21:33:09 -08:00
|
|
|
void DriverStation::WakeupWaitForData() {
|
|
|
|
|
std::scoped_lock waitLock(m_waitForDataMutex);
|
|
|
|
|
// Nofify all threads
|
|
|
|
|
m_waitForDataCounter++;
|
|
|
|
|
m_waitForDataCond.notify_all();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-14 20:50:38 -07:00
|
|
|
void DriverStation::GetData() {
|
2018-01-18 23:17:28 -08:00
|
|
|
{
|
2018-07-18 22:22:41 -07:00
|
|
|
// Compute the pressed and released buttons
|
|
|
|
|
HAL_JoystickButtons currentButtons;
|
2019-07-07 19:17:14 -07:00
|
|
|
std::unique_lock lock(m_buttonEdgeMutex);
|
2018-01-18 23:17:28 -08:00
|
|
|
|
|
|
|
|
for (int32_t i = 0; i < kJoystickPorts; i++) {
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetJoystickButtons(i, ¤tButtons);
|
|
|
|
|
|
2018-01-18 23:17:28 -08:00
|
|
|
// If buttons weren't pressed and are now, set flags in m_buttonsPressed
|
|
|
|
|
m_joystickButtonsPressed[i] |=
|
2018-07-18 22:22:41 -07:00
|
|
|
~m_previousButtonStates[i].buttons & currentButtons.buttons;
|
2017-10-27 21:45:56 -07:00
|
|
|
|
2018-01-18 23:17:28 -08:00
|
|
|
// If buttons were pressed and aren't now, set flags in m_buttonsReleased
|
|
|
|
|
m_joystickButtonsReleased[i] |=
|
2018-07-18 22:22:41 -07:00
|
|
|
m_previousButtonStates[i].buttons & ~currentButtons.buttons;
|
2018-01-18 23:17:28 -08:00
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
m_previousButtonStates[i] = currentButtons;
|
|
|
|
|
}
|
2017-10-27 21:45:56 -07:00
|
|
|
}
|
|
|
|
|
|
2019-11-05 21:33:09 -08:00
|
|
|
WakeupWaitForData();
|
2018-01-18 23:17:28 -08:00
|
|
|
SendMatchData();
|
2016-02-04 22:29:11 -08:00
|
|
|
}
|
|
|
|
|
|
2020-11-14 15:00:56 -05:00
|
|
|
void DriverStation::SilenceJoystickConnectionWarning(bool silence) {
|
|
|
|
|
m_silenceJoystickWarning = silence;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsJoystickConnectionWarningSilenced() const {
|
|
|
|
|
return !IsFMSAttached() && m_silenceJoystickWarning;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-14 20:50:38 -07:00
|
|
|
DriverStation::DriverStation() {
|
2018-05-24 17:03:19 -07:00
|
|
|
HAL_Initialize(500, 0);
|
2018-01-18 21:54:33 -08:00
|
|
|
m_waitForDataCounter = 0;
|
2016-07-14 20:50:38 -07:00
|
|
|
|
2018-01-18 23:17:28 -08:00
|
|
|
m_matchDataSender = std::make_unique<MatchDataSender>();
|
|
|
|
|
|
2016-07-14 20:50:38 -07:00
|
|
|
// All joysticks should default to having zero axes, povs and buttons, so
|
|
|
|
|
// uninitialized memory doesn't get sent to speed controllers.
|
|
|
|
|
for (unsigned int i = 0; i < kJoystickPorts; i++) {
|
2017-10-27 21:45:56 -07:00
|
|
|
m_joystickButtonsPressed[i] = 0;
|
|
|
|
|
m_joystickButtonsReleased[i] = 0;
|
2018-07-18 22:22:41 -07:00
|
|
|
m_previousButtonStates[i].count = 0;
|
|
|
|
|
m_previousButtonStates[i].buttons = 0;
|
2016-07-14 20:50:38 -07:00
|
|
|
}
|
|
|
|
|
|
2016-11-01 20:12:08 -07:00
|
|
|
m_dsThread = std::thread(&DriverStation::Run, this);
|
2016-07-14 20:50:38 -07:00
|
|
|
}
|
|
|
|
|
|
2021-05-24 23:36:26 -07:00
|
|
|
void DriverStation::ReportJoystickUnpluggedErrorV(fmt::string_view format,
|
|
|
|
|
fmt::format_args args) {
|
2021-05-28 22:06:59 -07:00
|
|
|
auto currentTime = Timer::GetFPGATimestamp();
|
2016-07-14 20:50:38 -07:00
|
|
|
if (currentTime > m_nextMessageTime) {
|
2021-05-24 23:36:26 -07:00
|
|
|
ReportErrorV(err::Error, "", 0, "", format, args);
|
2017-11-19 19:04:28 -08:00
|
|
|
m_nextMessageTime = currentTime + kJoystickUnpluggedMessageInterval;
|
2016-07-14 20:50:38 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-24 23:36:26 -07:00
|
|
|
void DriverStation::ReportJoystickUnpluggedWarningV(fmt::string_view format,
|
|
|
|
|
fmt::format_args args) {
|
2020-11-14 15:00:56 -05:00
|
|
|
if (IsFMSAttached() || !m_silenceJoystickWarning) {
|
2021-05-28 22:06:59 -07:00
|
|
|
auto currentTime = Timer::GetFPGATimestamp();
|
2020-11-14 15:00:56 -05:00
|
|
|
if (currentTime > m_nextMessageTime) {
|
2021-05-24 23:36:26 -07:00
|
|
|
ReportErrorV(warn::Warning, "", 0, "", format, args);
|
2020-11-14 15:00:56 -05:00
|
|
|
m_nextMessageTime = currentTime + kJoystickUnpluggedMessageInterval;
|
|
|
|
|
}
|
2016-07-14 20:50:38 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DriverStation::Run() {
|
|
|
|
|
m_isRunning = true;
|
2018-12-29 16:19:23 -08:00
|
|
|
int safetyCounter = 0;
|
2016-07-14 20:50:38 -07:00
|
|
|
while (m_isRunning) {
|
|
|
|
|
HAL_WaitForDSData();
|
|
|
|
|
GetData();
|
|
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
if (IsDisabled()) {
|
|
|
|
|
safetyCounter = 0;
|
|
|
|
|
}
|
2018-12-29 16:19:23 -08:00
|
|
|
|
|
|
|
|
if (++safetyCounter >= 4) {
|
|
|
|
|
MotorSafety::CheckMotors();
|
|
|
|
|
safetyCounter = 0;
|
|
|
|
|
}
|
2020-12-28 12:58:06 -08:00
|
|
|
if (m_userInDisabled) {
|
|
|
|
|
HAL_ObserveUserProgramDisabled();
|
|
|
|
|
}
|
|
|
|
|
if (m_userInAutonomous) {
|
|
|
|
|
HAL_ObserveUserProgramAutonomous();
|
|
|
|
|
}
|
|
|
|
|
if (m_userInTeleop) {
|
|
|
|
|
HAL_ObserveUserProgramTeleop();
|
|
|
|
|
}
|
|
|
|
|
if (m_userInTest) {
|
|
|
|
|
HAL_ObserveUserProgramTest();
|
|
|
|
|
}
|
2016-07-14 20:50:38 -07:00
|
|
|
}
|
2014-10-20 17:19:28 -04:00
|
|
|
}
|
2016-07-15 13:39:26 -07:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
void DriverStation::SendMatchData() {
|
|
|
|
|
int32_t status = 0;
|
|
|
|
|
HAL_AllianceStationID alliance = HAL_GetAllianceStation(&status);
|
|
|
|
|
bool isRedAlliance = false;
|
|
|
|
|
int stationNumber = 1;
|
|
|
|
|
switch (alliance) {
|
|
|
|
|
case HAL_AllianceStationID::HAL_AllianceStationID_kBlue1:
|
|
|
|
|
isRedAlliance = false;
|
|
|
|
|
stationNumber = 1;
|
|
|
|
|
break;
|
|
|
|
|
case HAL_AllianceStationID::HAL_AllianceStationID_kBlue2:
|
|
|
|
|
isRedAlliance = false;
|
|
|
|
|
stationNumber = 2;
|
|
|
|
|
break;
|
|
|
|
|
case HAL_AllianceStationID::HAL_AllianceStationID_kBlue3:
|
|
|
|
|
isRedAlliance = false;
|
|
|
|
|
stationNumber = 3;
|
|
|
|
|
break;
|
|
|
|
|
case HAL_AllianceStationID::HAL_AllianceStationID_kRed1:
|
|
|
|
|
isRedAlliance = true;
|
|
|
|
|
stationNumber = 1;
|
|
|
|
|
break;
|
|
|
|
|
case HAL_AllianceStationID::HAL_AllianceStationID_kRed2:
|
|
|
|
|
isRedAlliance = true;
|
|
|
|
|
stationNumber = 2;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
isRedAlliance = true;
|
|
|
|
|
stationNumber = 3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_MatchInfo tmpDataStore;
|
|
|
|
|
HAL_GetMatchInfo(&tmpDataStore);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2020-11-15 13:48:54 -05:00
|
|
|
m_matchDataSender->alliance.Set(isRedAlliance);
|
|
|
|
|
m_matchDataSender->station.Set(stationNumber);
|
|
|
|
|
m_matchDataSender->eventName.Set(tmpDataStore.eventName);
|
|
|
|
|
m_matchDataSender->gameSpecificMessage.Set(
|
2018-07-18 22:22:41 -07:00
|
|
|
std::string(reinterpret_cast<char*>(tmpDataStore.gameSpecificMessage),
|
|
|
|
|
tmpDataStore.gameSpecificMessageSize));
|
2020-11-15 13:48:54 -05:00
|
|
|
m_matchDataSender->matchNumber.Set(tmpDataStore.matchNumber);
|
|
|
|
|
m_matchDataSender->replayNumber.Set(tmpDataStore.replayNumber);
|
|
|
|
|
m_matchDataSender->matchType.Set(static_cast<int>(tmpDataStore.matchType));
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
HAL_ControlWord ctlWord;
|
2018-07-18 22:22:41 -07:00
|
|
|
HAL_GetControlWord(&ctlWord);
|
2018-05-31 20:47:15 -07:00
|
|
|
int32_t wordInt = 0;
|
|
|
|
|
std::memcpy(&wordInt, &ctlWord, sizeof(wordInt));
|
2020-11-15 13:48:54 -05:00
|
|
|
m_matchDataSender->controlWord.Set(wordInt);
|
2018-05-31 20:47:15 -07:00
|
|
|
}
|