mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Prepends all HAL functions with HAL_ (#146)
This commit is contained in:
committed by
Peter Johnson
parent
5ad28d58ec
commit
b637b9ee4c
@@ -30,8 +30,8 @@ ADXL345_I2C::ADXL345_I2C(I2C::Port port, Range range, int deviceAddress)
|
||||
// Specify the data format to read
|
||||
SetRange(range);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_ADXL345,
|
||||
HALUsageReporting::kADXL345_I2C, 0);
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXL345,
|
||||
HALUsageReporting::kADXL345_I2C, 0);
|
||||
LiveWindow::GetInstance()->AddSensor("ADXL345_I2C", port, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ ADXL345_SPI::ADXL345_SPI(SPI::Port port, ADXL345_SPI::Range range)
|
||||
|
||||
SetRange(range);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_ADXL345,
|
||||
HALUsageReporting::kADXL345_SPI);
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXL345,
|
||||
HALUsageReporting::kADXL345_SPI);
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("ADXL345_SPI", port, this);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ ADXL362::ADXL362(SPI::Port port, Range range) : m_spi(port) {
|
||||
commands[2] = kPowerCtl_Measure | kPowerCtl_UltraLowNoise;
|
||||
m_spi.Write(commands, 3);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_ADXL362, port);
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXL362, port);
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("ADXL362", port, this);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port) : m_spi(port) {
|
||||
|
||||
Calibrate();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_ADXRS450, port);
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXRS450, port);
|
||||
LiveWindow::GetInstance()->AddSensor("ADXRS450_Gyro", port, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* Common function for initializing the accelerometer.
|
||||
*/
|
||||
void AnalogAccelerometer::InitAccelerometer() {
|
||||
HALReport(HALUsageReporting::kResourceType_Accelerometer,
|
||||
m_analogInput->GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_Accelerometer,
|
||||
m_analogInput->GetChannel());
|
||||
LiveWindow::GetInstance()->AddSensor("Accelerometer",
|
||||
m_analogInput->GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ AnalogGyro::AnalogGyro(int32_t channel, uint32_t center, float offset) {
|
||||
m_analog = std::make_shared<AnalogInput>(channel);
|
||||
InitGyro();
|
||||
int32_t status = 0;
|
||||
setAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond, offset,
|
||||
center, &status);
|
||||
HAL_SetAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond,
|
||||
offset, center, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_gyroHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_gyroHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
Reset();
|
||||
@@ -109,11 +109,11 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, uint32_t center,
|
||||
} else {
|
||||
InitGyro();
|
||||
int32_t status = 0;
|
||||
setAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond,
|
||||
offset, center, &status);
|
||||
HAL_SetAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond,
|
||||
offset, center, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_gyroHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_gyroHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
Reset();
|
||||
@@ -124,7 +124,7 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, uint32_t center,
|
||||
* AnalogGyro Destructor
|
||||
*
|
||||
*/
|
||||
AnalogGyro::~AnalogGyro() { freeAnalogGyro(m_gyroHandle); }
|
||||
AnalogGyro::~AnalogGyro() { HAL_FreeAnalogGyro(m_gyroHandle); }
|
||||
|
||||
/**
|
||||
* Reset the gyro.
|
||||
@@ -136,8 +136,8 @@ AnalogGyro::~AnalogGyro() { freeAnalogGyro(m_gyroHandle); }
|
||||
void AnalogGyro::Reset() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
resetAnalogGyro(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_ResetAnalogGyro(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,34 +145,34 @@ void AnalogGyro::Reset() {
|
||||
*/
|
||||
void AnalogGyro::InitGyro() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_gyroHandle == HAL_INVALID_HANDLE) {
|
||||
if (m_gyroHandle == HAL_kInvalidHandle) {
|
||||
int32_t status = 0;
|
||||
m_gyroHandle = initializeAnalogGyro(m_analog->m_port, &status);
|
||||
m_gyroHandle = HAL_InitializeAnalogGyro(m_analog->m_port, &status);
|
||||
if (status == PARAMETER_OUT_OF_RANGE) {
|
||||
wpi_setWPIErrorWithContext(ParameterOutOfRange,
|
||||
" channel (must be accumulator channel)");
|
||||
m_analog = nullptr;
|
||||
m_gyroHandle = HAL_INVALID_HANDLE;
|
||||
m_gyroHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_analog = nullptr;
|
||||
m_gyroHandle = HAL_INVALID_HANDLE;
|
||||
m_gyroHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
setupAnalogGyro(m_gyroHandle, &status);
|
||||
HAL_SetupAnalogGyro(m_gyroHandle, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_analog = nullptr;
|
||||
m_gyroHandle = HAL_INVALID_HANDLE;
|
||||
m_gyroHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel());
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogGyro", m_analog->GetChannel(),
|
||||
this);
|
||||
}
|
||||
@@ -180,8 +180,8 @@ void AnalogGyro::InitGyro() {
|
||||
void AnalogGyro::Calibrate() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
calibrateAnalogGyro(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_CalibrateAnalogGyro(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,8 +199,8 @@ void AnalogGyro::Calibrate() {
|
||||
float AnalogGyro::GetAngle() const {
|
||||
if (StatusIsFatal()) return 0.f;
|
||||
int32_t status = 0;
|
||||
float value = getAnalogGyroAngle(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
float value = HAL_GetAnalogGyroAngle(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -214,8 +214,8 @@ float AnalogGyro::GetAngle() const {
|
||||
double AnalogGyro::GetRate() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
double value = getAnalogGyroRate(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double value = HAL_GetAnalogGyroRate(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ double AnalogGyro::GetRate() const {
|
||||
float AnalogGyro::GetOffset() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float value = getAnalogGyroOffset(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
float value = HAL_GetAnalogGyroOffset(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -242,8 +242,8 @@ float AnalogGyro::GetOffset() const {
|
||||
uint32_t AnalogGyro::GetCenter() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
uint32_t value = getAnalogGyroCenter(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint32_t value = HAL_GetAnalogGyroCenter(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -258,9 +258,9 @@ uint32_t AnalogGyro::GetCenter() const {
|
||||
*/
|
||||
void AnalogGyro::SetSensitivity(float voltsPerDegreePerSecond) {
|
||||
int32_t status = 0;
|
||||
setAnalogGyroVoltsPerDegreePerSecond(m_gyroHandle, voltsPerDegreePerSecond,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogGyroVoltsPerDegreePerSecond(m_gyroHandle,
|
||||
voltsPerDegreePerSecond, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,6 +275,6 @@ void AnalogGyro::SetSensitivity(float voltsPerDegreePerSecond) {
|
||||
void AnalogGyro::SetDeadband(float volts) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogGyroDeadband(m_gyroHandle, volts, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogGyroDeadband(m_gyroHandle, volts, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
@@ -27,33 +27,33 @@ AnalogInput::AnalogInput(uint32_t channel) {
|
||||
std::stringstream buf;
|
||||
buf << "Analog Input " << channel;
|
||||
|
||||
if (!checkAnalogInputChannel(channel)) {
|
||||
if (!HAL_CheckAnalogInputChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
|
||||
return;
|
||||
}
|
||||
|
||||
m_channel = channel;
|
||||
|
||||
HalPortHandle port = getPort(channel);
|
||||
HAL_PortHandle port = HAL_GetPort(channel);
|
||||
int32_t status = 0;
|
||||
m_port = initializeAnalogInputPort(port, &status);
|
||||
m_port = HAL_InitializeAnalogInputPort(port, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_channel = std::numeric_limits<uint32_t>::max();
|
||||
m_port = HAL_INVALID_HANDLE;
|
||||
m_port = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
|
||||
HALReport(HALUsageReporting::kResourceType_AnalogChannel, channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogChannel, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel destructor.
|
||||
*/
|
||||
AnalogInput::~AnalogInput() {
|
||||
freeAnalogInputPort(m_port);
|
||||
m_port = HAL_INVALID_HANDLE;
|
||||
HAL_FreeAnalogInputPort(m_port);
|
||||
m_port = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +68,8 @@ AnalogInput::~AnalogInput() {
|
||||
int16_t AnalogInput::GetValue() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int16_t value = getAnalogValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int16_t value = HAL_GetAnalogValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ int16_t AnalogInput::GetValue() const {
|
||||
int32_t AnalogInput::GetAverageValue() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t value = getAnalogAverageValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t value = HAL_GetAnalogAverageValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ int32_t AnalogInput::GetAverageValue() const {
|
||||
float AnalogInput::GetVoltage() const {
|
||||
if (StatusIsFatal()) return 0.0f;
|
||||
int32_t status = 0;
|
||||
float voltage = getAnalogVoltage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
float voltage = HAL_GetAnalogVoltage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@@ -128,8 +128,8 @@ float AnalogInput::GetVoltage() const {
|
||||
float AnalogInput::GetAverageVoltage() const {
|
||||
if (StatusIsFatal()) return 0.0f;
|
||||
int32_t status = 0;
|
||||
float voltage = getAnalogAverageVoltage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
float voltage = HAL_GetAnalogAverageVoltage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ float AnalogInput::GetAverageVoltage() const {
|
||||
uint32_t AnalogInput::GetLSBWeight() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t lsbWeight = getAnalogLSBWeight(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t lsbWeight = HAL_GetAnalogLSBWeight(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return lsbWeight;
|
||||
}
|
||||
|
||||
@@ -158,8 +158,8 @@ uint32_t AnalogInput::GetLSBWeight() const {
|
||||
int32_t AnalogInput::GetOffset() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t offset = getAnalogOffset(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t offset = HAL_GetAnalogOffset(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return offset;
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ uint32_t AnalogInput::GetChannel() const {
|
||||
void AnalogInput::SetAverageBits(uint32_t bits) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogAverageBits(m_port, bits, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogAverageBits(m_port, bits, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,8 +201,8 @@ void AnalogInput::SetAverageBits(uint32_t bits) {
|
||||
*/
|
||||
uint32_t AnalogInput::GetAverageBits() const {
|
||||
int32_t status = 0;
|
||||
int32_t averageBits = getAnalogAverageBits(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t averageBits = HAL_GetAnalogAverageBits(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return averageBits;
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ uint32_t AnalogInput::GetAverageBits() const {
|
||||
void AnalogInput::SetOversampleBits(uint32_t bits) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogOversampleBits(m_port, bits, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogOversampleBits(m_port, bits, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,8 +235,8 @@ void AnalogInput::SetOversampleBits(uint32_t bits) {
|
||||
uint32_t AnalogInput::GetOversampleBits() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t oversampleBits = getAnalogOversampleBits(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t oversampleBits = HAL_GetAnalogOversampleBits(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return oversampleBits;
|
||||
}
|
||||
|
||||
@@ -248,8 +248,8 @@ uint32_t AnalogInput::GetOversampleBits() const {
|
||||
bool AnalogInput::IsAccumulatorChannel() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool isAccum = isAccumulatorChannel(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool isAccum = HAL_IsAccumulatorChannel(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return isAccum;
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ void AnalogInput::InitAccumulator() {
|
||||
if (StatusIsFatal()) return;
|
||||
m_accumulatorOffset = 0;
|
||||
int32_t status = 0;
|
||||
initAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_InitAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,8 +283,8 @@ void AnalogInput::SetAccumulatorInitialValue(int64_t initialValue) {
|
||||
void AnalogInput::ResetAccumulator() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
resetAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_ResetAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
if (!StatusIsFatal()) {
|
||||
// Wait until the next sample, so the next call to GetAccumulator*()
|
||||
@@ -310,8 +310,8 @@ void AnalogInput::ResetAccumulator() {
|
||||
void AnalogInput::SetAccumulatorCenter(int32_t center) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAccumulatorCenter(m_port, center, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAccumulatorCenter(m_port, center, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,8 +320,8 @@ void AnalogInput::SetAccumulatorCenter(int32_t center) {
|
||||
void AnalogInput::SetAccumulatorDeadband(int32_t deadband) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAccumulatorDeadband(m_port, deadband, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAccumulatorDeadband(m_port, deadband, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,8 +335,8 @@ void AnalogInput::SetAccumulatorDeadband(int32_t deadband) {
|
||||
int64_t AnalogInput::GetAccumulatorValue() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int64_t value = getAccumulatorValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int64_t value = HAL_GetAccumulatorValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value + m_accumulatorOffset;
|
||||
}
|
||||
|
||||
@@ -351,8 +351,8 @@ int64_t AnalogInput::GetAccumulatorValue() const {
|
||||
uint32_t AnalogInput::GetAccumulatorCount() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
uint32_t count = getAccumulatorCount(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint32_t count = HAL_GetAccumulatorCount(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -368,8 +368,8 @@ uint32_t AnalogInput::GetAccumulatorCount() const {
|
||||
void AnalogInput::GetAccumulatorOutput(int64_t& value, uint32_t& count) const {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
getAccumulatorOutput(m_port, &value, &count, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_GetAccumulatorOutput(m_port, &value, &count, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
value += m_accumulatorOffset;
|
||||
}
|
||||
|
||||
@@ -383,8 +383,8 @@ void AnalogInput::GetAccumulatorOutput(int64_t& value, uint32_t& count) const {
|
||||
*/
|
||||
void AnalogInput::SetSampleRate(float samplesPerSecond) {
|
||||
int32_t status = 0;
|
||||
setAnalogSampleRate(samplesPerSecond, &status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogSampleRate(samplesPerSecond, &status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,8 +394,8 @@ void AnalogInput::SetSampleRate(float samplesPerSecond) {
|
||||
*/
|
||||
float AnalogInput::GetSampleRate() {
|
||||
int32_t status = 0;
|
||||
float sampleRate = getAnalogSampleRate(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
float sampleRate = HAL_GetAnalogSampleRate(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,27 +24,27 @@ AnalogOutput::AnalogOutput(uint32_t channel) {
|
||||
std::stringstream buf;
|
||||
buf << "analog input " << channel;
|
||||
|
||||
if (!checkAnalogOutputChannel(channel)) {
|
||||
if (!HAL_CheckAnalogOutputChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
|
||||
m_channel = std::numeric_limits<uint32_t>::max();
|
||||
m_port = HAL_INVALID_HANDLE;
|
||||
m_port = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
m_channel = channel;
|
||||
|
||||
HalPortHandle port = getPort(m_channel);
|
||||
HAL_PortHandle port = HAL_GetPort(m_channel);
|
||||
int32_t status = 0;
|
||||
m_port = initializeAnalogOutputPort(port, &status);
|
||||
m_port = HAL_InitializeAnalogOutputPort(port, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_channel = std::numeric_limits<uint32_t>::max();
|
||||
m_port = HAL_INVALID_HANDLE;
|
||||
m_port = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("AnalogOutput", m_channel, this);
|
||||
HALReport(HALUsageReporting::kResourceType_AnalogOutput, m_channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogOutput, m_channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ AnalogOutput::AnalogOutput(uint32_t channel) {
|
||||
*
|
||||
* Frees analog output resource.
|
||||
*/
|
||||
AnalogOutput::~AnalogOutput() { freeAnalogOutputPort(m_port); }
|
||||
AnalogOutput::~AnalogOutput() { HAL_FreeAnalogOutputPort(m_port); }
|
||||
|
||||
/**
|
||||
* Set the value of the analog output.
|
||||
@@ -61,9 +61,9 @@ AnalogOutput::~AnalogOutput() { freeAnalogOutputPort(m_port); }
|
||||
*/
|
||||
void AnalogOutput::SetVoltage(float voltage) {
|
||||
int32_t status = 0;
|
||||
setAnalogOutput(m_port, voltage, &status);
|
||||
HAL_SetAnalogOutput(m_port, voltage, &status);
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,9 +73,9 @@ void AnalogOutput::SetVoltage(float voltage) {
|
||||
*/
|
||||
float AnalogOutput::GetVoltage() const {
|
||||
int32_t status = 0;
|
||||
float voltage = getAnalogOutput(m_port, &status);
|
||||
float voltage = HAL_GetAnalogOutput(m_port, &status);
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@@ -36,21 +36,21 @@ AnalogTrigger::AnalogTrigger(AnalogInput* input) {
|
||||
m_analogInput = input;
|
||||
int32_t status = 0;
|
||||
uint32_t index = 0;
|
||||
m_trigger = initializeAnalogTrigger(input->m_port, &index, &status);
|
||||
m_trigger = HAL_InitializeAnalogTrigger(input->m_port, &index, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_index = std::numeric_limits<uint8_t>::max();
|
||||
m_trigger = HAL_INVALID_HANDLE;
|
||||
m_trigger = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
m_index = index;
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_AnalogTrigger, input->m_channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogTrigger, input->m_channel);
|
||||
}
|
||||
|
||||
AnalogTrigger::~AnalogTrigger() {
|
||||
int32_t status = 0;
|
||||
cleanAnalogTrigger(m_trigger, &status);
|
||||
HAL_CleanAnalogTrigger(m_trigger, &status);
|
||||
|
||||
if (m_ownsAnalog && m_analogInput != nullptr) {
|
||||
delete m_analogInput;
|
||||
@@ -69,8 +69,8 @@ AnalogTrigger::~AnalogTrigger() {
|
||||
void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerLimitsRaw(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogTriggerLimitsRaw(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +84,8 @@ void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper) {
|
||||
void AnalogTrigger::SetLimitsVoltage(float lower, float upper) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerLimitsVoltage(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogTriggerLimitsVoltage(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +100,8 @@ void AnalogTrigger::SetLimitsVoltage(float lower, float upper) {
|
||||
void AnalogTrigger::SetAveraged(bool useAveragedValue) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerAveraged(m_trigger, useAveragedValue, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogTriggerAveraged(m_trigger, useAveragedValue, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +117,8 @@ void AnalogTrigger::SetAveraged(bool useAveragedValue) {
|
||||
void AnalogTrigger::SetFiltered(bool useFilteredValue) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerFiltered(m_trigger, useFilteredValue, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetAnalogTriggerFiltered(m_trigger, useFilteredValue, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,8 +143,8 @@ uint32_t AnalogTrigger::GetIndex() const {
|
||||
bool AnalogTrigger::GetInWindow() {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool result = getAnalogTriggerInWindow(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool result = HAL_GetAnalogTriggerInWindow(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ bool AnalogTrigger::GetInWindow() {
|
||||
bool AnalogTrigger::GetTriggerState() {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool result = getAnalogTriggerTriggerState(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool result = HAL_GetAnalogTriggerTriggerState(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
AnalogTriggerOutput::AnalogTriggerOutput(const AnalogTrigger& trigger,
|
||||
AnalogTriggerType outputType)
|
||||
: m_trigger(trigger), m_outputType(outputType) {
|
||||
HALReport(HALUsageReporting::kResourceType_AnalogTriggerOutput,
|
||||
trigger.GetIndex(), outputType);
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogTriggerOutput,
|
||||
trigger.GetIndex(), (uint8_t)outputType);
|
||||
}
|
||||
|
||||
AnalogTriggerOutput::~AnalogTriggerOutput() {
|
||||
if (m_interrupt != HAL_INVALID_HANDLE) {
|
||||
if (m_interrupt != HAL_kInvalidHandle) {
|
||||
int32_t status = 0;
|
||||
cleanInterrupts(m_interrupt, &status);
|
||||
HAL_CleanInterrupts(m_interrupt, &status);
|
||||
// ignore status, as an invalid handle just needs to be ignored.
|
||||
m_interrupt = HAL_INVALID_HANDLE;
|
||||
m_interrupt = HAL_kInvalidHandle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,16 +44,16 @@ AnalogTriggerOutput::~AnalogTriggerOutput() {
|
||||
*/
|
||||
bool AnalogTriggerOutput::Get() const {
|
||||
int32_t status = 0;
|
||||
bool result =
|
||||
getAnalogTriggerOutput(m_trigger.m_trigger, m_outputType, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool result = HAL_GetAnalogTriggerOutput(
|
||||
m_trigger.m_trigger, (HAL_AnalogTriggerType)m_outputType, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The HAL Handle to the specified source.
|
||||
*/
|
||||
HalHandle AnalogTriggerOutput::GetPortHandleForRouting() const {
|
||||
HAL_Handle AnalogTriggerOutput::GetPortHandleForRouting() const {
|
||||
return m_trigger.m_trigger;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
|
||||
SetRange(range);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
|
||||
"Built-in accelerometer");
|
||||
HAL_Report(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
|
||||
"Built-in accelerometer");
|
||||
LiveWindow::GetInstance()->AddSensor((std::string) "BuiltInAccel", 0, this);
|
||||
}
|
||||
|
||||
@@ -29,25 +29,25 @@ void BuiltInAccelerometer::SetRange(Range range) {
|
||||
ParameterOutOfRange, "16G range not supported (use k2G, k4G, or k8G)");
|
||||
}
|
||||
|
||||
setAccelerometerActive(false);
|
||||
setAccelerometerRange((AccelerometerRange)range);
|
||||
setAccelerometerActive(true);
|
||||
HAL_SetAccelerometerActive(false);
|
||||
HAL_SetAccelerometerRange((HAL_AccelerometerRange)range);
|
||||
HAL_SetAccelerometerActive(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The acceleration of the roboRIO along the X axis in g-forces
|
||||
*/
|
||||
double BuiltInAccelerometer::GetX() { return getAccelerometerX(); }
|
||||
double BuiltInAccelerometer::GetX() { return HAL_GetAccelerometerX(); }
|
||||
|
||||
/**
|
||||
* @return The acceleration of the roboRIO along the Y axis in g-forces
|
||||
*/
|
||||
double BuiltInAccelerometer::GetY() { return getAccelerometerY(); }
|
||||
double BuiltInAccelerometer::GetY() { return HAL_GetAccelerometerY(); }
|
||||
|
||||
/**
|
||||
* @return The acceleration of the roboRIO along the Z axis in g-forces
|
||||
*/
|
||||
double BuiltInAccelerometer::GetZ() { return getAccelerometerZ(); }
|
||||
double BuiltInAccelerometer::GetZ() { return HAL_GetAccelerometerZ(); }
|
||||
|
||||
std::string BuiltInAccelerometer::GetSmartDashboardType() const {
|
||||
return "3AxisAccelerometer";
|
||||
|
||||
@@ -148,8 +148,8 @@ void CANJaguar::InitCANJaguar() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber,
|
||||
m_controlMode);
|
||||
HAL_Report(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber,
|
||||
m_controlMode);
|
||||
LiveWindow::GetInstance()->AddActuator("CANJaguar", m_deviceNumber, this);
|
||||
}
|
||||
|
||||
@@ -1566,8 +1566,8 @@ void CANJaguar::SetControlMode(ControlMode controlMode) {
|
||||
m_controlMode = controlMode;
|
||||
m_controlModeVerified = false;
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber,
|
||||
m_controlMode);
|
||||
HAL_Report(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber,
|
||||
m_controlMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -186,13 +186,13 @@ void CANTalon::Set(float value) {
|
||||
break;
|
||||
}
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
status = m_impl->SetModeSelect(m_sendMode);
|
||||
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ bool CANTalon::IsEnabled() const { return IsControlEnabled(); }
|
||||
void CANTalon::SetP(double p) {
|
||||
CTR_Code status = m_impl->SetPgain(m_profile, p);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void CANTalon::SetP(double p) {
|
||||
void CANTalon::SetI(double i) {
|
||||
CTR_Code status = m_impl->SetIgain(m_profile, i);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ void CANTalon::SetI(double i) {
|
||||
void CANTalon::SetD(double d) {
|
||||
CTR_Code status = m_impl->SetDgain(m_profile, d);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ void CANTalon::SetD(double d) {
|
||||
void CANTalon::SetF(double f) {
|
||||
CTR_Code status = m_impl->SetFgain(m_profile, f);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ void CANTalon::SetF(double f) {
|
||||
void CANTalon::SetIzone(unsigned iz) {
|
||||
CTR_Code status = m_impl->SetIzone(m_profile, iz);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ void CANTalon::SelectProfileSlot(int slotIdx) {
|
||||
m_profile = (slotIdx == 0) ? 0 : 1; /* only get two slots for now */
|
||||
CTR_Code status = m_impl->SetProfileSlotSelect(m_profile);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice feedbackDevice) {
|
||||
/* pass feedback to actual CAN frame */
|
||||
CTR_Code status = m_impl->SetFeedbackDeviceSelect((int)feedbackDevice);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice feedbackDevice) {
|
||||
void CANTalon::SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs) {
|
||||
CTR_Code status = m_impl->SetStatusFrameRate((int)stateFrame, periodMs);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ double CANTalon::GetP() const {
|
||||
// Update the info in m_impl.
|
||||
CTR_Code status = m_impl->RequestParam(param);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
// small yield for getting response
|
||||
std::this_thread::sleep_for(
|
||||
@@ -394,7 +394,7 @@ double CANTalon::GetP() const {
|
||||
double p;
|
||||
status = m_impl->GetPgain(m_profile, p);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ double CANTalon::GetI() const {
|
||||
// Update the info in m_impl.
|
||||
CTR_Code status = m_impl->RequestParam(param);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
// small yield for getting response
|
||||
std::this_thread::sleep_for(
|
||||
@@ -418,7 +418,7 @@ double CANTalon::GetI() const {
|
||||
double i;
|
||||
status = m_impl->GetIgain(m_profile, i);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ double CANTalon::GetD() const {
|
||||
// Update the info in m_impl.
|
||||
CTR_Code status = m_impl->RequestParam(param);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
// small yield for getting response
|
||||
std::this_thread::sleep_for(
|
||||
@@ -441,7 +441,7 @@ double CANTalon::GetD() const {
|
||||
double d;
|
||||
status = m_impl->GetDgain(m_profile, d);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ double CANTalon::GetF() const {
|
||||
// Update the info in m_impl.
|
||||
CTR_Code status = m_impl->RequestParam(param);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
// small yield for getting response
|
||||
@@ -465,7 +465,7 @@ double CANTalon::GetF() const {
|
||||
double f;
|
||||
status = m_impl->GetFgain(m_profile, f);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return f;
|
||||
}
|
||||
@@ -480,7 +480,7 @@ int CANTalon::GetIzone() const {
|
||||
// Update the info in m_impl.
|
||||
CTR_Code status = m_impl->RequestParam(param);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
std::this_thread::sleep_for(
|
||||
std::chrono::microseconds(kDelayForSolicitedSignalsUs));
|
||||
@@ -488,7 +488,7 @@ int CANTalon::GetIzone() const {
|
||||
int iz;
|
||||
status = m_impl->GetIzone(m_profile, iz);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return iz;
|
||||
}
|
||||
@@ -507,7 +507,7 @@ float CANTalon::GetBusVoltage() const {
|
||||
double voltage;
|
||||
CTR_Code status = m_impl->GetBatteryV(voltage);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return voltage;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ float CANTalon::GetOutputVoltage() const {
|
||||
CTR_Code status = m_impl->GetAppliedThrottle(throttle11);
|
||||
float voltage = GetBusVoltage() * (float(throttle11) / 1023.0);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return voltage;
|
||||
}
|
||||
@@ -533,7 +533,7 @@ float CANTalon::GetOutputCurrent() const {
|
||||
|
||||
CTR_Code status = m_impl->GetCurrent(current);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
return current;
|
||||
@@ -547,7 +547,7 @@ float CANTalon::GetTemperature() const {
|
||||
|
||||
CTR_Code status = m_impl->GetTemp(temp);
|
||||
if (temp != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
@@ -563,7 +563,7 @@ void CANTalon::SetPosition(double pos) {
|
||||
int32_t nativePos = ScaleRotationsToNativeUnits(m_feedbackDevice, pos);
|
||||
CTR_Code status = m_impl->SetSensorPosition(nativePos);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ double CANTalon::GetPosition() const {
|
||||
int32_t position;
|
||||
CTR_Code status = m_impl->GetSensorPosition(position);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return ScaleNativeUnitsToRotations(m_feedbackDevice, position);
|
||||
}
|
||||
@@ -594,7 +594,7 @@ double CANTalon::GetPosition() const {
|
||||
void CANTalon::SetSensorDirection(bool reverseSensor) {
|
||||
CTR_Code status = m_impl->SetRevFeedbackSensor(reverseSensor ? 1 : 0);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ void CANTalon::SetSensorDirection(bool reverseSensor) {
|
||||
void CANTalon::SetClosedLoopOutputDirection(bool reverseOutput) {
|
||||
CTR_Code status = m_impl->SetRevMotDuringCloseLoopEn(reverseOutput ? 1 : 0);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ int CANTalon::GetClosedLoopError() const {
|
||||
/* retrieve the closed loop error in native units */
|
||||
CTR_Code status = m_impl->GetCloseLoopErr(error);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ double CANTalon::GetSpeed() const {
|
||||
int32_t speed;
|
||||
CTR_Code status = m_impl->GetSensorVelocity(speed);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return ScaleNativeUnitsToRpm(m_feedbackDevice, speed);
|
||||
}
|
||||
@@ -687,7 +687,7 @@ int CANTalon::GetAnalogIn() const {
|
||||
int position;
|
||||
CTR_Code status = m_impl->GetAnalogInWithOv(position);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return position;
|
||||
}
|
||||
@@ -695,7 +695,7 @@ int CANTalon::GetAnalogIn() const {
|
||||
void CANTalon::SetAnalogPosition(int newPosition) {
|
||||
CTR_Code status = m_impl->SetParam(CanTalonSRX::eAinPosition, newPosition);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,7 +717,7 @@ int CANTalon::GetAnalogInVel() const {
|
||||
int vel;
|
||||
CTR_Code status = m_impl->GetAnalogInVel(vel);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return vel;
|
||||
}
|
||||
@@ -732,14 +732,14 @@ int CANTalon::GetEncPosition() const {
|
||||
int position;
|
||||
CTR_Code status = m_impl->GetEncPosition(position);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return position;
|
||||
}
|
||||
void CANTalon::SetEncPosition(int newPosition) {
|
||||
CTR_Code status = m_impl->SetParam(CanTalonSRX::eEncPosition, newPosition);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ int CANTalon::GetEncVel() const {
|
||||
int vel;
|
||||
CTR_Code status = m_impl->GetEncVel(vel);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return vel;
|
||||
}
|
||||
@@ -761,34 +761,34 @@ int CANTalon::GetPulseWidthPosition() const {
|
||||
int param;
|
||||
CTR_Code status = m_impl->GetPulseWidthPosition(param);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return param;
|
||||
}
|
||||
void CANTalon::SetPulseWidthPosition(int newPosition) {
|
||||
CTR_Code status = m_impl->SetParam(CanTalonSRX::ePwdPosition, newPosition);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
int CANTalon::GetPulseWidthVelocity() const {
|
||||
int param;
|
||||
CTR_Code status = m_impl->GetPulseWidthVelocity(param);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return param;
|
||||
}
|
||||
int CANTalon::GetPulseWidthRiseToFallUs() const {
|
||||
int param;
|
||||
CTR_Code status = m_impl->GetPulseWidthRiseToFallUs(param);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return param;
|
||||
}
|
||||
int CANTalon::GetPulseWidthRiseToRiseUs() const {
|
||||
int param;
|
||||
CTR_Code status = m_impl->GetPulseWidthRiseToRiseUs(param);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return param;
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ int CANTalon::GetPinStateQuadA() const {
|
||||
int retval;
|
||||
CTR_Code status = m_impl->GetQuadApin(retval);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -852,7 +852,7 @@ int CANTalon::GetPinStateQuadB() const {
|
||||
int retval;
|
||||
CTR_Code status = m_impl->GetQuadBpin(retval);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -864,7 +864,7 @@ int CANTalon::GetPinStateQuadIdx() const {
|
||||
int retval;
|
||||
CTR_Code status = m_impl->GetQuadIdxpin(retval);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -878,7 +878,7 @@ int CANTalon::IsFwdLimitSwitchClosed() const {
|
||||
CTR_Code status = m_impl->GetLimitSwitchClosedFor(
|
||||
retval); /* rename this func, '1' => open, '0' => closed */
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return retval ? 0 : 1;
|
||||
}
|
||||
@@ -892,7 +892,7 @@ int CANTalon::IsRevLimitSwitchClosed() const {
|
||||
CTR_Code status = m_impl->GetLimitSwitchClosedRev(
|
||||
retval); /* rename this func, '1' => open, '0' => closed */
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return retval ? 0 : 1;
|
||||
}
|
||||
@@ -906,7 +906,7 @@ int CANTalon::GetNumberOfQuadIdxRises() const {
|
||||
CTR_Code status = m_impl->GetEncIndexRiseEvents(
|
||||
rises); /* rename this func, '1' => open, '0' => closed */
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return rises;
|
||||
}
|
||||
@@ -920,7 +920,7 @@ void CANTalon::SetNumberOfQuadIdxRises(int rises) {
|
||||
CanTalonSRX::eEncIndexRiseEvents,
|
||||
rises); /* rename this func, '1' => open, '0' => closed */
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,11 +933,11 @@ bool CANTalon::GetForwardLimitOK() const {
|
||||
CTR_Code status = CTR_OKAY;
|
||||
status = m_impl->GetFault_ForSoftLim(softLim);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
status = m_impl->GetFault_ForLim(limSwit);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
/* If either fault is asserted, signal caller we are disabled (with false?) */
|
||||
return (softLim | limSwit) ? false : true;
|
||||
@@ -952,11 +952,11 @@ bool CANTalon::GetReverseLimitOK() const {
|
||||
CTR_Code status = CTR_OKAY;
|
||||
status = m_impl->GetFault_RevSoftLim(softLim);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
status = m_impl->GetFault_RevLim(limSwit);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
/* If either fault is asserted, signal caller we are disabled (with false?) */
|
||||
return (softLim | limSwit) ? false : true;
|
||||
@@ -974,42 +974,42 @@ uint16_t CANTalon::GetFaults() const {
|
||||
val = 0;
|
||||
status = m_impl->GetFault_OverTemp(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kTemperatureFault : 0;
|
||||
|
||||
/* voltage */
|
||||
val = 0;
|
||||
status = m_impl->GetFault_UnderVoltage(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kBusVoltageFault : 0;
|
||||
|
||||
/* fwd-limit-switch */
|
||||
val = 0;
|
||||
status = m_impl->GetFault_ForLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kFwdLimitSwitch : 0;
|
||||
|
||||
/* rev-limit-switch */
|
||||
val = 0;
|
||||
status = m_impl->GetFault_RevLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kRevLimitSwitch : 0;
|
||||
|
||||
/* fwd-soft-limit */
|
||||
val = 0;
|
||||
status = m_impl->GetFault_ForSoftLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kFwdSoftLimit : 0;
|
||||
|
||||
/* rev-soft-limit */
|
||||
val = 0;
|
||||
status = m_impl->GetFault_RevSoftLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kRevSoftLimit : 0;
|
||||
|
||||
return retval;
|
||||
@@ -1024,42 +1024,42 @@ uint16_t CANTalon::GetStickyFaults() const {
|
||||
val = 0;
|
||||
status = m_impl->GetStckyFault_OverTemp(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kTemperatureFault : 0;
|
||||
|
||||
/* voltage */
|
||||
val = 0;
|
||||
status = m_impl->GetStckyFault_UnderVoltage(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kBusVoltageFault : 0;
|
||||
|
||||
/* fwd-limit-switch */
|
||||
val = 0;
|
||||
status = m_impl->GetStckyFault_ForLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kFwdLimitSwitch : 0;
|
||||
|
||||
/* rev-limit-switch */
|
||||
val = 0;
|
||||
status = m_impl->GetStckyFault_RevLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kRevLimitSwitch : 0;
|
||||
|
||||
/* fwd-soft-limit */
|
||||
val = 0;
|
||||
status = m_impl->GetStckyFault_ForSoftLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kFwdSoftLimit : 0;
|
||||
|
||||
/* rev-soft-limit */
|
||||
val = 0;
|
||||
status = m_impl->GetStckyFault_RevSoftLim(val);
|
||||
if (status != CTR_OKAY)
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval |= (val) ? CANSpeedController::kRevSoftLimit : 0;
|
||||
|
||||
return retval;
|
||||
@@ -1067,7 +1067,7 @@ uint16_t CANTalon::GetStickyFaults() const {
|
||||
|
||||
void CANTalon::ClearStickyFaults() {
|
||||
CTR_Code status = m_impl->ClearStickyFaults();
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1088,7 +1088,7 @@ void CANTalon::SetVoltageRampRate(double rampRate) {
|
||||
double rampRatedThrotPer10ms = (rampRate * 1023.0 / 12.0) / 100;
|
||||
CTR_Code status = m_impl->SetRampThrottle((int)rampRatedThrotPer10ms);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1098,7 +1098,7 @@ void CANTalon::SetVoltageCompensationRampRate(double rampRate) {
|
||||
CTR_Code status = CTR_OKAY;
|
||||
status = m_impl->SetVoltageCompensationRate(rampRate / 1000);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ void CANTalon::SetCloseLoopRampRate(double rampRate) {
|
||||
CTR_Code status = m_impl->SetCloseLoopRampRate(
|
||||
m_profile, rampRate * 1023.0 / 12.0 / 1000.0);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1125,20 +1125,20 @@ uint32_t CANTalon::GetFirmwareVersion() const {
|
||||
int firmwareVersion;
|
||||
CTR_Code status = m_impl->RequestParam(CanTalonSRX::eFirmVers);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
std::this_thread::sleep_for(
|
||||
std::chrono::microseconds(kDelayForSolicitedSignalsUs));
|
||||
status =
|
||||
m_impl->GetParamResponseInt32(CanTalonSRX::eFirmVers, firmwareVersion);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/* only sent once on boot */
|
||||
// CTR_Code status = m_impl->GetFirmVers(firmwareVersion);
|
||||
// if (status != CTR_OKAY) {
|
||||
// wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
// wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
//}
|
||||
|
||||
return firmwareVersion;
|
||||
@@ -1150,7 +1150,7 @@ uint32_t CANTalon::GetFirmwareVersion() const {
|
||||
int CANTalon::GetIaccum() const {
|
||||
CTR_Code status = m_impl->RequestParam(CanTalonSRX::ePidIaccum);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
// small yield for getting response
|
||||
std::this_thread::sleep_for(
|
||||
@@ -1158,7 +1158,7 @@ int CANTalon::GetIaccum() const {
|
||||
int iaccum;
|
||||
status = m_impl->GetParamResponseInt32(CanTalonSRX::ePidIaccum, iaccum);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return iaccum;
|
||||
}
|
||||
@@ -1169,7 +1169,7 @@ int CANTalon::GetIaccum() const {
|
||||
void CANTalon::ClearIaccum() {
|
||||
CTR_Code status = m_impl->SetParam(CanTalonSRX::ePidIaccum, 0);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1195,7 +1195,7 @@ void CANTalon::ConfigNeutralMode(NeutralMode mode) {
|
||||
break;
|
||||
}
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,7 +1207,7 @@ int CANTalon::GetBrakeEnableDuringNeutral() const {
|
||||
int brakeEn = 0;
|
||||
CTR_Code status = m_impl->GetBrakeIsEnabled(brakeEn);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
return brakeEn;
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ void CANTalon::ConfigLimitSwitchOverrides(bool bForwardLimitSwitchEn,
|
||||
/* update signal and error check code */
|
||||
status = m_impl->SetOverrideLimitSwitchEn(fwdRevEnable);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1315,17 +1315,17 @@ void CANTalon::ConfigLimitMode(LimitMode mode) {
|
||||
* limit switch.*/
|
||||
status = m_impl->SetForwardSoftEnable(false);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
status = m_impl->SetReverseSoftEnable(false);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
/* override enable the limit switches, this circumvents the webdash */
|
||||
status = m_impl->SetOverrideLimitSwitchEn(
|
||||
CanTalonSRX::kLimitSwitchOverride_EnableFwd_EnableRev);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
break;
|
||||
case kLimitMode_SoftPositionLimits: /** Use both switches and soft limits */
|
||||
@@ -1333,17 +1333,17 @@ void CANTalon::ConfigLimitMode(LimitMode mode) {
|
||||
* limit switch.*/
|
||||
status = m_impl->SetForwardSoftEnable(true);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
status = m_impl->SetReverseSoftEnable(true);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
/* override enable the limit switches, this circumvents the webdash */
|
||||
status = m_impl->SetOverrideLimitSwitchEn(
|
||||
CanTalonSRX::kLimitSwitchOverride_EnableFwd_EnableRev);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1353,17 +1353,17 @@ void CANTalon::ConfigLimitMode(LimitMode mode) {
|
||||
* limit switch.*/
|
||||
status = m_impl->SetForwardSoftEnable(false);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
status = m_impl->SetReverseSoftEnable(false);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
/* override enable the limit switches, this circumvents the webdash */
|
||||
status = m_impl->SetOverrideLimitSwitchEn(
|
||||
CanTalonSRX::kLimitSwitchOverride_DisableFwd_DisableRev);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1378,7 +1378,7 @@ void CANTalon::ConfigForwardLimit(double forwardLimitPosition) {
|
||||
ScaleRotationsToNativeUnits(m_feedbackDevice, forwardLimitPosition);
|
||||
status = m_impl->SetForwardSoftLimit(nativeLimitPos);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,7 +1393,7 @@ void CANTalon::ConfigForwardSoftLimitEnable(bool bForwardSoftLimitEn) {
|
||||
CTR_Code status = CTR_OKAY;
|
||||
status = m_impl->SetForwardSoftEnable(bForwardSoftLimitEn);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1408,7 +1408,7 @@ void CANTalon::ConfigReverseSoftLimitEnable(bool bReverseSoftLimitEn) {
|
||||
CTR_Code status = CTR_OKAY;
|
||||
status = m_impl->SetReverseSoftEnable(bReverseSoftLimitEn);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1427,7 +1427,7 @@ void CANTalon::ConfigFwdLimitSwitchNormallyOpen(bool normallyOpen) {
|
||||
m_impl->SetParam(CanTalonSRX::eOnBoot_LimitSwitch_Forward_NormallyClosed,
|
||||
normallyOpen ? 0 : 1);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1446,7 +1446,7 @@ void CANTalon::ConfigRevLimitSwitchNormallyOpen(bool normallyOpen) {
|
||||
m_impl->SetParam(CanTalonSRX::eOnBoot_LimitSwitch_Reverse_NormallyClosed,
|
||||
normallyOpen ? 0 : 1);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1459,7 +1459,7 @@ void CANTalon::ConfigReverseLimit(double reverseLimitPosition) {
|
||||
ScaleRotationsToNativeUnits(m_feedbackDevice, reverseLimitPosition);
|
||||
status = m_impl->SetReverseSoftLimit(nativeLimitPos);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1515,7 +1515,7 @@ void CANTalon::ConfigSetParameter(uint32_t paramEnum, double value) {
|
||||
/* config peak throttle when in closed-loop mode in the positive direction. */
|
||||
status = m_impl->SetParam((CanTalonSRX::param_t)paramEnum, value);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1528,7 +1528,7 @@ bool CANTalon::GetParameter(uint32_t paramEnum, double& dvalue) const {
|
||||
/* send the request frame */
|
||||
CTR_Code status = m_impl->RequestParam((CanTalonSRX::param_t)paramEnum);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval = false;
|
||||
}
|
||||
/* small yield for getting response */
|
||||
@@ -1537,7 +1537,7 @@ bool CANTalon::GetParameter(uint32_t paramEnum, double& dvalue) const {
|
||||
/* get the last received update */
|
||||
status = m_impl->GetParamResponse((CanTalonSRX::param_t)paramEnum, dvalue);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
retval = false;
|
||||
}
|
||||
return retval;
|
||||
@@ -1560,8 +1560,8 @@ void CANTalon::ConfigFaultTime(float faultTime) {
|
||||
*/
|
||||
void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode) {
|
||||
m_controlMode = mode;
|
||||
HALReport(HALUsageReporting::kResourceType_CANTalonSRX, m_deviceNumber + 1,
|
||||
mode);
|
||||
HAL_Report(HALUsageReporting::kResourceType_CANTalonSRX, m_deviceNumber + 1,
|
||||
mode);
|
||||
switch (mode) {
|
||||
case kPercentVbus:
|
||||
m_sendMode = kThrottle;
|
||||
@@ -1588,7 +1588,7 @@ void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode) {
|
||||
// Keep the talon disabled until Set() is called.
|
||||
CTR_Code status = m_impl->SetModeSelect((int)kDisabled);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1723,7 +1723,7 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
|
||||
}
|
||||
/* handle any detected errors */
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
/* if scaling information is not possible, signal caller
|
||||
* by returning zero
|
||||
@@ -1979,7 +1979,7 @@ void CANTalon::GetMotionProfileStatus(
|
||||
0; /* this signal is only used sending pts to Talon */
|
||||
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
Compressor::Compressor(uint8_t pcmID) {
|
||||
int32_t status = 0;
|
||||
m_compressorHandle = initializeCompressor(pcmID, &status);
|
||||
m_compressorHandle = HAL_InitializeCompressor(pcmID, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return;
|
||||
}
|
||||
SetClosedLoopControl(true);
|
||||
@@ -50,7 +50,7 @@ bool Compressor::Enabled() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressor(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressor(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -69,7 +69,7 @@ bool Compressor::GetPressureSwitchValue() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getPressureSwitch(m_compressorHandle, &status);
|
||||
value = HAL_GetPressureSwitch(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -88,7 +88,7 @@ float Compressor::GetCompressorCurrent() const {
|
||||
int32_t status = 0;
|
||||
float value;
|
||||
|
||||
value = getCompressorCurrent(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressorCurrent(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -108,7 +108,7 @@ void Compressor::SetClosedLoopControl(bool on) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
|
||||
setClosedLoopControl(m_compressorHandle, on, &status);
|
||||
HAL_SetClosedLoopControl(m_compressorHandle, on, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -127,7 +127,7 @@ bool Compressor::GetClosedLoopControl() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getClosedLoopControl(m_compressorHandle, &status);
|
||||
value = HAL_GetClosedLoopControl(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -147,7 +147,7 @@ bool Compressor::GetCompressorCurrentTooHighFault() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorCurrentTooHighFault(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressorCurrentTooHighFault(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -171,7 +171,8 @@ bool Compressor::GetCompressorCurrentTooHighStickyFault() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorCurrentTooHighStickyFault(m_compressorHandle, &status);
|
||||
value =
|
||||
HAL_GetCompressorCurrentTooHighStickyFault(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -195,7 +196,7 @@ bool Compressor::GetCompressorShortedStickyFault() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorShortedStickyFault(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressorShortedStickyFault(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -215,7 +216,7 @@ bool Compressor::GetCompressorShortedFault() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorShortedFault(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressorShortedFault(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -238,7 +239,7 @@ bool Compressor::GetCompressorNotConnectedStickyFault() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorNotConnectedStickyFault(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressorNotConnectedStickyFault(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -258,7 +259,7 @@ bool Compressor::GetCompressorNotConnectedFault() const {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorNotConnectedFault(m_compressorHandle, &status);
|
||||
value = HAL_GetCompressorNotConnectedFault(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
@@ -281,7 +282,7 @@ void Compressor::ClearAllPCMStickyFaults() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
|
||||
clearAllPCMStickyFaults(m_compressorHandle, &status);
|
||||
HAL_ClearAllPCMStickyFaults(m_compressorHandle, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
double ControllerPower::GetInputVoltage() {
|
||||
int32_t status = 0;
|
||||
double retVal = getVinVoltage(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetVinVoltage(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ double ControllerPower::GetInputVoltage() {
|
||||
*/
|
||||
double ControllerPower::GetInputCurrent() {
|
||||
int32_t status = 0;
|
||||
double retVal = getVinCurrent(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetVinCurrent(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ double ControllerPower::GetInputCurrent() {
|
||||
*/
|
||||
double ControllerPower::GetVoltage6V() {
|
||||
int32_t status = 0;
|
||||
double retVal = getUserVoltage6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetUserVoltage6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ double ControllerPower::GetVoltage6V() {
|
||||
*/
|
||||
double ControllerPower::GetCurrent6V() {
|
||||
int32_t status = 0;
|
||||
double retVal = getUserCurrent6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetUserCurrent6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ double ControllerPower::GetCurrent6V() {
|
||||
*/
|
||||
bool ControllerPower::GetEnabled6V() {
|
||||
int32_t status = 0;
|
||||
bool retVal = getUserActive6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool retVal = HAL_GetUserActive6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ bool ControllerPower::GetEnabled6V() {
|
||||
*/
|
||||
int ControllerPower::GetFaultCount6V() {
|
||||
int32_t status = 0;
|
||||
int retVal = getUserCurrentFaults6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
int retVal = HAL_GetUserCurrentFaults6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ int ControllerPower::GetFaultCount6V() {
|
||||
*/
|
||||
double ControllerPower::GetVoltage5V() {
|
||||
int32_t status = 0;
|
||||
double retVal = getUserVoltage5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetUserVoltage5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ double ControllerPower::GetVoltage5V() {
|
||||
*/
|
||||
double ControllerPower::GetCurrent5V() {
|
||||
int32_t status = 0;
|
||||
double retVal = getUserCurrent5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetUserCurrent5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ double ControllerPower::GetCurrent5V() {
|
||||
*/
|
||||
bool ControllerPower::GetEnabled5V() {
|
||||
int32_t status = 0;
|
||||
bool retVal = getUserActive5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool retVal = HAL_GetUserActive5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -132,8 +132,8 @@ bool ControllerPower::GetEnabled5V() {
|
||||
*/
|
||||
int ControllerPower::GetFaultCount5V() {
|
||||
int32_t status = 0;
|
||||
int retVal = getUserCurrentFaults5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
int retVal = HAL_GetUserCurrentFaults5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ int ControllerPower::GetFaultCount5V() {
|
||||
*/
|
||||
double ControllerPower::GetVoltage3V3() {
|
||||
int32_t status = 0;
|
||||
double retVal = getUserVoltage3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetUserVoltage3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ double ControllerPower::GetVoltage3V3() {
|
||||
*/
|
||||
double ControllerPower::GetCurrent3V3() {
|
||||
int32_t status = 0;
|
||||
double retVal = getUserCurrent3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_GetUserCurrent3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -169,8 +169,8 @@ double ControllerPower::GetCurrent3V3() {
|
||||
*/
|
||||
bool ControllerPower::GetEnabled3V3() {
|
||||
int32_t status = 0;
|
||||
bool retVal = getUserActive3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool retVal = HAL_GetUserActive3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ bool ControllerPower::GetEnabled3V3() {
|
||||
*/
|
||||
int ControllerPower::GetFaultCount3V3() {
|
||||
int32_t status = 0;
|
||||
int retVal = getUserCurrentFaults3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
int retVal = HAL_GetUserCurrentFaults3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
*/
|
||||
Counter::Counter(Mode mode) {
|
||||
int32_t status = 0;
|
||||
m_counter = initializeCounter(mode, &m_index, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_counter = HAL_InitializeCounter((HAL_Counter_Mode)mode, &m_index, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
SetMaxPeriod(.5);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Counter, m_index, mode);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Counter, m_index, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ Counter::Counter(int32_t channel) : Counter(kTwoPulse) {
|
||||
*/
|
||||
DEPRECATED("Use pass-by-reference instead.")
|
||||
Counter::Counter(AnalogTrigger* trigger) : Counter(kTwoPulse) {
|
||||
SetUpSource(trigger->CreateOutput(kState));
|
||||
SetUpSource(trigger->CreateOutput(AnalogTriggerType::kState));
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ Counter::Counter(AnalogTrigger* trigger) : Counter(kTwoPulse) {
|
||||
* @param trigger The reference to the existing AnalogTrigger object.
|
||||
*/
|
||||
Counter::Counter(const AnalogTrigger& trigger) : Counter(kTwoPulse) {
|
||||
SetUpSource(trigger.CreateOutput(kState));
|
||||
SetUpSource(trigger.CreateOutput(AnalogTriggerType::kState));
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
@@ -162,13 +162,13 @@ Counter::Counter(EncodingType encodingType,
|
||||
|
||||
if (encodingType == k1X) {
|
||||
SetUpSourceEdge(true, false);
|
||||
setCounterAverageSize(m_counter, 1, &status);
|
||||
HAL_SetCounterAverageSize(m_counter, 1, &status);
|
||||
} else {
|
||||
SetUpSourceEdge(true, true);
|
||||
setCounterAverageSize(m_counter, 2, &status);
|
||||
HAL_SetCounterAverageSize(m_counter, 2, &status);
|
||||
}
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
SetDownSourceEdge(inverted, true);
|
||||
}
|
||||
|
||||
@@ -179,9 +179,9 @@ Counter::~Counter() {
|
||||
SetUpdateWhenEmpty(true);
|
||||
|
||||
int32_t status = 0;
|
||||
freeCounter(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_counter = HAL_INVALID_HANDLE;
|
||||
HAL_FreeCounter(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_counter = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,9 +234,11 @@ void Counter::SetUpSource(std::shared_ptr<DigitalSource> source) {
|
||||
CloneError(*m_upSource);
|
||||
} else {
|
||||
int32_t status = 0;
|
||||
setCounterUpSource(m_counter, source->GetPortHandleForRouting(),
|
||||
source->GetAnalogTriggerTypeForRouting(), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterUpSource(
|
||||
m_counter, source->GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)source->GetAnalogTriggerTypeForRouting(),
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,8 +275,8 @@ void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge) {
|
||||
"Must set non-nullptr UpSource before setting UpSourceEdge");
|
||||
}
|
||||
int32_t status = 0;
|
||||
setCounterUpSourceEdge(m_counter, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterUpSourceEdge(m_counter, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,8 +286,8 @@ void Counter::ClearUpSource() {
|
||||
if (StatusIsFatal()) return;
|
||||
m_upSource.reset();
|
||||
int32_t status = 0;
|
||||
clearCounterUpSource(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_ClearCounterUpSource(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,9 +342,11 @@ void Counter::SetDownSource(std::shared_ptr<DigitalSource> source) {
|
||||
CloneError(*m_downSource);
|
||||
} else {
|
||||
int32_t status = 0;
|
||||
setCounterDownSource(m_counter, source->GetPortHandleForRouting(),
|
||||
source->GetAnalogTriggerTypeForRouting(), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterDownSource(
|
||||
m_counter, source->GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)source->GetAnalogTriggerTypeForRouting(),
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,8 +383,8 @@ void Counter::SetDownSourceEdge(bool risingEdge, bool fallingEdge) {
|
||||
"Must set non-nullptr DownSource before setting DownSourceEdge");
|
||||
}
|
||||
int32_t status = 0;
|
||||
setCounterDownSourceEdge(m_counter, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterDownSourceEdge(m_counter, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,8 +394,8 @@ void Counter::ClearDownSource() {
|
||||
if (StatusIsFatal()) return;
|
||||
m_downSource.reset();
|
||||
int32_t status = 0;
|
||||
clearCounterDownSource(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_ClearCounterDownSource(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,8 +406,8 @@ void Counter::ClearDownSource() {
|
||||
void Counter::SetUpDownCounterMode() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterUpDownMode(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterUpDownMode(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,8 +419,8 @@ void Counter::SetUpDownCounterMode() {
|
||||
void Counter::SetExternalDirectionMode() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterExternalDirectionMode(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterExternalDirectionMode(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,8 +431,8 @@ void Counter::SetExternalDirectionMode() {
|
||||
void Counter::SetSemiPeriodMode(bool highSemiPeriod) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterSemiPeriodMode(m_counter, highSemiPeriod, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterSemiPeriodMode(m_counter, highSemiPeriod, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,8 +447,8 @@ void Counter::SetSemiPeriodMode(bool highSemiPeriod) {
|
||||
void Counter::SetPulseLengthMode(float threshold) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterPulseLengthMode(m_counter, threshold, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterPulseLengthMode(m_counter, threshold, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,8 +462,8 @@ void Counter::SetPulseLengthMode(float threshold) {
|
||||
*/
|
||||
int Counter::GetSamplesToAverage() const {
|
||||
int32_t status = 0;
|
||||
int32_t samples = getCounterSamplesToAverage(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t samples = HAL_GetCounterSamplesToAverage(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return samples;
|
||||
}
|
||||
|
||||
@@ -477,8 +481,8 @@ void Counter::SetSamplesToAverage(int samplesToAverage) {
|
||||
"Average counter values must be between 1 and 127");
|
||||
}
|
||||
int32_t status = 0;
|
||||
setCounterSamplesToAverage(m_counter, samplesToAverage, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterSamplesToAverage(m_counter, samplesToAverage, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,8 +494,8 @@ void Counter::SetSamplesToAverage(int samplesToAverage) {
|
||||
int32_t Counter::Get() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t value = getCounter(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t value = HAL_GetCounter(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -504,8 +508,8 @@ int32_t Counter::Get() const {
|
||||
void Counter::Reset() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
resetCounter(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_ResetCounter(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -519,8 +523,8 @@ void Counter::Reset() {
|
||||
double Counter::GetPeriod() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
double value = getCounterPeriod(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double value = HAL_GetCounterPeriod(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -537,8 +541,8 @@ double Counter::GetPeriod() const {
|
||||
void Counter::SetMaxPeriod(double maxPeriod) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterMaxPeriod(m_counter, maxPeriod, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterMaxPeriod(m_counter, maxPeriod, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,8 +565,8 @@ void Counter::SetMaxPeriod(double maxPeriod) {
|
||||
void Counter::SetUpdateWhenEmpty(bool enabled) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterUpdateWhenEmpty(m_counter, enabled, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterUpdateWhenEmpty(m_counter, enabled, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,8 +582,8 @@ void Counter::SetUpdateWhenEmpty(bool enabled) {
|
||||
bool Counter::GetStopped() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool value = getCounterStopped(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_GetCounterStopped(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -591,8 +595,8 @@ bool Counter::GetStopped() const {
|
||||
bool Counter::GetDirection() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool value = getCounterDirection(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_GetCounterDirection(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -607,8 +611,8 @@ bool Counter::GetDirection() const {
|
||||
void Counter::SetReverseDirection(bool reverseDirection) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setCounterReverseDirection(m_counter, reverseDirection, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetCounterReverseDirection(m_counter, reverseDirection, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void Counter::UpdateTable() {
|
||||
|
||||
@@ -29,7 +29,7 @@ DigitalGlitchFilter::DigitalGlitchFilter() {
|
||||
m_channelIndex = std::distance(m_filterAllocated.begin(), index);
|
||||
*index = true;
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_DigitalFilter, m_channelIndex);
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalFilter, m_channelIndex);
|
||||
}
|
||||
|
||||
DigitalGlitchFilter::~DigitalGlitchFilter() {
|
||||
@@ -59,16 +59,17 @@ void DigitalGlitchFilter::DoAdd(DigitalSource* input, int requested_index) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
setFilterSelect(input->GetPortHandleForRouting(), requested_index, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetFilterSelect(input->GetPortHandleForRouting(), requested_index,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
// Validate that we set it correctly.
|
||||
int actual_index =
|
||||
getFilterSelect(input->GetPortHandleForRouting(), &status);
|
||||
HAL_GetFilterSelect(input->GetPortHandleForRouting(), &status);
|
||||
wpi_assertEqual(actual_index, requested_index);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_DigitalInput,
|
||||
input->GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalInput,
|
||||
input->GetChannel());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,8 +148,8 @@ void DigitalGlitchFilter::Remove(Counter* input) {
|
||||
*/
|
||||
void DigitalGlitchFilter::SetPeriodCycles(uint32_t fpga_cycles) {
|
||||
int32_t status = 0;
|
||||
setFilterPeriod(m_channelIndex, fpga_cycles, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetFilterPeriod(m_channelIndex, fpga_cycles, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,10 +160,10 @@ void DigitalGlitchFilter::SetPeriodCycles(uint32_t fpga_cycles) {
|
||||
void DigitalGlitchFilter::SetPeriodNanoSeconds(uint64_t nanoseconds) {
|
||||
int32_t status = 0;
|
||||
uint32_t fpga_cycles =
|
||||
nanoseconds * HAL_getSystemClockTicksPerMicrosecond() / 4 / 1000;
|
||||
setFilterPeriod(m_channelIndex, fpga_cycles, &status);
|
||||
nanoseconds * HAL_GetSystemClockTicksPerMicrosecond() / 4 / 1000;
|
||||
HAL_SetFilterPeriod(m_channelIndex, fpga_cycles, &status);
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,9 +173,9 @@ void DigitalGlitchFilter::SetPeriodNanoSeconds(uint64_t nanoseconds) {
|
||||
*/
|
||||
uint32_t DigitalGlitchFilter::GetPeriodCycles() {
|
||||
int32_t status = 0;
|
||||
uint32_t fpga_cycles = getFilterPeriod(m_channelIndex, &status);
|
||||
uint32_t fpga_cycles = HAL_GetFilterPeriod(m_channelIndex, &status);
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return fpga_cycles;
|
||||
}
|
||||
@@ -186,10 +187,10 @@ uint32_t DigitalGlitchFilter::GetPeriodCycles() {
|
||||
*/
|
||||
uint64_t DigitalGlitchFilter::GetPeriodNanoSeconds() {
|
||||
int32_t status = 0;
|
||||
uint32_t fpga_cycles = getFilterPeriod(m_channelIndex, &status);
|
||||
uint32_t fpga_cycles = HAL_GetFilterPeriod(m_channelIndex, &status);
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return static_cast<uint64_t>(fpga_cycles) * 1000L /
|
||||
static_cast<uint64_t>(HAL_getSystemClockTicksPerMicrosecond() / 4);
|
||||
static_cast<uint64_t>(HAL_GetSystemClockTicksPerMicrosecond() / 4);
|
||||
}
|
||||
|
||||
@@ -33,16 +33,16 @@ DigitalInput::DigitalInput(uint32_t channel) {
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
m_handle = initializeDIOPort(getPort(channel), true, &status);
|
||||
m_handle = HAL_InitializeDIOPort(HAL_GetPort(channel), true, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_handle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_handle = HAL_kInvalidHandle;
|
||||
m_channel = std::numeric_limits<uint32_t>::max();
|
||||
return;
|
||||
}
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("DigitalInput", channel, this);
|
||||
HALReport(HALUsageReporting::kResourceType_DigitalInput, channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalInput, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,14 +50,14 @@ DigitalInput::DigitalInput(uint32_t channel) {
|
||||
*/
|
||||
DigitalInput::~DigitalInput() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_interrupt != HAL_INVALID_HANDLE) {
|
||||
if (m_interrupt != HAL_kInvalidHandle) {
|
||||
int32_t status = 0;
|
||||
cleanInterrupts(m_interrupt, &status);
|
||||
HAL_CleanInterrupts(m_interrupt, &status);
|
||||
// ignore status, as an invalid handle just needs to be ignored.
|
||||
m_interrupt = HAL_INVALID_HANDLE;
|
||||
m_interrupt = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
freeDIOPort(m_handle);
|
||||
HAL_FreeDIOPort(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +68,8 @@ DigitalInput::~DigitalInput() {
|
||||
bool DigitalInput::Get() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool value = getDIO(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_GetDIO(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ uint32_t DigitalInput::GetChannel() const { return m_channel; }
|
||||
/**
|
||||
* @return The HAL Handle to the specified source.
|
||||
*/
|
||||
HalHandle DigitalInput::GetPortHandleForRouting() const { return m_handle; }
|
||||
HAL_Handle DigitalInput::GetPortHandleForRouting() const { return m_handle; }
|
||||
|
||||
/**
|
||||
* Is source an AnalogTrigger
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
DigitalOutput::DigitalOutput(uint32_t channel) {
|
||||
std::stringstream buf;
|
||||
|
||||
m_pwmGenerator = HAL_INVALID_HANDLE;
|
||||
m_pwmGenerator = HAL_kInvalidHandle;
|
||||
if (!CheckDigitalChannel(channel)) {
|
||||
buf << "Digital Channel " << channel;
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
|
||||
@@ -34,15 +34,15 @@ DigitalOutput::DigitalOutput(uint32_t channel) {
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
m_handle = initializeDIOPort(getPort(channel), false, &status);
|
||||
m_handle = HAL_InitializeDIOPort(HAL_GetPort(channel), false, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_channel = std::numeric_limits<uint32_t>::max();
|
||||
m_handle = HAL_INVALID_HANDLE;
|
||||
m_handle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_DigitalOutput, channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalOutput, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ DigitalOutput::~DigitalOutput() {
|
||||
// Disable the PWM in case it was running.
|
||||
DisablePWM();
|
||||
|
||||
freeDIOPort(m_handle);
|
||||
HAL_FreeDIOPort(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +68,8 @@ void DigitalOutput::Set(uint32_t value) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
setDIO(m_handle, value, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetDIO(m_handle, value, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ void DigitalOutput::Pulse(float length) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
pulse(m_handle, length, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_Pulse(m_handle, length, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,8 +102,8 @@ bool DigitalOutput::IsPulsing() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
|
||||
int32_t status = 0;
|
||||
bool value = isPulsing(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_IsPulsing(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ void DigitalOutput::SetPWMRate(float rate) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
setDigitalPWMRate(rate, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetDigitalPWMRate(rate, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,21 +139,21 @@ void DigitalOutput::SetPWMRate(float rate) {
|
||||
* @param initialDutyCycle The duty-cycle to start generating. [0..1]
|
||||
*/
|
||||
void DigitalOutput::EnablePWM(float initialDutyCycle) {
|
||||
if (m_pwmGenerator != HAL_INVALID_HANDLE) return;
|
||||
if (m_pwmGenerator != HAL_kInvalidHandle) return;
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
if (StatusIsFatal()) return;
|
||||
m_pwmGenerator = allocateDigitalPWM(&status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_pwmGenerator = HAL_AllocateDigitalPWM(&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
if (StatusIsFatal()) return;
|
||||
setDigitalPWMDutyCycle(m_pwmGenerator, initialDutyCycle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetDigitalPWMDutyCycle(m_pwmGenerator, initialDutyCycle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
if (StatusIsFatal()) return;
|
||||
setDigitalPWMOutputChannel(m_pwmGenerator, m_channel, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, m_channel, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,18 +163,18 @@ void DigitalOutput::EnablePWM(float initialDutyCycle) {
|
||||
*/
|
||||
void DigitalOutput::DisablePWM() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_pwmGenerator == HAL_INVALID_HANDLE) return;
|
||||
if (m_pwmGenerator == HAL_kInvalidHandle) return;
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
// Disable the output by routing to a dead bit.
|
||||
setDigitalPWMOutputChannel(m_pwmGenerator, kDigitalChannels, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, kDigitalChannels, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
freeDigitalPWM(m_pwmGenerator, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_FreeDigitalPWM(m_pwmGenerator, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
m_pwmGenerator = HAL_INVALID_HANDLE;
|
||||
m_pwmGenerator = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,14 +189,14 @@ void DigitalOutput::UpdateDutyCycle(float dutyCycle) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
setDigitalPWMDutyCycle(m_pwmGenerator, dutyCycle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetDigitalPWMDutyCycle(m_pwmGenerator, dutyCycle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The HAL Handle to the specified source.
|
||||
*/
|
||||
HalHandle DigitalOutput::GetPortHandleForRouting() const { return m_handle; }
|
||||
HAL_Handle DigitalOutput::GetPortHandleForRouting() const { return m_handle; }
|
||||
|
||||
/**
|
||||
* Is source an AnalogTrigger
|
||||
|
||||
@@ -53,33 +53,33 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
m_forwardHandle = initializeSolenoidPort(
|
||||
getPortWithModule(moduleNumber, m_forwardChannel), &status);
|
||||
m_forwardHandle = HAL_InitializeSolenoidPort(
|
||||
HAL_GetPortWithModule(moduleNumber, m_forwardChannel), &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_forwardHandle = HAL_kInvalidHandle;
|
||||
m_reverseHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
m_reverseHandle = initializeSolenoidPort(
|
||||
getPortWithModule(moduleNumber, m_reverseChannel), &status);
|
||||
m_reverseHandle = HAL_InitializeSolenoidPort(
|
||||
HAL_GetPortWithModule(moduleNumber, m_reverseChannel), &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
// free forward solenoid
|
||||
freeSolenoidPort(m_forwardHandle);
|
||||
m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
HAL_FreeSolenoidPort(m_forwardHandle);
|
||||
m_forwardHandle = HAL_kInvalidHandle;
|
||||
m_reverseHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
m_forwardMask = 1 << m_forwardChannel;
|
||||
m_reverseMask = 1 << m_reverseChannel;
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Solenoid, m_forwardChannel,
|
||||
m_moduleNumber);
|
||||
HALReport(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel,
|
||||
m_moduleNumber);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_forwardChannel,
|
||||
m_moduleNumber);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel,
|
||||
m_moduleNumber);
|
||||
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", m_moduleNumber,
|
||||
m_forwardChannel, this);
|
||||
}
|
||||
@@ -88,8 +88,8 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
|
||||
* Destructor.
|
||||
*/
|
||||
DoubleSolenoid::~DoubleSolenoid() {
|
||||
freeSolenoidPort(m_forwardHandle);
|
||||
freeSolenoidPort(m_reverseHandle);
|
||||
HAL_FreeSolenoidPort(m_forwardHandle);
|
||||
HAL_FreeSolenoidPort(m_reverseHandle);
|
||||
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ void DoubleSolenoid::Set(Value value) {
|
||||
break;
|
||||
}
|
||||
int32_t fstatus = 0;
|
||||
setSolenoid(m_forwardHandle, forward, &fstatus);
|
||||
HAL_SetSolenoid(m_forwardHandle, forward, &fstatus);
|
||||
int32_t rstatus = 0;
|
||||
setSolenoid(m_reverseHandle, reverse, &rstatus);
|
||||
HAL_SetSolenoid(m_reverseHandle, reverse, &rstatus);
|
||||
|
||||
wpi_setErrorWithContext(fstatus, getHALErrorMessage(fstatus));
|
||||
wpi_setErrorWithContext(rstatus, getHALErrorMessage(rstatus));
|
||||
wpi_setErrorWithContext(fstatus, HAL_GetErrorMessage(fstatus));
|
||||
wpi_setErrorWithContext(rstatus, HAL_GetErrorMessage(rstatus));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,11 +135,11 @@ DoubleSolenoid::Value DoubleSolenoid::Get() const {
|
||||
if (StatusIsFatal()) return kOff;
|
||||
int32_t fstatus = 0;
|
||||
int32_t rstatus = 0;
|
||||
bool valueForward = getSolenoid(m_forwardHandle, &fstatus);
|
||||
bool valueReverse = getSolenoid(m_reverseHandle, &rstatus);
|
||||
bool valueForward = HAL_GetSolenoid(m_forwardHandle, &fstatus);
|
||||
bool valueReverse = HAL_GetSolenoid(m_reverseHandle, &rstatus);
|
||||
|
||||
wpi_setErrorWithContext(fstatus, getHALErrorMessage(fstatus));
|
||||
wpi_setErrorWithContext(rstatus, getHALErrorMessage(rstatus));
|
||||
wpi_setErrorWithContext(fstatus, HAL_GetErrorMessage(fstatus));
|
||||
wpi_setErrorWithContext(rstatus, HAL_GetErrorMessage(rstatus));
|
||||
|
||||
if (valueForward) return kForward;
|
||||
if (valueReverse) return kReverse;
|
||||
|
||||
@@ -25,17 +25,17 @@ const uint32_t DriverStation::kJoystickPorts;
|
||||
* This is only called once the first time GetInstance() is called
|
||||
*/
|
||||
DriverStation::DriverStation() {
|
||||
m_joystickAxes = std::make_unique<HALJoystickAxes[]>(kJoystickPorts);
|
||||
m_joystickPOVs = std::make_unique<HALJoystickPOVs[]>(kJoystickPorts);
|
||||
m_joystickButtons = std::make_unique<HALJoystickButtons[]>(kJoystickPorts);
|
||||
m_joystickAxes = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
|
||||
m_joystickPOVs = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
|
||||
m_joystickButtons = std::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
|
||||
m_joystickDescriptor =
|
||||
std::make_unique<HALJoystickDescriptor[]>(kJoystickPorts);
|
||||
m_joystickAxesCache = std::make_unique<HALJoystickAxes[]>(kJoystickPorts);
|
||||
m_joystickPOVsCache = std::make_unique<HALJoystickPOVs[]>(kJoystickPorts);
|
||||
std::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
|
||||
m_joystickAxesCache = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
|
||||
m_joystickPOVsCache = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
|
||||
m_joystickButtonsCache =
|
||||
std::make_unique<HALJoystickButtons[]>(kJoystickPorts);
|
||||
std::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
|
||||
m_joystickDescriptorCache =
|
||||
std::make_unique<HALJoystickDescriptor[]>(kJoystickPorts);
|
||||
std::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
|
||||
|
||||
// All joysticks should default to having zero axes, povs and buttons, so
|
||||
// uninitialized memory doesn't get sent to speed controllers.
|
||||
@@ -56,7 +56,7 @@ DriverStation::DriverStation() {
|
||||
}
|
||||
// Register that semaphore with the network communications task.
|
||||
// It will signal when new packet data is available.
|
||||
HALSetNewDataSem(&m_packetDataAvailableCond);
|
||||
HAL_SetNewDataSem(&m_packetDataAvailableCond);
|
||||
|
||||
m_task = Task("DriverStation", &DriverStation::Run, this);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ DriverStation::~DriverStation() {
|
||||
m_task.join();
|
||||
|
||||
// Unregister our semaphore.
|
||||
HALSetNewDataSem(nullptr);
|
||||
HAL_SetNewDataSem(nullptr);
|
||||
}
|
||||
|
||||
void DriverStation::Run() {
|
||||
@@ -88,11 +88,11 @@ void DriverStation::Run() {
|
||||
MotorSafetyHelper::CheckMotors();
|
||||
period = 0;
|
||||
}
|
||||
if (m_userInDisabled) HALNetworkCommunicationObserveUserProgramDisabled();
|
||||
if (m_userInDisabled) HAL_NetworkCommunicationObserveUserProgramDisabled();
|
||||
if (m_userInAutonomous)
|
||||
HALNetworkCommunicationObserveUserProgramAutonomous();
|
||||
if (m_userInTeleop) HALNetworkCommunicationObserveUserProgramTeleop();
|
||||
if (m_userInTest) HALNetworkCommunicationObserveUserProgramTest();
|
||||
HAL_NetworkCommunicationObserveUserProgramAutonomous();
|
||||
if (m_userInTeleop) HAL_NetworkCommunicationObserveUserProgramTeleop();
|
||||
if (m_userInTest) HAL_NetworkCommunicationObserveUserProgramTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,10 +115,10 @@ DriverStation& DriverStation::GetInstance() {
|
||||
void DriverStation::GetData() {
|
||||
// Get the status of all of the joysticks, and save to the cache
|
||||
for (uint8_t stick = 0; stick < kJoystickPorts; stick++) {
|
||||
HALGetJoystickAxes(stick, &m_joystickAxesCache[stick]);
|
||||
HALGetJoystickPOVs(stick, &m_joystickPOVsCache[stick]);
|
||||
HALGetJoystickButtons(stick, &m_joystickButtonsCache[stick]);
|
||||
HALGetJoystickDescriptor(stick, &m_joystickDescriptorCache[stick]);
|
||||
HAL_GetJoystickAxes(stick, &m_joystickAxesCache[stick]);
|
||||
HAL_GetJoystickPOVs(stick, &m_joystickPOVsCache[stick]);
|
||||
HAL_GetJoystickButtons(stick, &m_joystickButtonsCache[stick]);
|
||||
HAL_GetJoystickDescriptor(stick, &m_joystickDescriptorCache[stick]);
|
||||
}
|
||||
// Obtain a write lock on the data, swap the cached data into the
|
||||
// main data arrays
|
||||
@@ -138,7 +138,7 @@ void DriverStation::GetData() {
|
||||
*/
|
||||
float DriverStation::GetBatteryVoltage() const {
|
||||
int32_t status = 0;
|
||||
float voltage = getVinVoltage(&status);
|
||||
float voltage = HAL_GetVinVoltage(&status);
|
||||
wpi_setErrorWithContext(status, "getVinVoltage");
|
||||
|
||||
return voltage;
|
||||
@@ -293,7 +293,7 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) {
|
||||
// Unlock early so error printing isn't locked.
|
||||
m_joystickDataMutex.unlock();
|
||||
lock.release();
|
||||
if (axis >= kMaxJoystickAxes)
|
||||
if (axis >= HAL_kMaxJoystickAxes)
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
else
|
||||
ReportJoystickUnpluggedWarning(
|
||||
@@ -318,7 +318,7 @@ int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) {
|
||||
if (pov >= m_joystickPOVs[stick].count) {
|
||||
// Unlock early so error printing isn't locked.
|
||||
lock.unlock();
|
||||
if (pov >= kMaxJoystickPOVs)
|
||||
if (pov >= HAL_kMaxJoystickPOVs)
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
else
|
||||
ReportJoystickUnpluggedWarning(
|
||||
@@ -380,9 +380,9 @@ bool DriverStation::GetStickButton(uint32_t stick, uint8_t button) {
|
||||
* @return True if the robot is enabled and the DS is connected
|
||||
*/
|
||||
bool DriverStation::IsEnabled() const {
|
||||
HALControlWord controlWord;
|
||||
HAL_ControlWord controlWord;
|
||||
std::memset(&controlWord, 0, sizeof(controlWord));
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return controlWord.enabled && controlWord.dsAttached;
|
||||
}
|
||||
|
||||
@@ -392,9 +392,9 @@ bool DriverStation::IsEnabled() const {
|
||||
* @return True if the robot is explicitly disabled or the DS is not connected
|
||||
*/
|
||||
bool DriverStation::IsDisabled() const {
|
||||
HALControlWord controlWord;
|
||||
HAL_ControlWord controlWord;
|
||||
std::memset(&controlWord, 0, sizeof(controlWord));
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return !(controlWord.enabled && controlWord.dsAttached);
|
||||
}
|
||||
|
||||
@@ -404,9 +404,9 @@ bool DriverStation::IsDisabled() const {
|
||||
* @return True if the robot is being commanded to be in autonomous mode
|
||||
*/
|
||||
bool DriverStation::IsAutonomous() const {
|
||||
HALControlWord controlWord;
|
||||
HAL_ControlWord controlWord;
|
||||
std::memset(&controlWord, 0, sizeof(controlWord));
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return controlWord.autonomous;
|
||||
}
|
||||
|
||||
@@ -416,9 +416,9 @@ bool DriverStation::IsAutonomous() const {
|
||||
* @return True if the robot is being commanded to be in teleop mode
|
||||
*/
|
||||
bool DriverStation::IsOperatorControl() const {
|
||||
HALControlWord controlWord;
|
||||
HAL_ControlWord controlWord;
|
||||
std::memset(&controlWord, 0, sizeof(controlWord));
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return !(controlWord.autonomous || controlWord.test);
|
||||
}
|
||||
|
||||
@@ -428,8 +428,8 @@ bool DriverStation::IsOperatorControl() const {
|
||||
* @return True if the robot is being commanded to be in test mode
|
||||
*/
|
||||
bool DriverStation::IsTest() const {
|
||||
HALControlWord controlWord;
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_ControlWord controlWord;
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return controlWord.test;
|
||||
}
|
||||
|
||||
@@ -439,9 +439,9 @@ bool DriverStation::IsTest() const {
|
||||
* @return True if the DS is connected to the robot
|
||||
*/
|
||||
bool DriverStation::IsDSAttached() const {
|
||||
HALControlWord controlWord;
|
||||
HAL_ControlWord controlWord;
|
||||
std::memset(&controlWord, 0, sizeof(controlWord));
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return controlWord.dsAttached;
|
||||
}
|
||||
|
||||
@@ -455,8 +455,8 @@ bool DriverStation::IsDSAttached() const {
|
||||
*/
|
||||
bool DriverStation::IsSysActive() const {
|
||||
int32_t status = 0;
|
||||
bool retVal = HALGetSystemActive(&status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool retVal = HAL_GetSystemActive(&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -467,8 +467,8 @@ bool DriverStation::IsSysActive() const {
|
||||
*/
|
||||
bool DriverStation::IsBrownedOut() const {
|
||||
int32_t status = 0;
|
||||
bool retVal = HALGetBrownedOut(&status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool retVal = HAL_GetBrownedOut(&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -492,8 +492,8 @@ bool DriverStation::IsNewControlData() const {
|
||||
* Management System
|
||||
*/
|
||||
bool DriverStation::IsFMSAttached() const {
|
||||
HALControlWord controlWord;
|
||||
HALGetControlWord(&controlWord);
|
||||
HAL_ControlWord controlWord;
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return controlWord.fmsAttached;
|
||||
}
|
||||
|
||||
@@ -505,16 +505,16 @@ bool DriverStation::IsFMSAttached() const {
|
||||
* @return The Alliance enum (kRed, kBlue or kInvalid)
|
||||
*/
|
||||
DriverStation::Alliance DriverStation::GetAlliance() const {
|
||||
HALAllianceStationID allianceStationID;
|
||||
HALGetAllianceStation(&allianceStationID);
|
||||
HAL_AllianceStationID allianceStationID;
|
||||
HAL_GetAllianceStation(&allianceStationID);
|
||||
switch (allianceStationID) {
|
||||
case kHALAllianceStationID_red1:
|
||||
case kHALAllianceStationID_red2:
|
||||
case kHALAllianceStationID_red3:
|
||||
case HAL_AllianceStationID_kRed1:
|
||||
case HAL_AllianceStationID_kRed2:
|
||||
case HAL_AllianceStationID_kRed3:
|
||||
return kRed;
|
||||
case kHALAllianceStationID_blue1:
|
||||
case kHALAllianceStationID_blue2:
|
||||
case kHALAllianceStationID_blue3:
|
||||
case HAL_AllianceStationID_kBlue1:
|
||||
case HAL_AllianceStationID_kBlue2:
|
||||
case HAL_AllianceStationID_kBlue3:
|
||||
return kBlue;
|
||||
default:
|
||||
return kInvalid;
|
||||
@@ -529,17 +529,17 @@ DriverStation::Alliance DriverStation::GetAlliance() const {
|
||||
* @return The location of the driver station (1-3, 0 for invalid)
|
||||
*/
|
||||
uint32_t DriverStation::GetLocation() const {
|
||||
HALAllianceStationID allianceStationID;
|
||||
HALGetAllianceStation(&allianceStationID);
|
||||
HAL_AllianceStationID allianceStationID;
|
||||
HAL_GetAllianceStation(&allianceStationID);
|
||||
switch (allianceStationID) {
|
||||
case kHALAllianceStationID_red1:
|
||||
case kHALAllianceStationID_blue1:
|
||||
case HAL_AllianceStationID_kRed1:
|
||||
case HAL_AllianceStationID_kBlue1:
|
||||
return 1;
|
||||
case kHALAllianceStationID_red2:
|
||||
case kHALAllianceStationID_blue2:
|
||||
case HAL_AllianceStationID_kRed2:
|
||||
case HAL_AllianceStationID_kBlue2:
|
||||
return 2;
|
||||
case kHALAllianceStationID_red3:
|
||||
case kHALAllianceStationID_blue3:
|
||||
case HAL_AllianceStationID_kRed3:
|
||||
case HAL_AllianceStationID_kBlue3:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
@@ -579,7 +579,7 @@ void DriverStation::WaitForData() {
|
||||
*/
|
||||
double DriverStation::GetMatchTime() const {
|
||||
float matchTime;
|
||||
HALGetMatchTime(&matchTime);
|
||||
HAL_GetMatchTime(&matchTime);
|
||||
return (double)matchTime;
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ double DriverStation::GetMatchTime() const {
|
||||
* The error is also printed to the program console.
|
||||
*/
|
||||
void DriverStation::ReportError(std::string error) {
|
||||
HALSendError(1, 1, 0, error.c_str(), "", "", 1);
|
||||
HAL_SendError(1, 1, 0, error.c_str(), "", "", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,7 +598,7 @@ void DriverStation::ReportError(std::string error) {
|
||||
* The warning is also printed to the program console.
|
||||
*/
|
||||
void DriverStation::ReportWarning(std::string error) {
|
||||
HALSendError(0, 1, 0, error.c_str(), "", "", 1);
|
||||
HAL_SendError(0, 1, 0, error.c_str(), "", "", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,6 +610,6 @@ void DriverStation::ReportError(bool is_error, int32_t code,
|
||||
const std::string& error,
|
||||
const std::string& location,
|
||||
const std::string& stack) {
|
||||
HALSendError(is_error, code, 0, error.c_str(), location.c_str(),
|
||||
stack.c_str(), 1);
|
||||
HAL_SendError(is_error, code, 0, error.c_str(), location.c_str(),
|
||||
stack.c_str(), 1);
|
||||
}
|
||||
|
||||
@@ -31,16 +31,16 @@
|
||||
*/
|
||||
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
|
||||
int32_t status = 0;
|
||||
m_encoder = initializeEncoder(m_aSource->GetPortHandleForRouting(),
|
||||
m_aSource->GetAnalogTriggerTypeForRouting(),
|
||||
m_bSource->GetPortHandleForRouting(),
|
||||
m_bSource->GetAnalogTriggerTypeForRouting(),
|
||||
reverseDirection,
|
||||
(EncoderEncodingType)encodingType, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_encoder = HAL_InitializeEncoder(
|
||||
m_aSource->GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)m_aSource->GetAnalogTriggerTypeForRouting(),
|
||||
m_bSource->GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)m_bSource->GetAnalogTriggerTypeForRouting(),
|
||||
reverseDirection, (HAL_EncoderEncodingType)encodingType, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex(),
|
||||
encodingType);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex(),
|
||||
encodingType);
|
||||
LiveWindow::GetInstance()->AddSensor("Encoder", m_aSource->GetChannel(),
|
||||
this);
|
||||
}
|
||||
@@ -155,8 +155,8 @@ Encoder::Encoder(DigitalSource& aSource, DigitalSource& bSource,
|
||||
*/
|
||||
Encoder::~Encoder() {
|
||||
int32_t status = 0;
|
||||
freeEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_FreeEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,8 +166,8 @@ Encoder::~Encoder() {
|
||||
*/
|
||||
int32_t Encoder::GetEncodingScale() const {
|
||||
int32_t status = 0;
|
||||
int32_t val = getEncoderEncodingScale(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t val = HAL_GetEncoderEncodingScale(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -182,8 +182,8 @@ int32_t Encoder::GetEncodingScale() const {
|
||||
int32_t Encoder::GetRaw() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t value = getEncoderRaw(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t value = HAL_GetEncoderRaw(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -199,8 +199,8 @@ int32_t Encoder::GetRaw() const {
|
||||
int32_t Encoder::Get() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
int32_t value = getEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t value = HAL_GetEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ int32_t Encoder::Get() const {
|
||||
void Encoder::Reset() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
resetEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_ResetEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
;
|
||||
}
|
||||
|
||||
@@ -232,8 +232,8 @@ void Encoder::Reset() {
|
||||
double Encoder::GetPeriod() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
double value = getEncoderPeriod(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double value = HAL_GetEncoderPeriod(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -256,8 +256,8 @@ double Encoder::GetPeriod() const {
|
||||
void Encoder::SetMaxPeriod(double maxPeriod) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setEncoderMaxPeriod(m_encoder, maxPeriod, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetEncoderMaxPeriod(m_encoder, maxPeriod, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,8 +272,8 @@ void Encoder::SetMaxPeriod(double maxPeriod) {
|
||||
bool Encoder::GetStopped() const {
|
||||
if (StatusIsFatal()) return true;
|
||||
int32_t status = 0;
|
||||
bool value = getEncoderStopped(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_GetEncoderStopped(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -285,8 +285,8 @@ bool Encoder::GetStopped() const {
|
||||
bool Encoder::GetDirection() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool value = getEncoderDirection(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_GetEncoderDirection(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -297,8 +297,8 @@ bool Encoder::GetDirection() const {
|
||||
double Encoder::DecodingScaleFactor() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
double val = getEncoderDecodingScaleFactor(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double val = HAL_GetEncoderDecodingScaleFactor(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -311,8 +311,8 @@ double Encoder::DecodingScaleFactor() const {
|
||||
double Encoder::GetDistance() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
double value = getEncoderDistance(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double value = HAL_GetEncoderDistance(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -327,8 +327,8 @@ double Encoder::GetDistance() const {
|
||||
double Encoder::GetRate() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
double value = getEncoderRate(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double value = HAL_GetEncoderRate(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -341,8 +341,8 @@ double Encoder::GetRate() const {
|
||||
void Encoder::SetMinRate(double minRate) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setEncoderMinRate(m_encoder, minRate, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetEncoderMinRate(m_encoder, minRate, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,8 +365,8 @@ void Encoder::SetMinRate(double minRate) {
|
||||
void Encoder::SetDistancePerPulse(double distancePerPulse) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setEncoderDistancePerPulse(m_encoder, distancePerPulse, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetEncoderDistancePerPulse(m_encoder, distancePerPulse, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,8 +380,8 @@ void Encoder::SetDistancePerPulse(double distancePerPulse) {
|
||||
void Encoder::SetReverseDirection(bool reverseDirection) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setEncoderReverseDirection(m_encoder, reverseDirection, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetEncoderReverseDirection(m_encoder, reverseDirection, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,8 +401,8 @@ void Encoder::SetSamplesToAverage(int samplesToAverage) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
setEncoderSamplesToAverage(m_encoder, samplesToAverage, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetEncoderSamplesToAverage(m_encoder, samplesToAverage, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,8 +416,8 @@ void Encoder::SetSamplesToAverage(int samplesToAverage) {
|
||||
*/
|
||||
int Encoder::GetSamplesToAverage() const {
|
||||
int32_t status = 0;
|
||||
int result = getEncoderSamplesToAverage(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int result = HAL_GetEncoderSamplesToAverage(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -477,16 +477,17 @@ void Encoder::SetIndexSource(DigitalSource* source,
|
||||
void Encoder::SetIndexSource(const DigitalSource& source,
|
||||
Encoder::IndexingType type) {
|
||||
int32_t status = 0;
|
||||
setEncoderIndexSource(m_encoder, source.GetPortHandleForRouting(),
|
||||
source.GetAnalogTriggerTypeForRouting(),
|
||||
(EncoderIndexingType)type, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetEncoderIndexSource(
|
||||
m_encoder, source.GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)source.GetAnalogTriggerTypeForRouting(),
|
||||
(HAL_EncoderIndexingType)type, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
int32_t Encoder::GetFPGAIndex() const {
|
||||
int32_t status = 0;
|
||||
int32_t val = getEncoderFPGAIndex(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t val = HAL_GetEncoderFPGAIndex(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -495,8 +496,9 @@ void Encoder::UpdateTable() {
|
||||
m_table->PutNumber("Speed", GetRate());
|
||||
m_table->PutNumber("Distance", GetDistance());
|
||||
int32_t status = 0;
|
||||
double distancePerPulse = getEncoderDistancePerPulse(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double distancePerPulse =
|
||||
HAL_GetEncoderDistancePerPulse(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_table->PutNumber("Distance per Tick", distancePerPulse);
|
||||
}
|
||||
}
|
||||
@@ -507,9 +509,9 @@ void Encoder::StopLiveWindowMode() {}
|
||||
|
||||
std::string Encoder::GetSmartDashboardType() const {
|
||||
int32_t status = 0;
|
||||
EncoderEncodingType type = getEncoderEncodingType(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
if (type == EncoderEncodingType::HAL_Encoder_k4X)
|
||||
HAL_EncoderEncodingType type = HAL_GetEncoderEncodingType(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
if (type == HAL_EncoderEncodingType::HAL_Encoder_k4X)
|
||||
return "Quadrature Encoder";
|
||||
else
|
||||
return "Encoder";
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
I2C::I2C(Port port, uint8_t deviceAddress)
|
||||
: m_port(port), m_deviceAddress(deviceAddress) {
|
||||
int32_t status = 0;
|
||||
i2CInitialize(m_port, &status);
|
||||
// wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_I2CInitialize(m_port, &status);
|
||||
// wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_I2C, deviceAddress);
|
||||
HAL_Report(HALUsageReporting::kResourceType_I2C, deviceAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
I2C::~I2C() { i2CClose(m_port); }
|
||||
I2C::~I2C() { HAL_I2CClose(m_port); }
|
||||
|
||||
/**
|
||||
* Generic transaction.
|
||||
@@ -44,9 +44,9 @@ I2C::~I2C() { i2CClose(m_port); }
|
||||
bool I2C::Transaction(uint8_t* dataToSend, uint8_t sendSize,
|
||||
uint8_t* dataReceived, uint8_t receiveSize) {
|
||||
int32_t status = 0;
|
||||
status = i2CTransaction(m_port, m_deviceAddress, dataToSend, sendSize,
|
||||
dataReceived, receiveSize);
|
||||
// wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
status = HAL_I2CTransaction(m_port, m_deviceAddress, dataToSend, sendSize,
|
||||
dataReceived, receiveSize);
|
||||
// wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return status < receiveSize;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) {
|
||||
buffer[0] = registerAddress;
|
||||
buffer[1] = data;
|
||||
int32_t status = 0;
|
||||
status = i2CWrite(m_port, m_deviceAddress, buffer, sizeof(buffer));
|
||||
status = HAL_I2CWrite(m_port, m_deviceAddress, buffer, sizeof(buffer));
|
||||
return status < static_cast<int32_t>(sizeof(buffer));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) {
|
||||
*/
|
||||
bool I2C::WriteBulk(uint8_t* data, uint8_t count) {
|
||||
int32_t status = 0;
|
||||
status = i2CWrite(m_port, m_deviceAddress, data, count);
|
||||
status = HAL_I2CWrite(m_port, m_deviceAddress, data, count);
|
||||
return status < count;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ bool I2C::ReadOnly(uint8_t count, uint8_t* buffer) {
|
||||
return true;
|
||||
}
|
||||
int32_t status = 0;
|
||||
status = i2CRead(m_port, m_deviceAddress, buffer, count);
|
||||
status = HAL_I2CRead(m_port, m_deviceAddress, buffer, count);
|
||||
return status < count;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "HAL/HAL.h"
|
||||
|
||||
void HardwareHLReporting::ReportScheduler() {
|
||||
HALReport(HALUsageReporting::kResourceType_Command,
|
||||
HALUsageReporting::kCommand_Scheduler);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Command,
|
||||
HALUsageReporting::kCommand_Scheduler);
|
||||
}
|
||||
|
||||
void HardwareHLReporting::ReportSmartDashboard() {
|
||||
HALReport(HALUsageReporting::kResourceType_SmartDashboard, 0);
|
||||
HAL_Report(HALUsageReporting::kResourceType_SmartDashboard, 0);
|
||||
}
|
||||
|
||||
@@ -25,16 +25,17 @@ void InterruptableSensorBase::RequestInterrupts(
|
||||
InterruptHandlerFunction handler, void* param) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
wpi_assert(m_interrupt == HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt == HAL_kInvalidHandle);
|
||||
AllocateInterrupts(false);
|
||||
if (StatusIsFatal()) return; // if allocate failed, out of interrupts
|
||||
|
||||
int32_t status = 0;
|
||||
requestInterrupts(m_interrupt, GetPortHandleForRouting(),
|
||||
GetAnalogTriggerTypeForRouting(), &status);
|
||||
HAL_RequestInterrupts(m_interrupt, GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)GetAnalogTriggerTypeForRouting(),
|
||||
&status);
|
||||
SetUpSourceEdge(true, false);
|
||||
attachInterruptHandler(m_interrupt, handler, param, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_AttachInterruptHandler(m_interrupt, handler, param, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,23 +48,24 @@ void InterruptableSensorBase::RequestInterrupts(
|
||||
void InterruptableSensorBase::RequestInterrupts() {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
wpi_assert(m_interrupt == HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt == HAL_kInvalidHandle);
|
||||
AllocateInterrupts(true);
|
||||
if (StatusIsFatal()) return; // if allocate failed, out of interrupts
|
||||
|
||||
int32_t status = 0;
|
||||
requestInterrupts(m_interrupt, GetPortHandleForRouting(),
|
||||
GetAnalogTriggerTypeForRouting(), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_RequestInterrupts(m_interrupt, GetPortHandleForRouting(),
|
||||
(HAL_AnalogTriggerType)GetAnalogTriggerTypeForRouting(),
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
SetUpSourceEdge(true, false);
|
||||
}
|
||||
|
||||
void InterruptableSensorBase::AllocateInterrupts(bool watcher) {
|
||||
wpi_assert(m_interrupt == HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt == HAL_kInvalidHandle);
|
||||
// Expects the calling leaf class to allocate an interrupt index.
|
||||
int32_t status = 0;
|
||||
m_interrupt = initializeInterrupts(watcher, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_interrupt = HAL_InitializeInterrupts(watcher, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,11 +75,11 @@ void InterruptableSensorBase::AllocateInterrupts(bool watcher) {
|
||||
*/
|
||||
void InterruptableSensorBase::CancelInterrupts() {
|
||||
if (StatusIsFatal()) return;
|
||||
wpi_assert(m_interrupt != HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
cleanInterrupts(m_interrupt, &status);
|
||||
HAL_CleanInterrupts(m_interrupt, &status);
|
||||
// ignore status, as an invalid handle just needs to be ignored.
|
||||
m_interrupt = HAL_INVALID_HANDLE;
|
||||
m_interrupt = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,12 +97,12 @@ void InterruptableSensorBase::CancelInterrupts() {
|
||||
InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
|
||||
float timeout, bool ignorePrevious) {
|
||||
if (StatusIsFatal()) return InterruptableSensorBase::kTimeout;
|
||||
wpi_assert(m_interrupt != HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
uint32_t result;
|
||||
|
||||
result = waitForInterrupt(m_interrupt, timeout, ignorePrevious, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
result = HAL_WaitForInterrupt(m_interrupt, timeout, ignorePrevious, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return static_cast<WaitResult>(result);
|
||||
}
|
||||
@@ -114,10 +116,10 @@ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
|
||||
*/
|
||||
void InterruptableSensorBase::EnableInterrupts() {
|
||||
if (StatusIsFatal()) return;
|
||||
wpi_assert(m_interrupt != HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
enableInterrupts(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_EnableInterrupts(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,10 +127,10 @@ void InterruptableSensorBase::EnableInterrupts() {
|
||||
*/
|
||||
void InterruptableSensorBase::DisableInterrupts() {
|
||||
if (StatusIsFatal()) return;
|
||||
wpi_assert(m_interrupt != HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
disableInterrupts(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_DisableInterrupts(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,10 +144,10 @@ void InterruptableSensorBase::DisableInterrupts() {
|
||||
*/
|
||||
double InterruptableSensorBase::ReadRisingTimestamp() {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
wpi_assert(m_interrupt != HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
double timestamp = readRisingTimestamp(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double timestamp = HAL_ReadRisingTimestamp(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -160,10 +162,10 @@ double InterruptableSensorBase::ReadRisingTimestamp() {
|
||||
*/
|
||||
double InterruptableSensorBase::ReadFallingTimestamp() {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
wpi_assert(m_interrupt != HAL_INVALID_HANDLE);
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
double timestamp = readFallingTimestamp(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double timestamp = HAL_ReadFallingTimestamp(m_interrupt, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -176,15 +178,15 @@ double InterruptableSensorBase::ReadFallingTimestamp() {
|
||||
void InterruptableSensorBase::SetUpSourceEdge(bool risingEdge,
|
||||
bool fallingEdge) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_interrupt == HAL_INVALID_HANDLE) {
|
||||
if (m_interrupt == HAL_kInvalidHandle) {
|
||||
wpi_setWPIErrorWithContext(
|
||||
NullParameter,
|
||||
"You must call RequestInterrupts before SetUpSourceEdge");
|
||||
return;
|
||||
}
|
||||
if (m_interrupt != HAL_INVALID_HANDLE) {
|
||||
if (m_interrupt != HAL_kInvalidHandle) {
|
||||
int32_t status = 0;
|
||||
setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ constexpr double IterativeRobot::kDefaultPeriod;
|
||||
* the DS packets
|
||||
*/
|
||||
void IterativeRobot::StartCompetition() {
|
||||
HALReport(HALUsageReporting::kResourceType_Framework,
|
||||
HALUsageReporting::kFramework_Iterative);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Framework,
|
||||
HALUsageReporting::kFramework_Iterative);
|
||||
|
||||
LiveWindow* lw = LiveWindow::GetInstance();
|
||||
// first and one-time initialization
|
||||
@@ -34,7 +34,7 @@ void IterativeRobot::StartCompetition() {
|
||||
RobotInit();
|
||||
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
HALNetworkCommunicationObserveUserProgramStarting();
|
||||
HAL_NetworkCommunicationObserveUserProgramStarting();
|
||||
|
||||
// loop forever, calling the appropriate mode-dependent function
|
||||
lw->SetEnabled(false);
|
||||
@@ -52,7 +52,7 @@ void IterativeRobot::StartCompetition() {
|
||||
m_teleopInitialized = false;
|
||||
m_testInitialized = false;
|
||||
}
|
||||
HALNetworkCommunicationObserveUserProgramDisabled();
|
||||
HAL_NetworkCommunicationObserveUserProgramDisabled();
|
||||
DisabledPeriodic();
|
||||
} else if (IsAutonomous()) {
|
||||
// call AutonomousInit() if we are now just entering autonomous mode from
|
||||
@@ -66,7 +66,7 @@ void IterativeRobot::StartCompetition() {
|
||||
m_teleopInitialized = false;
|
||||
m_testInitialized = false;
|
||||
}
|
||||
HALNetworkCommunicationObserveUserProgramAutonomous();
|
||||
HAL_NetworkCommunicationObserveUserProgramAutonomous();
|
||||
AutonomousPeriodic();
|
||||
} else if (IsTest()) {
|
||||
// call TestInit() if we are now just entering test mode from
|
||||
@@ -80,7 +80,7 @@ void IterativeRobot::StartCompetition() {
|
||||
m_autonomousInitialized = false;
|
||||
m_teleopInitialized = false;
|
||||
}
|
||||
HALNetworkCommunicationObserveUserProgramTest();
|
||||
HAL_NetworkCommunicationObserveUserProgramTest();
|
||||
TestPeriodic();
|
||||
} else {
|
||||
// call TeleopInit() if we are now just entering teleop mode from
|
||||
@@ -95,7 +95,7 @@ void IterativeRobot::StartCompetition() {
|
||||
m_testInitialized = false;
|
||||
Scheduler::GetInstance()->SetEnabled(true);
|
||||
}
|
||||
HALNetworkCommunicationObserveUserProgramTeleop();
|
||||
HAL_NetworkCommunicationObserveUserProgramTeleop();
|
||||
TeleopPeriodic();
|
||||
}
|
||||
// wait for driver station data so the loop doesn't hog the CPU
|
||||
|
||||
@@ -30,6 +30,6 @@ Jaguar::Jaguar(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Jaguar, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_Jaguar, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ Joystick::Joystick(uint32_t port)
|
||||
m_buttons[kTriggerButton] = kDefaultTriggerButton;
|
||||
m_buttons[kTopButton] = kDefaultTopButton;
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Joystick, port);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Joystick, port);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +371,7 @@ void Joystick::SetRumble(RumbleType type, float value) {
|
||||
m_leftRumble = value * 65535;
|
||||
else
|
||||
m_rightRumble = value * 65535;
|
||||
HALSetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
|
||||
HAL_SetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,7 +385,7 @@ void Joystick::SetOutput(uint8_t outputNumber, bool value) {
|
||||
m_outputs =
|
||||
(m_outputs & ~(1 << (outputNumber - 1))) | (value << (outputNumber - 1));
|
||||
|
||||
HALSetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
|
||||
HAL_SetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,5 +395,5 @@ void Joystick::SetOutput(uint8_t outputNumber, bool value) {
|
||||
*/
|
||||
void Joystick::SetOutputs(uint32_t value) {
|
||||
m_outputs = value;
|
||||
HALSetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
|
||||
HAL_SetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ Notifier::Notifier(TimerEventHandler handler) {
|
||||
wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr");
|
||||
m_handler = handler;
|
||||
int32_t status = 0;
|
||||
m_notifier = initializeNotifier(&Notifier::Notify, this, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_notifier = HAL_InitializeNotifier(&Notifier::Notify, this, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,9 +32,9 @@ Notifier::Notifier(TimerEventHandler handler) {
|
||||
Notifier::~Notifier() {
|
||||
int32_t status = 0;
|
||||
// atomically set handle to 0, then clean
|
||||
HalNotifierHandle handle = m_notifier.exchange(0);
|
||||
cleanNotifier(handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_NotifierHandle handle = m_notifier.exchange(0);
|
||||
HAL_CleanNotifier(handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
/* Acquire the mutex; this makes certain that the handler is not being
|
||||
* executed by the interrupt manager.
|
||||
@@ -47,8 +47,9 @@ Notifier::~Notifier() {
|
||||
*/
|
||||
void Notifier::UpdateAlarm() {
|
||||
int32_t status = 0;
|
||||
updateNotifierAlarm(m_notifier, (uint64_t)(m_expirationTime * 1e6), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_UpdateNotifierAlarm(m_notifier, (uint64_t)(m_expirationTime * 1e6),
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +118,8 @@ void Notifier::StartPeriodic(double period) {
|
||||
*/
|
||||
void Notifier::Stop() {
|
||||
int32_t status = 0;
|
||||
stopNotifierAlarm(m_notifier, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_StopNotifierAlarm(m_notifier, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
// Wait for a currently executing handler to complete before returning from
|
||||
// Stop()
|
||||
|
||||
@@ -74,7 +74,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
|
||||
|
||||
static int32_t instances = 0;
|
||||
instances++;
|
||||
HALReport(HALUsageReporting::kResourceType_PIDController, instances);
|
||||
HAL_Report(HALUsageReporting::kResourceType_PIDController, instances);
|
||||
}
|
||||
|
||||
PIDController::~PIDController() {
|
||||
|
||||
@@ -33,23 +33,23 @@ PWM::PWM(uint32_t channel) {
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
m_handle = initializePWMPort(getPort(channel), &status);
|
||||
m_handle = HAL_InitializePWMPort(HAL_GetPort(channel), &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_channel = std::numeric_limits<uint32_t>::max();
|
||||
m_handle = HAL_INVALID_HANDLE;
|
||||
m_handle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
m_channel = channel;
|
||||
|
||||
setPWMDisabled(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMDisabled(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
status = 0;
|
||||
setPWMEliminateDeadband(m_handle, false, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMEliminateDeadband(m_handle, false, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_PWM, channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_PWM, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,11 +60,11 @@ PWM::PWM(uint32_t channel) {
|
||||
PWM::~PWM() {
|
||||
int32_t status = 0;
|
||||
|
||||
setPWMDisabled(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMDisabled(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
freePWMPort(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_FreePWMPort(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
||||
}
|
||||
@@ -80,8 +80,8 @@ PWM::~PWM() {
|
||||
void PWM::EnableDeadbandElimination(bool eliminateDeadband) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setPWMEliminateDeadband(m_handle, eliminateDeadband, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMEliminateDeadband(m_handle, eliminateDeadband, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,8 +101,9 @@ void PWM::SetBounds(double max, double deadbandMax, double center,
|
||||
double deadbandMin, double min) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setPWMConfig(m_handle, max, deadbandMax, center, deadbandMin, min, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMConfig(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,9 +123,9 @@ void PWM::SetRawBounds(int32_t max, int32_t deadbandMax, int32_t center,
|
||||
int32_t deadbandMin, int32_t min) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,9 +144,9 @@ void PWM::SetRawBounds(int32_t max, int32_t deadbandMax, int32_t center,
|
||||
void PWM::GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
|
||||
int32_t* deadbandMin, int32_t* min) {
|
||||
int32_t status = 0;
|
||||
getPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_GetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,8 +162,8 @@ void PWM::GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
|
||||
void PWM::SetPosition(float pos) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setPWMPosition(m_handle, pos, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMPosition(m_handle, pos, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,8 +179,8 @@ void PWM::SetPosition(float pos) {
|
||||
float PWM::GetPosition() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float position = getPWMPosition(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
float position = HAL_GetPWMPosition(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -199,8 +200,8 @@ float PWM::GetPosition() const {
|
||||
void PWM::SetSpeed(float speed) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setPWMSpeed(m_handle, speed, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMSpeed(m_handle, speed, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,8 +219,8 @@ void PWM::SetSpeed(float speed) {
|
||||
float PWM::GetSpeed() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float speed = getPWMSpeed(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
float speed = HAL_GetPWMSpeed(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return speed;
|
||||
}
|
||||
|
||||
@@ -234,8 +235,8 @@ void PWM::SetRaw(unsigned short value) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
setPWMRaw(m_handle, value, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMRaw(m_handle, value, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,8 +250,8 @@ unsigned short PWM::GetRaw() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
|
||||
int32_t status = 0;
|
||||
unsigned short value = getPWMRaw(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
unsigned short value = HAL_GetPWMRaw(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -267,19 +268,21 @@ void PWM::SetPeriodMultiplier(PeriodMultiplier mult) {
|
||||
|
||||
switch (mult) {
|
||||
case kPeriodMultiplier_4X:
|
||||
setPWMPeriodScale(m_handle, 3, &status); // Squelch 3 out of 4 outputs
|
||||
HAL_SetPWMPeriodScale(m_handle, 3,
|
||||
&status); // Squelch 3 out of 4 outputs
|
||||
break;
|
||||
case kPeriodMultiplier_2X:
|
||||
setPWMPeriodScale(m_handle, 1, &status); // Squelch 1 out of 2 outputs
|
||||
HAL_SetPWMPeriodScale(m_handle, 1,
|
||||
&status); // Squelch 1 out of 2 outputs
|
||||
break;
|
||||
case kPeriodMultiplier_1X:
|
||||
setPWMPeriodScale(m_handle, 0, &status); // Don't squelch any outputs
|
||||
HAL_SetPWMPeriodScale(m_handle, 0, &status); // Don't squelch any outputs
|
||||
break;
|
||||
default:
|
||||
wpi_assert(false);
|
||||
}
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,8 +294,8 @@ void PWM::SetDisabled() {
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
setPWMDisabled(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetPWMDisabled(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void PWM::SetZeroLatch() {
|
||||
@@ -300,8 +303,8 @@ void PWM::SetZeroLatch() {
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
latchPWMZero(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_LatchPWMZero(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void PWM::ValueChanged(ITable* source, llvm::StringRef key,
|
||||
|
||||
@@ -19,7 +19,7 @@ PowerDistributionPanel::PowerDistributionPanel() : PowerDistributionPanel(0) {}
|
||||
*/
|
||||
PowerDistributionPanel::PowerDistributionPanel(uint8_t module)
|
||||
: m_module(module) {
|
||||
initializePDP(m_module);
|
||||
HAL_InitializePDP(m_module);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ PowerDistributionPanel::PowerDistributionPanel(uint8_t module)
|
||||
double PowerDistributionPanel::GetVoltage() const {
|
||||
int32_t status = 0;
|
||||
|
||||
double voltage = getPDPVoltage(m_module, &status);
|
||||
double voltage = HAL_GetPDPVoltage(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -47,7 +47,7 @@ double PowerDistributionPanel::GetVoltage() const {
|
||||
double PowerDistributionPanel::GetTemperature() const {
|
||||
int32_t status = 0;
|
||||
|
||||
double temperature = getPDPTemperature(m_module, &status);
|
||||
double temperature = HAL_GetPDPTemperature(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -70,7 +70,7 @@ double PowerDistributionPanel::GetCurrent(uint8_t channel) const {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
|
||||
}
|
||||
|
||||
double current = getPDPChannelCurrent(m_module, channel, &status);
|
||||
double current = HAL_GetPDPChannelCurrent(m_module, channel, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -87,7 +87,7 @@ double PowerDistributionPanel::GetCurrent(uint8_t channel) const {
|
||||
double PowerDistributionPanel::GetTotalCurrent() const {
|
||||
int32_t status = 0;
|
||||
|
||||
double current = getPDPTotalCurrent(m_module, &status);
|
||||
double current = HAL_GetPDPTotalCurrent(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -104,7 +104,7 @@ double PowerDistributionPanel::GetTotalCurrent() const {
|
||||
double PowerDistributionPanel::GetTotalPower() const {
|
||||
int32_t status = 0;
|
||||
|
||||
double power = getPDPTotalPower(m_module, &status);
|
||||
double power = HAL_GetPDPTotalPower(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -121,7 +121,7 @@ double PowerDistributionPanel::GetTotalPower() const {
|
||||
double PowerDistributionPanel::GetTotalEnergy() const {
|
||||
int32_t status = 0;
|
||||
|
||||
double energy = getPDPTotalEnergy(m_module, &status);
|
||||
double energy = HAL_GetPDPTotalEnergy(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -138,7 +138,7 @@ double PowerDistributionPanel::GetTotalEnergy() const {
|
||||
void PowerDistributionPanel::ResetTotalEnergy() {
|
||||
int32_t status = 0;
|
||||
|
||||
resetPDPTotalEnergy(m_module, &status);
|
||||
HAL_ResetPDPTotalEnergy(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -151,7 +151,7 @@ void PowerDistributionPanel::ResetTotalEnergy() {
|
||||
void PowerDistributionPanel::ClearStickyFaults() {
|
||||
int32_t status = 0;
|
||||
|
||||
clearPDPStickyFaults(m_module, &status);
|
||||
HAL_ClearPDPStickyFaults(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
|
||||
@@ -26,7 +26,7 @@ void Preferences::Listener::ValueChangedEx(ITable* source, llvm::StringRef key,
|
||||
|
||||
Preferences::Preferences() : m_table(NetworkTable::GetTable(kTableName)) {
|
||||
m_table->AddTableListenerEx(&m_listener, NT_NOTIFY_NEW | NT_NOTIFY_IMMEDIATE);
|
||||
HALReport(HALUsageReporting::kResourceType_Preferences, 0);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Preferences, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,48 +32,48 @@ Relay::Relay(uint32_t channel, Relay::Direction direction)
|
||||
return;
|
||||
}
|
||||
|
||||
HalPortHandle portHandle = getPort(channel);
|
||||
HAL_PortHandle portHandle = HAL_GetPort(channel);
|
||||
|
||||
if (m_direction == kBothDirections || m_direction == kForwardOnly) {
|
||||
int32_t status = 0;
|
||||
m_forwardHandle = initializeRelayPort(portHandle, true, &status);
|
||||
m_forwardHandle = HAL_InitializeRelayPort(portHandle, true, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_forwardHandle = HAL_kInvalidHandle;
|
||||
m_reverseHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
HALReport(HALUsageReporting::kResourceType_Relay, m_channel);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Relay, m_channel);
|
||||
}
|
||||
if (m_direction == kBothDirections || m_direction == kReverseOnly) {
|
||||
int32_t status = 0;
|
||||
m_reverseHandle = initializeRelayPort(portHandle, false, &status);
|
||||
m_reverseHandle = HAL_InitializeRelayPort(portHandle, false, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_forwardHandle = HAL_kInvalidHandle;
|
||||
m_reverseHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Relay, m_channel + 128);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Relay, m_channel + 128);
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
if (m_forwardHandle != HAL_INVALID_HANDLE) {
|
||||
setRelay(m_forwardHandle, false, &status);
|
||||
if (m_forwardHandle != HAL_kInvalidHandle) {
|
||||
HAL_SetRelay(m_forwardHandle, false, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_forwardHandle = HAL_kInvalidHandle;
|
||||
m_reverseHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (m_reverseHandle != HAL_INVALID_HANDLE) {
|
||||
setRelay(m_reverseHandle, false, &status);
|
||||
if (m_reverseHandle != HAL_kInvalidHandle) {
|
||||
HAL_SetRelay(m_reverseHandle, false, &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_forwardHandle = HAL_kInvalidHandle;
|
||||
m_reverseHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -91,11 +91,11 @@ Relay::Relay(uint32_t channel, Relay::Direction direction)
|
||||
*/
|
||||
Relay::~Relay() {
|
||||
int32_t status = 0;
|
||||
setRelay(m_forwardHandle, false, &status);
|
||||
setRelay(m_reverseHandle, false, &status);
|
||||
HAL_SetRelay(m_forwardHandle, false, &status);
|
||||
HAL_SetRelay(m_reverseHandle, false, &status);
|
||||
// ignore errors, as we want to make sure a free happens.
|
||||
if (m_forwardHandle != HAL_INVALID_HANDLE) freeRelayPort(m_forwardHandle);
|
||||
if (m_reverseHandle != HAL_INVALID_HANDLE) freeRelayPort(m_reverseHandle);
|
||||
if (m_forwardHandle != HAL_kInvalidHandle) HAL_FreeRelayPort(m_forwardHandle);
|
||||
if (m_reverseHandle != HAL_kInvalidHandle) HAL_FreeRelayPort(m_reverseHandle);
|
||||
|
||||
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
||||
}
|
||||
@@ -123,18 +123,18 @@ void Relay::Set(Relay::Value value) {
|
||||
switch (value) {
|
||||
case kOff:
|
||||
if (m_direction == kBothDirections || m_direction == kForwardOnly) {
|
||||
setRelay(m_forwardHandle, false, &status);
|
||||
HAL_SetRelay(m_forwardHandle, false, &status);
|
||||
}
|
||||
if (m_direction == kBothDirections || m_direction == kReverseOnly) {
|
||||
setRelay(m_reverseHandle, false, &status);
|
||||
HAL_SetRelay(m_reverseHandle, false, &status);
|
||||
}
|
||||
break;
|
||||
case kOn:
|
||||
if (m_direction == kBothDirections || m_direction == kForwardOnly) {
|
||||
setRelay(m_forwardHandle, true, &status);
|
||||
HAL_SetRelay(m_forwardHandle, true, &status);
|
||||
}
|
||||
if (m_direction == kBothDirections || m_direction == kReverseOnly) {
|
||||
setRelay(m_reverseHandle, true, &status);
|
||||
HAL_SetRelay(m_reverseHandle, true, &status);
|
||||
}
|
||||
break;
|
||||
case kForward:
|
||||
@@ -143,10 +143,10 @@ void Relay::Set(Relay::Value value) {
|
||||
break;
|
||||
}
|
||||
if (m_direction == kBothDirections || m_direction == kForwardOnly) {
|
||||
setRelay(m_forwardHandle, true, &status);
|
||||
HAL_SetRelay(m_forwardHandle, true, &status);
|
||||
}
|
||||
if (m_direction == kBothDirections) {
|
||||
setRelay(m_reverseHandle, false, &status);
|
||||
HAL_SetRelay(m_reverseHandle, false, &status);
|
||||
}
|
||||
break;
|
||||
case kReverse:
|
||||
@@ -155,15 +155,15 @@ void Relay::Set(Relay::Value value) {
|
||||
break;
|
||||
}
|
||||
if (m_direction == kBothDirections) {
|
||||
setRelay(m_forwardHandle, false, &status);
|
||||
HAL_SetRelay(m_forwardHandle, false, &status);
|
||||
}
|
||||
if (m_direction == kBothDirections || m_direction == kReverseOnly) {
|
||||
setRelay(m_reverseHandle, true, &status);
|
||||
HAL_SetRelay(m_reverseHandle, true, &status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,8 +179,8 @@ void Relay::Set(Relay::Value value) {
|
||||
Relay::Value Relay::Get() const {
|
||||
int32_t status;
|
||||
|
||||
if (getRelay(m_forwardHandle, &status)) {
|
||||
if (getRelay(m_reverseHandle, &status)) {
|
||||
if (HAL_GetRelay(m_forwardHandle, &status)) {
|
||||
if (HAL_GetRelay(m_reverseHandle, &status)) {
|
||||
return kOn;
|
||||
} else {
|
||||
if (m_direction == kForwardOnly) {
|
||||
@@ -190,7 +190,7 @@ Relay::Value Relay::Get() const {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getRelay(m_reverseHandle, &status)) {
|
||||
if (HAL_GetRelay(m_reverseHandle, &status)) {
|
||||
if (m_direction == kReverseOnly) {
|
||||
return kOn;
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@ Relay::Value Relay::Get() const {
|
||||
}
|
||||
}
|
||||
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
uint32_t Relay::GetChannel() const { return m_channel; }
|
||||
|
||||
@@ -217,8 +217,8 @@ void RobotDrive::Drive(float outputMagnitude, float curve) {
|
||||
float leftOutput, rightOutput;
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_ArcadeRatioCurve);
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_ArcadeRatioCurve);
|
||||
reported = true;
|
||||
}
|
||||
|
||||
@@ -306,8 +306,8 @@ void RobotDrive::TankDrive(float leftValue, float rightValue,
|
||||
bool squaredInputs) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_Tank);
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_Tank);
|
||||
reported = true;
|
||||
}
|
||||
|
||||
@@ -430,8 +430,8 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
bool squaredInputs) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_ArcadeStandard);
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_ArcadeStandard);
|
||||
reported = true;
|
||||
}
|
||||
|
||||
@@ -502,8 +502,8 @@ void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
float gyroAngle) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_MecanumCartesian);
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_MecanumCartesian);
|
||||
reported = true;
|
||||
}
|
||||
|
||||
@@ -551,8 +551,8 @@ void RobotDrive::MecanumDrive_Polar(float magnitude, float direction,
|
||||
float rotation) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_MecanumPolar);
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
HALUsageReporting::kRobotDrive_MecanumPolar);
|
||||
reported = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,6 @@ SD540::SD540(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_MindsensorsSD540, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_MindsensorsSD540, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("SD540", GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
SPI::SPI(Port SPIport) {
|
||||
m_port = SPIport;
|
||||
int32_t status = 0;
|
||||
spiInitialize(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiInitialize(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
static int32_t instances = 0;
|
||||
instances++;
|
||||
HALReport(HALUsageReporting::kResourceType_SPI, instances);
|
||||
HAL_Report(HALUsageReporting::kResourceType_SPI, instances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
SPI::~SPI() { spiClose(m_port); }
|
||||
SPI::~SPI() { HAL_SpiClose(m_port); }
|
||||
|
||||
/**
|
||||
* Configure the rate of the generated clock signal.
|
||||
@@ -41,7 +41,7 @@ SPI::~SPI() { spiClose(m_port); }
|
||||
*
|
||||
* @param hz The clock rate in Hertz.
|
||||
*/
|
||||
void SPI::SetClockRate(double hz) { spiSetSpeed(m_port, hz); }
|
||||
void SPI::SetClockRate(double hz) { HAL_SpiSetSpeed(m_port, hz); }
|
||||
|
||||
/**
|
||||
* Configure the order that bits are sent and received on the wire
|
||||
@@ -49,8 +49,8 @@ void SPI::SetClockRate(double hz) { spiSetSpeed(m_port, hz); }
|
||||
*/
|
||||
void SPI::SetMSBFirst() {
|
||||
m_msbFirst = true;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +59,8 @@ void SPI::SetMSBFirst() {
|
||||
*/
|
||||
void SPI::SetLSBFirst() {
|
||||
m_msbFirst = false;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ void SPI::SetLSBFirst() {
|
||||
*/
|
||||
void SPI::SetSampleDataOnFalling() {
|
||||
m_sampleOnTrailing = true;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,8 +79,8 @@ void SPI::SetSampleDataOnFalling() {
|
||||
*/
|
||||
void SPI::SetSampleDataOnRising() {
|
||||
m_sampleOnTrailing = false;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ void SPI::SetSampleDataOnRising() {
|
||||
*/
|
||||
void SPI::SetClockActiveLow() {
|
||||
m_clk_idle_high = true;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,8 +99,8 @@ void SPI::SetClockActiveLow() {
|
||||
*/
|
||||
void SPI::SetClockActiveHigh() {
|
||||
m_clk_idle_high = false;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +108,8 @@ void SPI::SetClockActiveHigh() {
|
||||
*/
|
||||
void SPI::SetChipSelectActiveHigh() {
|
||||
int32_t status = 0;
|
||||
spiSetChipSelectActiveHigh(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetChipSelectActiveHigh(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +117,8 @@ void SPI::SetChipSelectActiveHigh() {
|
||||
*/
|
||||
void SPI::SetChipSelectActiveLow() {
|
||||
int32_t status = 0;
|
||||
spiSetChipSelectActiveLow(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetChipSelectActiveLow(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ void SPI::SetChipSelectActiveLow() {
|
||||
*/
|
||||
int32_t SPI::Write(uint8_t* data, uint8_t size) {
|
||||
int32_t retVal = 0;
|
||||
retVal = spiWrite(m_port, data, size);
|
||||
retVal = HAL_SpiWrite(m_port, data, size);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
|
||||
if (initiate) {
|
||||
auto dataToSend = new uint8_t[size];
|
||||
std::memset(dataToSend, 0, size);
|
||||
retVal = spiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
retVal = HAL_SpiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
} else
|
||||
retVal = spiRead(m_port, dataReceived, size);
|
||||
retVal = HAL_SpiRead(m_port, dataReceived, size);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
|
||||
int32_t SPI::Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
|
||||
uint8_t size) {
|
||||
int32_t retVal = 0;
|
||||
retVal = spiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
retVal = HAL_SpiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -192,10 +192,10 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
|
||||
uint8_t data_shift, uint8_t data_size, bool is_signed,
|
||||
bool big_endian) {
|
||||
int32_t status = 0;
|
||||
spiInitAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size,
|
||||
valid_mask, valid_value, data_shift, data_size, is_signed,
|
||||
big_endian, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiInitAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size,
|
||||
valid_mask, valid_value, data_shift, data_size,
|
||||
is_signed, big_endian, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,8 +203,8 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
|
||||
*/
|
||||
void SPI::FreeAccumulator() {
|
||||
int32_t status = 0;
|
||||
spiFreeAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiFreeAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,8 +212,8 @@ void SPI::FreeAccumulator() {
|
||||
*/
|
||||
void SPI::ResetAccumulator() {
|
||||
int32_t status = 0;
|
||||
spiResetAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiResetAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,8 +226,8 @@ void SPI::ResetAccumulator() {
|
||||
*/
|
||||
void SPI::SetAccumulatorCenter(int32_t center) {
|
||||
int32_t status = 0;
|
||||
spiSetAccumulatorCenter(m_port, center, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetAccumulatorCenter(m_port, center, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,8 +235,8 @@ void SPI::SetAccumulatorCenter(int32_t center) {
|
||||
*/
|
||||
void SPI::SetAccumulatorDeadband(int32_t deadband) {
|
||||
int32_t status = 0;
|
||||
spiSetAccumulatorDeadband(m_port, deadband, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetAccumulatorDeadband(m_port, deadband, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,8 +244,8 @@ void SPI::SetAccumulatorDeadband(int32_t deadband) {
|
||||
*/
|
||||
int32_t SPI::GetAccumulatorLastValue() const {
|
||||
int32_t status = 0;
|
||||
int32_t retVal = spiGetAccumulatorLastValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t retVal = HAL_SpiGetAccumulatorLastValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -256,8 +256,8 @@ int32_t SPI::GetAccumulatorLastValue() const {
|
||||
*/
|
||||
int64_t SPI::GetAccumulatorValue() const {
|
||||
int32_t status = 0;
|
||||
int64_t retVal = spiGetAccumulatorValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int64_t retVal = HAL_SpiGetAccumulatorValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -271,8 +271,8 @@ int64_t SPI::GetAccumulatorValue() const {
|
||||
*/
|
||||
uint32_t SPI::GetAccumulatorCount() const {
|
||||
int32_t status = 0;
|
||||
uint32_t retVal = spiGetAccumulatorCount(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint32_t retVal = HAL_SpiGetAccumulatorCount(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -283,8 +283,8 @@ uint32_t SPI::GetAccumulatorCount() const {
|
||||
*/
|
||||
double SPI::GetAccumulatorAverage() const {
|
||||
int32_t status = 0;
|
||||
double retVal = spiGetAccumulatorAverage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_SpiGetAccumulatorAverage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -299,6 +299,6 @@ double SPI::GetAccumulatorAverage() const {
|
||||
*/
|
||||
void SPI::GetAccumulatorOutput(int64_t& value, uint32_t& count) const {
|
||||
int32_t status = 0;
|
||||
spiGetAccumulatorOutput(m_port, &value, &count, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiGetAccumulatorOutput(m_port, &value, &count, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ void SampleRobot::RobotMain() { m_robotMainOverridden = false; }
|
||||
void SampleRobot::StartCompetition() {
|
||||
LiveWindow* lw = LiveWindow::GetInstance();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Framework,
|
||||
HALUsageReporting::kFramework_Simple);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Framework,
|
||||
HALUsageReporting::kFramework_Simple);
|
||||
|
||||
SmartDashboard::init();
|
||||
NetworkTable::GetTable("LiveWindow")
|
||||
@@ -112,7 +112,7 @@ void SampleRobot::StartCompetition() {
|
||||
RobotInit();
|
||||
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
HALNetworkCommunicationObserveUserProgramStarting();
|
||||
HAL_NetworkCommunicationObserveUserProgramStarting();
|
||||
|
||||
RobotMain();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ bool SensorBase::CheckDigitalChannel(uint32_t channel) {
|
||||
* @return Relay channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckRelayChannel(uint32_t channel) {
|
||||
return checkRelayChannel((uint8_t)channel);
|
||||
return HAL_CheckRelayChannel((uint8_t)channel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,16 +30,16 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits,
|
||||
|
||||
m_port = port;
|
||||
|
||||
serialInitializePort(port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
serialSetBaudRate(port, baudRate, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
serialSetDataBits(port, dataBits, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
serialSetParity(port, parity, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
serialSetStopBits(port, stopBits, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialInitializePort(port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
HAL_SerialSetBaudRate(port, baudRate, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
HAL_SerialSetDataBits(port, dataBits, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
HAL_SerialSetParity(port, parity, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
HAL_SerialSetStopBits(port, stopBits, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
// Set the default timeout to 5 seconds.
|
||||
SetTimeout(5.0f);
|
||||
@@ -53,7 +53,7 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits,
|
||||
// this);
|
||||
// viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_NULL);
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_SerialPort, 0);
|
||||
HAL_Report(HALUsageReporting::kResourceType_SerialPort, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +61,8 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits,
|
||||
*/
|
||||
SerialPort::~SerialPort() {
|
||||
int32_t status = 0;
|
||||
serialClose(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialClose(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,8 +72,8 @@ SerialPort::~SerialPort() {
|
||||
*/
|
||||
void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) {
|
||||
int32_t status = 0;
|
||||
serialSetFlowControl(m_port, flowControl, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialSetFlowControl(m_port, flowControl, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,8 @@ void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) {
|
||||
*/
|
||||
void SerialPort::EnableTermination(char terminator) {
|
||||
int32_t status = 0;
|
||||
serialEnableTermination(m_port, terminator, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialEnableTermination(m_port, terminator, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,8 +96,8 @@ void SerialPort::EnableTermination(char terminator) {
|
||||
*/
|
||||
void SerialPort::DisableTermination() {
|
||||
int32_t status = 0;
|
||||
serialDisableTermination(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialDisableTermination(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,8 +107,8 @@ void SerialPort::DisableTermination() {
|
||||
*/
|
||||
int32_t SerialPort::GetBytesReceived() {
|
||||
int32_t status = 0;
|
||||
int32_t retVal = serialGetBytesReceived(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t retVal = HAL_SerialGetBytesReceived(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ int32_t SerialPort::GetBytesReceived() {
|
||||
*/
|
||||
uint32_t SerialPort::Read(char* buffer, int32_t count) {
|
||||
int32_t status = 0;
|
||||
int32_t retVal = serialRead(m_port, buffer, count, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t retVal = HAL_SerialRead(m_port, buffer, count, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ uint32_t SerialPort::Read(char* buffer, int32_t count) {
|
||||
*/
|
||||
uint32_t SerialPort::Write(const std::string& buffer, int32_t count) {
|
||||
int32_t status = 0;
|
||||
int32_t retVal = serialWrite(m_port, buffer.c_str(), count, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t retVal = HAL_SerialWrite(m_port, buffer.c_str(), count, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ uint32_t SerialPort::Write(const std::string& buffer, int32_t count) {
|
||||
*/
|
||||
void SerialPort::SetTimeout(float timeout) {
|
||||
int32_t status = 0;
|
||||
serialSetTimeout(m_port, timeout, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialSetTimeout(m_port, timeout, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,8 +168,8 @@ void SerialPort::SetTimeout(float timeout) {
|
||||
*/
|
||||
void SerialPort::SetReadBufferSize(uint32_t size) {
|
||||
int32_t status = 0;
|
||||
serialSetReadBufferSize(m_port, size, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialSetReadBufferSize(m_port, size, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,8 +182,8 @@ void SerialPort::SetReadBufferSize(uint32_t size) {
|
||||
*/
|
||||
void SerialPort::SetWriteBufferSize(uint32_t size) {
|
||||
int32_t status = 0;
|
||||
serialSetWriteBufferSize(m_port, size, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialSetWriteBufferSize(m_port, size, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,8 +199,8 @@ void SerialPort::SetWriteBufferSize(uint32_t size) {
|
||||
*/
|
||||
void SerialPort::SetWriteBufferMode(SerialPort::WriteBufferMode mode) {
|
||||
int32_t status = 0;
|
||||
serialSetWriteMode(m_port, mode, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialSetWriteMode(m_port, mode, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,8 +211,8 @@ void SerialPort::SetWriteBufferMode(SerialPort::WriteBufferMode mode) {
|
||||
*/
|
||||
void SerialPort::Flush() {
|
||||
int32_t status = 0;
|
||||
serialFlush(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialFlush(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,6 +222,6 @@ void SerialPort::Flush() {
|
||||
*/
|
||||
void SerialPort::Reset() {
|
||||
int32_t status = 0;
|
||||
serialClear(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SerialClear(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
@@ -41,25 +41,25 @@ Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
m_solenoidHandle =
|
||||
initializeSolenoidPort(getPortWithModule(moduleNumber, channel), &status);
|
||||
m_solenoidHandle = HAL_InitializeSolenoidPort(
|
||||
HAL_GetPortWithModule(moduleNumber, channel), &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_solenoidHandle = HAL_INVALID_HANDLE;
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_solenoidHandle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("Solenoid", m_moduleNumber, m_channel,
|
||||
this);
|
||||
HALReport(HALUsageReporting::kResourceType_Solenoid, m_channel,
|
||||
m_moduleNumber);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_channel,
|
||||
m_moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
Solenoid::~Solenoid() {
|
||||
freeSolenoidPort(m_solenoidHandle);
|
||||
HAL_FreeSolenoidPort(m_solenoidHandle);
|
||||
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ Solenoid::~Solenoid() {
|
||||
void Solenoid::Set(bool on) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setSolenoid(m_solenoidHandle, on, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SetSolenoid(m_solenoidHandle, on, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +83,8 @@ void Solenoid::Set(bool on) {
|
||||
bool Solenoid::Get() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool value = getSolenoid(m_solenoidHandle, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
bool value = HAL_GetSolenoid(m_solenoidHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ SolenoidBase::SolenoidBase(uint8_t moduleNumber)
|
||||
uint8_t SolenoidBase::GetAll(int module) const {
|
||||
uint8_t value = 0;
|
||||
int32_t status = 0;
|
||||
value = getAllSolenoids(static_cast<uint8_t>(module), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
value = HAL_GetAllSolenoids(static_cast<uint8_t>(module), &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ uint8_t SolenoidBase::GetAll(int module) const {
|
||||
*/
|
||||
uint8_t SolenoidBase::GetPCMSolenoidBlackList(int module) const {
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidBlackList(static_cast<uint8_t>(module), &status);
|
||||
return HAL_GetPCMSolenoidBlackList(static_cast<uint8_t>(module), &status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +50,8 @@ uint8_t SolenoidBase::GetPCMSolenoidBlackList(int module) const {
|
||||
*/
|
||||
bool SolenoidBase::GetPCMSolenoidVoltageStickyFault(int module) const {
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageStickyFault(static_cast<uint8_t>(module),
|
||||
&status);
|
||||
return HAL_GetPCMSolenoidVoltageStickyFault(static_cast<uint8_t>(module),
|
||||
&status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ bool SolenoidBase::GetPCMSolenoidVoltageStickyFault(int module) const {
|
||||
*/
|
||||
bool SolenoidBase::GetPCMSolenoidVoltageFault(int module) const {
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageFault(static_cast<uint8_t>(module), &status);
|
||||
return HAL_GetPCMSolenoidVoltageFault(static_cast<uint8_t>(module), &status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,5 +75,5 @@ bool SolenoidBase::GetPCMSolenoidVoltageFault(int module) const {
|
||||
*/
|
||||
void SolenoidBase::ClearAllPCMStickyFaults(int module) {
|
||||
int32_t status = 0;
|
||||
return clearAllPCMStickyFaults_sol(static_cast<uint8_t>(module), &status);
|
||||
return HAL_ClearAllPCMStickyFaults_sol(static_cast<uint8_t>(module), &status);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@ Spark::Spark(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_RevSPARK, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_RevSPARK, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("Spark", GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@ Talon::Talon(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_Talon, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,6 @@ TalonSRX::TalonSRX(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_TalonSRX, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_TalonSRX, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("TalonSRX", GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ std::thread::native_handle_type Task::native_handle() {
|
||||
*/
|
||||
bool Task::Verify() {
|
||||
TASK id = (TASK)m_thread.native_handle();
|
||||
return verifyTaskID(id) == OK;
|
||||
return HAL_VerifyTaskID(id) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ bool Task::Verify() {
|
||||
int32_t Task::GetPriority() {
|
||||
int priority;
|
||||
auto id = m_thread.native_handle();
|
||||
if (HandleError(getTaskPriority(&id, &priority)))
|
||||
if (HandleError(HAL_GetTaskPriority(&id, &priority)))
|
||||
return priority;
|
||||
else
|
||||
return 0;
|
||||
@@ -79,7 +79,7 @@ int32_t Task::GetPriority() {
|
||||
*/
|
||||
bool Task::SetPriority(int32_t priority) {
|
||||
auto id = m_thread.native_handle();
|
||||
return HandleError(setTaskPriority(&id, priority));
|
||||
return HandleError(HAL_SetTaskPriority(&id, priority));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ std::string Task::GetName() const { return m_taskName; }
|
||||
bool Task::HandleError(STATUS results) {
|
||||
if (results != ERROR) return true;
|
||||
int errsv = errno;
|
||||
if (errsv == HAL_taskLib_ILLEGAL_PRIORITY) {
|
||||
if (errsv == HAL_TaskLib_ILLEGAL_PRIORITY) {
|
||||
wpi_setWPIErrorWithContext(TaskPriorityError, m_taskName.c_str());
|
||||
} else {
|
||||
printf("ERROR: errno=%i", errsv);
|
||||
|
||||
@@ -73,7 +73,7 @@ void Ultrasonic::Initialize() {
|
||||
|
||||
static int instances = 0;
|
||||
instances++;
|
||||
HALReport(HALUsageReporting::kResourceType_Ultrasonic, instances);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Ultrasonic, instances);
|
||||
LiveWindow::GetInstance()->AddSensor("Ultrasonic",
|
||||
m_echoChannel->GetChannel(), this);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ bool wpi_assert_impl(bool conditionValue, const char* conditionText,
|
||||
std::string error = errorStream.str();
|
||||
|
||||
// Print the error and send it to the DriverStation
|
||||
HALSendError(1, 1, 0, error.c_str(), location.c_str(), stack.c_str(), 1);
|
||||
HAL_SendError(1, 1, 0, error.c_str(), location.c_str(), stack.c_str(), 1);
|
||||
}
|
||||
|
||||
return conditionValue;
|
||||
@@ -80,7 +80,7 @@ void wpi_assertEqual_common_impl(const char* valueA, const char* valueB,
|
||||
std::string error = errorStream.str();
|
||||
|
||||
// Print the error and send it to the DriverStation
|
||||
HALSendError(1, 1, 0, error.c_str(), location.c_str(), trace.c_str(), 1);
|
||||
HAL_SendError(1, 1, 0, error.c_str(), location.c_str(), trace.c_str(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,8 +127,8 @@ bool wpi_assertNotEqual_impl(int valueA, int valueB, const char* valueAString,
|
||||
*/
|
||||
uint16_t GetFPGAVersion() {
|
||||
int32_t status = 0;
|
||||
uint16_t version = getFPGAVersion(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint16_t version = HAL_GetFPGAVersion(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -142,8 +142,8 @@ uint16_t GetFPGAVersion() {
|
||||
*/
|
||||
uint32_t GetFPGARevision() {
|
||||
int32_t status = 0;
|
||||
uint32_t revision = getFPGARevision(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint32_t revision = HAL_GetFPGARevision(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return revision;
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ uint32_t GetFPGARevision() {
|
||||
*/
|
||||
uint64_t GetFPGATime() {
|
||||
int32_t status = 0;
|
||||
uint64_t time = getFPGATime(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint64_t time = HAL_GetFPGATime(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return time;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ uint64_t GetFPGATime() {
|
||||
bool GetUserButton() {
|
||||
int32_t status = 0;
|
||||
|
||||
bool value = getFPGAButton(&status);
|
||||
bool value = HAL_GetFPGAButton(&status);
|
||||
wpi_setGlobalError(status);
|
||||
|
||||
return value;
|
||||
|
||||
@@ -37,5 +37,5 @@ Victor::Victor(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
|
||||
HALReport(HALUsageReporting::kResourceType_Victor, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_Victor, GetChannel());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@ VictorSP::VictorSP(uint32_t channel) : PWMSpeedController(channel) {
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_VictorSP, GetChannel());
|
||||
HAL_Report(HALUsageReporting::kResourceType_VictorSP, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("VictorSP", GetChannel(), this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user