mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[hal] Report previous allocation location for indexed resource duplicates (#3322)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/PWM.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
|
||||
@@ -17,7 +18,9 @@ using namespace frc;
|
||||
AddressableLED::AddressableLED(int port) {
|
||||
int32_t status = 0;
|
||||
|
||||
m_pwmHandle = HAL_InitializePWMPort(HAL_GetPort(port), &status);
|
||||
auto stack = wpi::GetStackTrace(1);
|
||||
m_pwmHandle =
|
||||
HAL_InitializePWMPort(HAL_GetPort(port), stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Port " + wpi::Twine{port});
|
||||
if (m_pwmHandle == HAL_kInvalidHandle) {
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/AnalogGyro.h>
|
||||
#include <hal/Errors.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/Base.h"
|
||||
@@ -111,7 +112,9 @@ void AnalogGyro::Reset() {
|
||||
void AnalogGyro::InitGyro() {
|
||||
if (m_gyroHandle == HAL_kInvalidHandle) {
|
||||
int32_t status = 0;
|
||||
m_gyroHandle = HAL_InitializeAnalogGyro(m_analog->m_port, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_gyroHandle =
|
||||
HAL_InitializeAnalogGyro(m_analog->m_port, stackTrace.c_str(), &status);
|
||||
if (status == PARAMETER_OUT_OF_RANGE) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange,
|
||||
"channel must be accumulator channel");
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -28,7 +29,8 @@ AnalogInput::AnalogInput(int channel) {
|
||||
|
||||
HAL_PortHandle port = HAL_GetPort(channel);
|
||||
int32_t status = 0;
|
||||
m_port = HAL_InitializeAnalogInputPort(port, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_port = HAL_InitializeAnalogInputPort(port, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Analog Input " + wpi::Twine{channel});
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogChannel, channel + 1);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -29,7 +30,8 @@ AnalogOutput::AnalogOutput(int channel) {
|
||||
|
||||
HAL_PortHandle port = HAL_GetPort(m_channel);
|
||||
int32_t status = 0;
|
||||
m_port = HAL_InitializeAnalogOutputPort(port, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_port = HAL_InitializeAnalogOutputPort(port, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "analog output " + wpi::Twine(channel));
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogOutput, m_channel + 1);
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
#include "frc/DigitalInput.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include <hal/DIO.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -26,7 +28,9 @@ DigitalInput::DigitalInput(int channel) {
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializeDIOPort(HAL_GetPort(channel), true, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDIOPort(HAL_GetPort(channel), true,
|
||||
stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Digital Channel " + wpi::Twine{channel});
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalInput, channel + 1);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -27,7 +28,9 @@ DigitalOutput::DigitalOutput(int channel) {
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializeDIOPort(HAL_GetPort(channel), false, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDIOPort(HAL_GetPort(channel), false,
|
||||
stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Digital Channel " + wpi::Twine{channel});
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalOutput, channel + 1);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/PWM.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -26,8 +27,10 @@ PWM::PWM(int channel, bool registerSendable) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto stack = wpi::GetStackTrace(1);
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializePWMPort(HAL_GetPort(channel), &status);
|
||||
m_handle =
|
||||
HAL_InitializePWMPort(HAL_GetPort(channel), stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "PWM Channel " + wpi::Twine{channel});
|
||||
|
||||
m_channel = channel;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <hal/Relay.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
@@ -31,13 +32,17 @@ Relay::Relay(int channel, Relay::Direction direction)
|
||||
|
||||
if (m_direction == kBothDirections || m_direction == kForwardOnly) {
|
||||
int32_t status = 0;
|
||||
m_forwardHandle = HAL_InitializeRelayPort(portHandle, true, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_forwardHandle =
|
||||
HAL_InitializeRelayPort(portHandle, true, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Relay Channel " + wpi::Twine{m_channel});
|
||||
HAL_Report(HALUsageReporting::kResourceType_Relay, m_channel + 1);
|
||||
}
|
||||
if (m_direction == kBothDirections || m_direction == kReverseOnly) {
|
||||
int32_t status = 0;
|
||||
m_reverseHandle = HAL_InitializeRelayPort(portHandle, false, &status);
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_reverseHandle =
|
||||
HAL_InitializeRelayPort(portHandle, false, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Relay Channel " + wpi::Twine{m_channel});
|
||||
HAL_Report(HALUsageReporting::kResourceType_Relay, m_channel + 128);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user