JNI for java

Normal vs recursive mutex
HAL delineation
This commit is contained in:
charris
2014-01-06 10:12:21 -05:00
parent b62b606110
commit f7146d4230
134 changed files with 2377 additions and 3358 deletions

View File

@@ -7,7 +7,7 @@
#include "ADXL345_SPI.h"
#include "DigitalInput.h"
#include "DigitalOutput.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "SPI.h"
const uint8_t ADXL345_SPI::kPowerCtlRegister;
@@ -109,7 +109,7 @@ void ADXL345_SPI::Init(DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *mi
m_spi->SetBitsPerWord(24);
m_spi->ApplyConfig();
nUsageReporting::report(nUsageReporting::kResourceType_ADXL345, nUsageReporting::kADXL345_SPI);
HALReport(HALUsageReporting::kResourceType_ADXL345, HALUsageReporting::kADXL345_SPI);
}
}

View File

@@ -6,7 +6,7 @@
#include "Accelerometer.h"
#include "AnalogModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -18,7 +18,7 @@ void Accelerometer::InitAccelerometer()
m_table = NULL;
m_voltsPerG = 1.0;
m_zeroGVoltage = 2.5;
nUsageReporting::report(nUsageReporting::kResourceType_Accelerometer, m_analogChannel->GetChannel(), m_analogChannel->GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_Accelerometer, m_analogChannel->GetChannel(), m_analogChannel->GetModuleNumber() - 1);
LiveWindow::GetInstance()->AddSensor("Accelerometer", m_analogChannel->GetModuleNumber(), m_analogChannel->GetChannel(), this);
}

View File

@@ -6,7 +6,7 @@
#include "AnalogChannel.h"
#include "AnalogModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -53,7 +53,7 @@ void AnalogChannel::InitChannel(uint8_t moduleNumber, uint32_t channel)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
LiveWindow::GetInstance()->AddSensor("AnalogChannel",channel, GetModuleNumber(), this);
nUsageReporting::report(nUsageReporting::kResourceType_AnalogChannel, channel, GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_AnalogChannel, channel, GetModuleNumber() - 1);
}
/**

View File

@@ -8,7 +8,7 @@
#include "AnalogChannel.h"
#include "AnalogModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
@@ -25,7 +25,7 @@ void AnalogTrigger::InitTrigger(uint8_t moduleNumber, uint32_t channel)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
m_index = index;
nUsageReporting::report(nUsageReporting::kResourceType_AnalogTrigger, channel, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_AnalogTrigger, channel, moduleNumber - 1);
}
/**

View File

@@ -6,7 +6,7 @@
#include "AnalogTriggerOutput.h"
#include "AnalogTrigger.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
/**
@@ -22,7 +22,7 @@ AnalogTriggerOutput::AnalogTriggerOutput(AnalogTrigger *trigger, AnalogTriggerTy
: m_trigger (trigger)
, m_outputType (outputType)
{
nUsageReporting::report(nUsageReporting::kResourceType_AnalogTriggerOutput, trigger->GetIndex(), outputType);
HALReport(HALUsageReporting::kResourceType_AnalogTriggerOutput, trigger->GetIndex(), outputType);
}
AnalogTriggerOutput::~AnalogTriggerOutput()

View File

@@ -6,9 +6,9 @@
#include "CANJaguar.h"
#define tNIRIO_i32 int
#include "CAN/JaguarCANDriver.h"
//#include "CAN/JaguarCANDriver.h"
#include "CAN/can_proto.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include <stdio.h>
#include "LiveWindow/LiveWindow.h"
@@ -31,7 +31,7 @@ constexpr double CANJaguar::kApproxBusVoltage;
void CANJaguar::InitCANJaguar()
{
m_table = NULL;
m_transactionSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE);
m_transactionSemaphore = initializeMutexNormal();
if (m_deviceNumber < 1 || m_deviceNumber > 63)
{
char buf[256];
@@ -69,7 +69,7 @@ void CANJaguar::InitCANJaguar()
}
m_safetyHelper = new MotorSafetyHelper(this);
nUsageReporting::report(nUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode);
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode);
LiveWindow::GetInstance()->AddActuator("CANJaguar", m_deviceNumber, 0, this);
}
@@ -405,7 +405,7 @@ void CANJaguar::setTransaction(uint32_t messageID, const uint8_t *data, uint8_t
return;
// Make sure we don't have more than one transaction with the same Jaguar outstanding.
takeMutex(m_transactionSemaphore, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_transactionSemaphore);
// Throw away any stale acks.
receiveMessage(&ackMessageID, NULL, 0, 0.0f);
@@ -444,7 +444,7 @@ void CANJaguar::getTransaction(uint32_t messageID, uint8_t *data, uint8_t *dataS
}
// Make sure we don't have more than one transaction with the same Jaguar outstanding.
takeMutex(m_transactionSemaphore, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_transactionSemaphore);
// Throw away any stale responses.
receiveMessage(&targetedMessageID, NULL, 0, 0.0f);
@@ -778,7 +778,7 @@ void CANJaguar::ChangeControlMode(ControlMode controlMode)
// Update the local mode
m_controlMode = controlMode;
nUsageReporting::report(nUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode);
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode);
}
/**

View File

@@ -8,7 +8,7 @@
#include "Buttons/ButtonScheduler.h"
#include "Commands/Subsystem.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
#include <iostream>
@@ -19,23 +19,21 @@ Scheduler *Scheduler::_instance = NULL;
Scheduler::Scheduler() :
m_buttonsLock(NULL), m_additionsLock(NULL), m_adding(false) {
m_buttonsLock = initializeMutex(
SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE);
m_additionsLock = initializeMutex(
SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE);
m_buttonsLock = initializeMutexNormal();
m_additionsLock = initializeMutexNormal();
nUsageReporting::report(nUsageReporting::kResourceType_Command,
nUsageReporting::kCommand_Scheduler);
HALReport(HALUsageReporting::kResourceType_Command,
HALUsageReporting::kCommand_Scheduler);
m_table = NULL;
m_enabled = true;
}
Scheduler::~Scheduler() {
takeMutex(m_additionsLock, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_additionsLock);
deleteMutex(m_additionsLock);
takeMutex(m_buttonsLock, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_buttonsLock);
deleteMutex(m_buttonsLock);
}

View File

@@ -6,7 +6,7 @@
#include "Compressor.h"
#include "DigitalInput.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Timer.h"
#include "WPIErrors.h"
@@ -52,7 +52,7 @@ void Compressor::InitCompressor(uint8_t pressureSwitchModuleNumber,
m_pressureSwitch = new DigitalInput(pressureSwitchModuleNumber, pressureSwitchChannel);
m_relay = new Relay(compresssorRelayModuleNumber, compressorRelayChannel, Relay::kForwardOnly);
nUsageReporting::report(nUsageReporting::kResourceType_Compressor, 0);
HALReport(HALUsageReporting::kResourceType_Compressor, 0);
if (!m_task.Start((int32_t)this))
{

View File

@@ -7,7 +7,7 @@
#include "Counter.h"
#include "AnalogTrigger.h"
#include "DigitalInput.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
@@ -29,7 +29,7 @@ void Counter::InitCounter(Mode mode)
m_allocatedUpSource = false;
m_allocatedDownSource = false;
nUsageReporting::report(nUsageReporting::kResourceType_Counter, index, mode);
HALReport(HALUsageReporting::kResourceType_Counter, index, mode);
}
/**

View File

@@ -6,7 +6,7 @@
#include "Dashboard.h"
#include "DriverStation.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
#include <string.h>
@@ -33,7 +33,7 @@ Dashboard::Dashboard(MUTEX_ID statusDataSem)
m_localPrintBuffer = new char[kMaxDashboardDataSize * 2];
m_localPrintBuffer[0] = 0;
m_packPtr = m_localBuffer;
m_printSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
m_printSemaphore = initializeMutexNormal();
}
/**
@@ -307,7 +307,7 @@ int32_t Dashboard::Finalize()
static bool reported = false;
if (!reported)
{
nUsageReporting::report(nUsageReporting::kResourceType_Dashboard, 0);
HALReport(HALUsageReporting::kResourceType_Dashboard, 0);
reported = true;
}

View File

@@ -6,7 +6,7 @@
#include "DigitalInput.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
@@ -39,7 +39,7 @@ void DigitalInput::InitDigitalInput(uint8_t moduleNumber, uint32_t channel)
m_module = DigitalModule::GetInstance(moduleNumber);
m_module->AllocateDIO(channel, true);
nUsageReporting::report(nUsageReporting::kResourceType_DigitalInput, channel, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_DigitalInput, channel, moduleNumber - 1);
}
/**

View File

@@ -6,7 +6,7 @@
#include "DigitalOutput.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
@@ -38,7 +38,7 @@ void DigitalOutput::InitDigitalOutput(uint8_t moduleNumber, uint32_t channel)
m_module = DigitalModule::GetInstance(moduleNumber);
m_module->AllocateDIO(m_channel, false);
nUsageReporting::report(nUsageReporting::kResourceType_DigitalOutput, channel, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_DigitalOutput, channel, moduleNumber - 1);
}
/**

View File

@@ -5,7 +5,7 @@
/*----------------------------------------------------------------------------*/
#include "DoubleSolenoid.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include <string.h>
#include "LiveWindow/LiveWindow.h"
@@ -52,8 +52,8 @@ void DoubleSolenoid::InitSolenoid()
m_forwardMask = 1 << (m_forwardChannel - 1);
m_reverseMask = 1 << (m_reverseChannel - 1);
nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_forwardChannel, m_moduleNumber - 1);
nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_reverseChannel, m_moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_Solenoid, m_forwardChannel, m_moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel, m_moduleNumber - 1);
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", m_moduleNumber, m_forwardChannel, this);
}

View File

@@ -8,12 +8,20 @@
#include "AnalogChannel.h"
#include "HAL/cpp/Synchronized.h"
#include "Timer.h"
#include "NetworkCommunication/FRCComm.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "MotorSafetyHelper.h"
#include "Utility.h"
#include "WPIErrors.h"
#include <string.h>
#include "Log.h"
// set the logging level
TLogLevel dsLogLevel = logDEBUG;
#define DS_LOG(level) \
if (level > dsLogLevel) ; \
else Log().Get(level)
const uint32_t DriverStation::kBatteryModuleNumber;
const uint32_t DriverStation::kBatteryChannel;
@@ -32,7 +40,7 @@ DriverStation::DriverStation()
: m_controlData (NULL)
, m_digitalOut (0)
, m_batteryChannel (NULL)
, m_statusDataSemaphore (initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE))
, m_statusDataSemaphore (initializeMutexNormal())
, m_task ("DriverStation", (FUNCPTR)DriverStation::InitTask)
, m_dashboardHigh(m_statusDataSemaphore)
, m_dashboardLow(m_statusDataSemaphore)
@@ -49,16 +57,16 @@ DriverStation::DriverStation()
, m_userInTest(false)
{
// Create a new semaphore
m_packetDataAvailableSem = initializeMutex(SEMAPHORE_Q_PRIORITY);
m_newControlData = initializeSemaphore(SEMAPHORE_Q_FIFO, SEMAPHORE_EMPTY);
m_packetDataAvailableSem = initializeMutexNormal();
m_newControlData = initializeSemaphore(SEMAPHORE_EMPTY);
// Register that semaphore with the network communications task.
// It will signal when new packet data is available.
setNewDataSem(m_packetDataAvailableSem);
HALSetNewDataSem(m_packetDataAvailableSem);
m_waitForDataSem = initializeMultiWait();
m_controlData = new FRCCommonControlData;
m_controlData = new HALCommonControlData;
// initialize packet number and control words to zero;
m_controlData->packetIndex = 0;
@@ -104,7 +112,7 @@ DriverStation::~DriverStation()
m_instance = NULL;
deleteMultiWait(m_waitForDataSem);
// Unregister our semaphore.
setNewDataSem(0);
HALSetNewDataSem(0);
deleteMutex(m_packetDataAvailableSem);
}
@@ -118,7 +126,7 @@ void DriverStation::Run()
int period = 0;
while (true)
{
takeMutex(m_packetDataAvailableSem, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_packetDataAvailableSem);
SetData();
m_enhancedIO.UpdateData();
GetData();
@@ -129,13 +137,13 @@ void DriverStation::Run()
period = 0;
}
if (m_userInDisabled)
FRC_NetworkCommunication_observeUserProgramDisabled();
HALNetworkCommunicationObserveUserProgramDisabled();
if (m_userInAutonomous)
FRC_NetworkCommunication_observeUserProgramAutonomous();
HALNetworkCommunicationObserveUserProgramAutonomous();
if (m_userInTeleop)
FRC_NetworkCommunication_observeUserProgramTeleop();
HALNetworkCommunicationObserveUserProgramTeleop();
if (m_userInTest)
FRC_NetworkCommunication_observeUserProgramTest();
HALNetworkCommunicationObserveUserProgramTest();
}
}
@@ -159,7 +167,9 @@ DriverStation* DriverStation::GetInstance()
void DriverStation::GetData()
{
static bool lastEnabled = false;
getCommonControlData(m_controlData, HAL_WAIT_FOREVER);
HALGetCommonControlData(m_controlData, HAL_WAIT_FOREVER);
if (!lastEnabled && IsEnabled())
{
// If starting teleop, assume that autonomous just took up 15 seconds
@@ -190,7 +200,7 @@ void DriverStation::SetData()
m_dashboardInUseHigh->GetStatusBuffer(&userStatusDataHigh, &userStatusDataHighSize);
m_dashboardInUseLow->GetStatusBuffer(&userStatusDataLow, &userStatusDataLowSize);
setStatusData(GetBatteryVoltage(), m_digitalOut, m_updateNumber,
HALSetStatusData(GetBatteryVoltage(), m_digitalOut, m_updateNumber,
userStatusDataHigh, userStatusDataHighSize, userStatusDataLow, userStatusDataLowSize, HAL_WAIT_FOREVER);
m_dashboardInUseHigh->Flush();
@@ -311,7 +321,7 @@ float DriverStation::GetAnalogIn(uint32_t channel)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_Analog);
HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel, HALUsageReporting::kDriverStationCIO_Analog);
reported_mask |= (1 >> channel);
}
@@ -343,7 +353,7 @@ bool DriverStation::GetDigitalIn(uint32_t channel)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_DigitalIn);
HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel, HALUsageReporting::kDriverStationCIO_DigitalIn);
reported_mask |= (1 >> channel);
}
@@ -367,7 +377,7 @@ void DriverStation::SetDigitalOut(uint32_t channel, bool value)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_DigitalOut);
HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel,HALUsageReporting::kDriverStationCIO_DigitalOut);
reported_mask |= (1 >> channel);
}
@@ -421,7 +431,7 @@ bool DriverStation::IsTest()
*/
bool DriverStation::IsNewControlData()
{
return takeSemaphore(m_newControlData, SEMAPHORE_NO_WAIT) == 0;
return tryTakeSemaphore(m_newControlData) == 0;
}
/**

View File

@@ -5,7 +5,7 @@
/*----------------------------------------------------------------------------*/
#include "DriverStationEnhancedIO.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
#include <string.h>
@@ -27,8 +27,8 @@ DriverStationEnhancedIO::DriverStationEnhancedIO()
m_outputData.id = kOutputBlockID;
// Expected to be active low, so initialize inactive.
m_outputData.data.fixed_digital_out = 0x3;
m_inputDataSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
m_outputDataSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
m_inputDataSemaphore = initializeMutexNormal();
m_outputDataSemaphore = initializeMutexNormal();
m_encoderOffsets[0] = 0;
m_encoderOffsets[1] = 0;
}
@@ -72,9 +72,9 @@ void DriverStationEnhancedIO::UpdateData()
}
m_outputData.flags |= kStatusConfigChanged;
}
overrideIOConfig((char*)&m_outputData, 5);
HALOverrideIOConfig((char*)&m_outputData, 5);
}
retVal = getDynamicControlData(kOutputBlockID, (char*)&tempOutputData, sizeof(status_block_t), 5);
retVal = HALGetDynamicControlData(kOutputBlockID, (char*)&tempOutputData, sizeof(status_block_t), 5);
if (retVal == 0)
{
if (m_outputValid)
@@ -114,7 +114,7 @@ void DriverStationEnhancedIO::UpdateData()
{
Synchronized sync(m_inputDataSemaphore);
control_block_t tempInputData;
retVal = getDynamicControlData(kInputBlockID, (char*)&tempInputData, sizeof(control_block_t), 5);
retVal = HALGetDynamicControlData(kInputBlockID, (char*)&tempInputData, sizeof(control_block_t), 5);
if (retVal == 0 && tempInputData.data.api_version == kSupportedAPIVersion)
{
m_inputData = tempInputData;
@@ -179,7 +179,7 @@ double DriverStationEnhancedIO::GetAcceleration(tAccelChannel channel)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_Acceleration);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_Acceleration);
reported_mask |= (1 >> channel);
}
@@ -221,7 +221,7 @@ double DriverStationEnhancedIO::GetAnalogInRatio(uint32_t channel)
static uint16_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_AnalogIn);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_AnalogIn);
reported_mask |= (1 >> channel);
}
@@ -286,7 +286,7 @@ void DriverStationEnhancedIO::SetAnalogOut(uint32_t channel, double value)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_AnalogOut);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_AnalogOut);
reported_mask |= (1 >> channel);
}
@@ -320,7 +320,7 @@ bool DriverStationEnhancedIO::GetButton(uint32_t channel)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_Button);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_Button);
reported_mask |= (1 >> channel);
}
@@ -339,7 +339,7 @@ uint8_t DriverStationEnhancedIO::GetButtons()
wpi_setWPIError(EnhancedIOMissing);
return 0;
}
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 0, nUsageReporting::kDriverStationEIO_Button);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_Button);
Synchronized sync(m_inputDataSemaphore);
return m_inputData.data.buttons;
}
@@ -366,7 +366,7 @@ void DriverStationEnhancedIO::SetLED(uint32_t channel, bool value)
static uint16_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_LED);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_LED);
reported_mask |= (1 >> channel);
}
@@ -392,7 +392,8 @@ void DriverStationEnhancedIO::SetLEDs(uint8_t value)
wpi_setWPIError(EnhancedIOMissing);
return;
}
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 0, nUsageReporting::kDriverStationEIO_LED);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_LED);
Synchronized sync(m_outputDataSemaphore);
m_outputData.data.leds = value;
}
@@ -414,7 +415,7 @@ bool DriverStationEnhancedIO::GetDigital(uint32_t channel)
static uint32_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_DigitalIn);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_DigitalIn);
reported_mask |= (1 >> channel);
}
@@ -433,7 +434,7 @@ uint16_t DriverStationEnhancedIO::GetDigitals()
wpi_setWPIError(EnhancedIOMissing);
return 0;
}
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 0, nUsageReporting::kDriverStationEIO_DigitalIn);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_DigitalIn);
Synchronized sync(m_inputDataSemaphore);
return m_inputData.data.digital;
}
@@ -460,7 +461,7 @@ void DriverStationEnhancedIO::SetDigitalOutput(uint32_t channel, bool value)
static uint32_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_DigitalOut);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_DigitalOut);
reported_mask |= (1 >> channel);
}
@@ -762,7 +763,7 @@ void DriverStationEnhancedIO::SetFixedDigitalOutput(uint32_t channel, bool value
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_FixedDigitalOut);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_FixedDigitalOut);
reported_mask |= (1 >> channel);
}
@@ -806,7 +807,7 @@ int16_t DriverStationEnhancedIO::GetEncoder(uint32_t encoderNumber)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> encoderNumber)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, encoderNumber, nUsageReporting::kDriverStationEIO_Encoder);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, encoderNumber, HALUsageReporting::kDriverStationEIO_Encoder);
reported_mask |= (1 >> encoderNumber);
}
@@ -906,7 +907,7 @@ double DriverStationEnhancedIO::GetTouchSlider()
return 0.0;
}
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 1, nUsageReporting::kDriverStationEIO_TouchSlider);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 1, HALUsageReporting::kDriverStationEIO_TouchSlider);
Synchronized sync(m_inputDataSemaphore);
uint8_t value = m_inputData.data.capsense_slider;
@@ -961,7 +962,7 @@ void DriverStationEnhancedIO::SetPWMOutput(uint32_t channel, double value)
static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_PWM);
HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_PWM);
reported_mask |= (1 >> channel);
}

View File

@@ -8,8 +8,8 @@
//#include <algorithm>
#include <string.h>
#include "NetworkCommunication/FRCComm.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
#undef min
@@ -29,14 +29,14 @@ DriverStationLCD::DriverStationLCD()
: m_textBuffer (NULL)
, m_textBufferSemaphore (NULL)
{
m_textBuffer = new char[USER_DS_LCD_DATA_SIZE];
memset(m_textBuffer, ' ', USER_DS_LCD_DATA_SIZE);
m_textBuffer = new char[HAL_USER_DS_LCD_DATA_SIZE];
memset(m_textBuffer, ' ', HAL_USER_DS_LCD_DATA_SIZE);
*((uint16_t *)m_textBuffer) = kFullDisplayTextCommand;
m_textBufferSemaphore = initializeMutex(SEMAPHORE_DELETE_SAFE);
m_textBufferSemaphore = initializeMutexNormal();
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationLCD, 0);
HALReport(HALUsageReporting::kResourceType_DriverStationLCD, 0);
AddToSingletonList();
}
@@ -66,7 +66,7 @@ DriverStationLCD* DriverStationLCD::GetInstance()
void DriverStationLCD::UpdateLCD()
{
Synchronized sync(m_textBufferSemaphore);
setUserDsLcdData(m_textBuffer, USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms);
HALSetUserDsLcdData(m_textBuffer, HAL_USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms);
}
/**

View File

@@ -6,7 +6,7 @@
#include "Encoder.h"
#include "DigitalInput.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -62,7 +62,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType)
m_distancePerPulse = 1.0;
m_pidSource = kDistance;
nUsageReporting::report(nUsageReporting::kResourceType_Encoder, index, encodingType);
HALReport(HALUsageReporting::kResourceType_Encoder, index, encodingType);
LiveWindow::GetInstance()->AddSensor("Encoder", m_aSource->GetModuleForRouting(), m_aSource->GetChannelForRouting(), this);
}

View File

@@ -10,7 +10,7 @@
#include <cstdio>
#include <cstring>
#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/FRCComm.h"
#include "Timer.h"
#include "Utility.h"
bool Error::m_stackTraceEnabled = false;
@@ -94,7 +94,7 @@ void Error::Report()
// TODO: Add logging to disk
// Send to the DriverStation
setErrorData(error_with_code, strlen(error_with_code), 100);
HALSetErrorData(error_with_code, strlen(error_with_code), 100);
delete [] error_with_code;

View File

@@ -14,7 +14,7 @@
#include <errno.h>
#include <cstdio>
MUTEX_ID ErrorBase::_globalErrorMutex = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
MUTEX_ID ErrorBase::_globalErrorMutex = initializeMutexNormal();
Error ErrorBase::_globalError;
/**
* @brief Initialize the instance status to 0 for now.

View File

@@ -7,7 +7,7 @@
#include "Gyro.h"
#include "AnalogChannel.h"
#include "AnalogModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Timer.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -66,7 +66,7 @@ void Gyro::InitGyro()
SetPIDSourceParameter(kAngle);
nUsageReporting::report(nUsageReporting::kResourceType_Gyro, m_analog->GetChannel(), m_analog->GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel(), m_analog->GetModuleNumber() - 1);
LiveWindow::GetInstance()->AddSensor("Gyro", m_analog->GetModuleNumber(), m_analog->GetChannel(), this);
}

View File

@@ -7,7 +7,7 @@
#include "HiTechnicColorSensor.h"
#include "DigitalModule.h"
#include "I2C.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "networktables2/type/NumberArray.h"
#include "WPIErrors.h"
@@ -54,7 +54,7 @@ HiTechnicColorSensor::HiTechnicColorSensor(uint8_t moduleNumber)
wpi_setWPIError(CompassTypeError);
}
nUsageReporting::report(nUsageReporting::kResourceType_HiTechnicColorSensor, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_HiTechnicColorSensor, moduleNumber - 1);
}
}

View File

@@ -7,7 +7,7 @@
#include "HiTechnicCompass.h"
#include "DigitalModule.h"
#include "I2C.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -45,7 +45,7 @@ HiTechnicCompass::HiTechnicCompass(uint8_t moduleNumber)
wpi_setWPIError(CompassTypeError);
}
nUsageReporting::report(nUsageReporting::kResourceType_HiTechnicCompass, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_HiTechnicCompass, moduleNumber - 1);
LiveWindow::GetInstance()->AddSensor("HiTechnicCompass", moduleNumber, 0, this);
}
}

View File

@@ -6,7 +6,7 @@
#include "I2C.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
@@ -26,11 +26,11 @@ I2C::I2C(DigitalModule *module, uint8_t deviceAddress)
{
if (m_semaphore == NULL)
{
m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
m_semaphore = initializeMutexNormal();
}
m_objCount++;
nUsageReporting::report(nUsageReporting::kResourceType_I2C, deviceAddress, module->GetNumber() - 1);
HALReport(HALUsageReporting::kResourceType_I2C, deviceAddress, module->GetNumber() - 1);
}
/**
@@ -163,7 +163,7 @@ void I2C::SetCompatibilityMode(bool enable)
const char *cm = NULL;
if (m_compatibilityMode) cm = "C";
nUsageReporting::report(nUsageReporting::kResourceType_I2C, m_deviceAddress, m_module->GetNumber() - 1, cm);
HALReport(HALUsageReporting::kResourceType_I2C, m_deviceAddress, m_module->GetNumber() - 1, cm);
}
/**

View File

@@ -7,7 +7,7 @@
#include "IterativeRobot.h"
#include "DriverStation.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/HAL.h"
#include "SmartDashboard/SmartDashboard.h"
#include "LiveWindow/LiveWindow.h"
@@ -92,7 +92,7 @@ double IterativeRobot::GetLoopsPerSec()
*/
void IterativeRobot::StartCompetition()
{
nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Iterative);
HALReport(HALUsageReporting::kResourceType_Framework, HALUsageReporting::kFramework_Iterative);
LiveWindow *lw = LiveWindow::GetInstance();
// first and one-time initialization
@@ -121,7 +121,7 @@ void IterativeRobot::StartCompetition()
}
if (NextPeriodReady())
{
FRC_NetworkCommunication_observeUserProgramDisabled();
HALNetworkCommunicationObserveUserProgramDisabled();
DisabledPeriodic();
}
}
@@ -141,7 +141,7 @@ void IterativeRobot::StartCompetition()
}
if (NextPeriodReady())
{
FRC_NetworkCommunication_observeUserProgramAutonomous();
HALNetworkCommunicationObserveUserProgramAutonomous();
AutonomousPeriodic();
}
}
@@ -161,7 +161,7 @@ void IterativeRobot::StartCompetition()
}
if (NextPeriodReady())
{
FRC_NetworkCommunication_observeUserProgramTest();
HALNetworkCommunicationObserveUserProgramTest();
TestPeriodic();
}
}
@@ -182,7 +182,7 @@ void IterativeRobot::StartCompetition()
}
if (NextPeriodReady())
{
FRC_NetworkCommunication_observeUserProgramTeleop();
HALNetworkCommunicationObserveUserProgramTeleop();
TeleopPeriodic();
}
}

View File

@@ -6,7 +6,7 @@
#include "Jaguar.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "DigitalModule.h"
#include "LiveWindow/LiveWindow.h"
@@ -28,7 +28,7 @@ void Jaguar::InitJaguar()
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetRaw(m_centerPwm);
nUsageReporting::report(nUsageReporting::kResourceType_Jaguar, GetChannel(), GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_Jaguar, GetChannel(), GetModuleNumber() - 1);
LiveWindow::GetInstance()->AddActuator("Jaguar", GetModuleNumber(), GetChannel(), this);
}

View File

@@ -6,7 +6,7 @@
#include "Joystick.h"
#include "DriverStation.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include <math.h>
@@ -43,7 +43,7 @@ Joystick::Joystick(uint32_t port)
m_buttons[kTriggerButton] = kDefaultTriggerButton;
m_buttons[kTopButton] = kDefaultTopButton;
nUsageReporting::report(nUsageReporting::kResourceType_Joystick, port);
HALReport(HALUsageReporting::kResourceType_Joystick, port);
}
/**

View File

@@ -7,16 +7,16 @@
#include "Kinect.h"
#include "DriverStation.h"
#include "NetworkCommunication/FRCComm.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Skeleton.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
#include <cstring>
#define kHeaderBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Header
#define kSkeletonExtraBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Extra1
#define kSkeletonBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Vertices1
#define kHeaderBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Header
#define kSkeletonExtraBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1
#define kSkeletonBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1
Kinect *Kinect::_instance = NULL;
@@ -25,14 +25,14 @@ Kinect::Kinect() :
m_numberOfPlayers(0)
{
AddToSingletonList();
m_dataLock = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE);
m_dataLock = initializeMutexNormal();
nUsageReporting::report(nUsageReporting::kResourceType_Kinect, 0);
HALReport(HALUsageReporting::kResourceType_Kinect, 0);
}
Kinect::~Kinect()
{
takeMutex(m_dataLock, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_dataLock);
deleteMutex(m_dataLock);
}
@@ -156,7 +156,7 @@ void Kinect::UpdateData()
if (m_recentPacketNumber != packetNumber)
{
m_recentPacketNumber = packetNumber;
int retVal = getDynamicControlData(kHeaderBundleID, m_rawHeader, sizeof(m_rawHeader), 5);
int retVal = HALGetDynamicControlData(kHeaderBundleID, m_rawHeader, sizeof(m_rawHeader), 5);
if(retVal == 0)
{
m_numberOfPlayers = (int)m_rawHeader[13];
@@ -169,7 +169,7 @@ void Kinect::UpdateData()
memcpy(&m_gravityNormal.z, &m_rawHeader[42], 4);
}
retVal = getDynamicControlData(kSkeletonExtraBundleID, m_rawSkeletonExtra, sizeof(m_rawSkeletonExtra), 5);
retVal = HALGetDynamicControlData(kSkeletonExtraBundleID, m_rawSkeletonExtra, sizeof(m_rawSkeletonExtra), 5);
if(retVal == 0)
{
memcpy(&m_position[0].x, &m_rawSkeletonExtra[22], 4);
@@ -179,7 +179,7 @@ void Kinect::UpdateData()
memcpy(&m_trackingState[0], &m_rawSkeletonExtra[38], 4);
}
retVal = getDynamicControlData(kSkeletonBundleID, m_rawSkeleton, sizeof(m_rawSkeleton), 5);
retVal = HALGetDynamicControlData(kSkeletonBundleID, m_rawSkeleton, sizeof(m_rawSkeleton), 5);
if(retVal == 0)
{
for(int i=0; i < Skeleton::JointCount; i++)

View File

@@ -8,15 +8,15 @@
#include "DriverStation.h"
#include "Joystick.h"
#include "NetworkCommunication/FRCComm.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Utility.h"
#include "WPIErrors.h"
uint32_t KinectStick::_recentPacketNumber = 0;
KinectStick::KinectStickData KinectStick::_sticks;
#define kJoystickBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Joystick
#define kJoystickBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick
#define kTriggerMask 1
#define kTopMask 2
@@ -34,7 +34,7 @@ KinectStick::KinectStick(int id)
}
m_id = id;
nUsageReporting::report(nUsageReporting::kResourceType_KinectStick, id);
HALReport(HALUsageReporting::kResourceType_KinectStick, id);
}
/**
@@ -169,7 +169,7 @@ void KinectStick::GetData()
if (_recentPacketNumber != packetNumber)
{
_recentPacketNumber = packetNumber;
int retVal = getDynamicControlData(kJoystickBundleID, _sticks.data, sizeof(_sticks.data), 5);
int retVal = HALGetDynamicControlData(kJoystickBundleID, _sticks.data, sizeof(_sticks.data), 5);
if (retVal == 0)
{
wpi_assert(_sticks.formatted.size == sizeof(_sticks.data) - 1);

View File

@@ -30,7 +30,7 @@ Notifier::Notifier(TimerEventHandler handler, void *param)
m_period = 0;
m_nextEvent = NULL;
m_queued = false;
m_handlerSemaphore = initializeSemaphore(SEMAPHORE_Q_PRIORITY, SEMAPHORE_FULL);
m_handlerSemaphore = initializeSemaphore(SEMAPHORE_FULL);
{
Synchronized sync(queueSemaphore);
// do the first time intialization of static variables
@@ -66,7 +66,7 @@ Notifier::~Notifier()
// Acquire the semaphore; this makes certain that the handler is
// not being executed by the interrupt manager.
takeSemaphore(m_handlerSemaphore, SEMAPHORE_WAIT_FOREVER);
takeSemaphore(m_handlerSemaphore);
// Delete while holding the semaphore so there can be no race.
deleteSemaphore(m_handlerSemaphore);
}
@@ -122,7 +122,7 @@ void Notifier::ProcessQueue(uint32_t mask, void *params)
}
// Take handler semaphore while holding queue semaphore to make sure
// the handler will execute to completion in case we are being deleted.
takeSemaphore(current->m_handlerSemaphore, SEMAPHORE_WAIT_FOREVER);
takeSemaphore(current->m_handlerSemaphore);
}
current->m_handler(current->m_param); // call the event handler

View File

@@ -5,7 +5,7 @@
/*----------------------------------------------------------------------------*/
#include "PIDController.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Notifier.h"
#include "PIDSource.h"
#include "PIDOutput.h"
@@ -63,7 +63,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
{
m_table = NULL;
m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY);
m_semaphore = initializeMutexNormal();
m_controlLoop = new Notifier(PIDController::CallCalculate, this);
@@ -96,7 +96,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
static int32_t instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_PIDController, instances);
HALReport(HALUsageReporting::kResourceType_PIDController, instances);
m_toleranceType = kNoTolerance;
}
@@ -106,7 +106,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
*/
PIDController::~PIDController()
{
takeMutex(m_semaphore, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_semaphore);
deleteMutex(m_semaphore);
delete m_controlLoop;
}

View File

@@ -7,7 +7,7 @@
#include "PWM.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "Utility.h"
#include "WPIErrors.h"
@@ -54,7 +54,7 @@ void PWM::InitPWM(uint8_t moduleNumber, uint32_t channel)
m_module->SetPWM(m_channel, kPwmDisabled);
m_eliminateDeadband = false;
nUsageReporting::report(nUsageReporting::kResourceType_PWM, channel, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_PWM, channel, moduleNumber - 1);
}
/**

View File

@@ -6,7 +6,7 @@
#include "Preferences.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
@@ -36,22 +36,22 @@ Preferences::Preferences() :
m_readTask("PreferencesReadTask", (FUNCPTR)Preferences::InitReadTask),
m_writeTask("PreferencesWriteTask", (FUNCPTR)Preferences::InitWriteTask)
{
m_fileLock = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE);
m_fileOpStarted = initializeSemaphore (SEMAPHORE_Q_PRIORITY, SEMAPHORE_EMPTY);
m_tableLock = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE);
m_fileLock = initializeMutexNormal();
m_fileOpStarted = initializeSemaphore (SEMAPHORE_EMPTY);
m_tableLock = initializeMutexNormal();
Synchronized sync(m_fileLock);
m_readTask.Start((uint32_t)this);
takeSemaphore(m_fileOpStarted, SEMAPHORE_WAIT_FOREVER);
takeSemaphore(m_fileOpStarted);
nUsageReporting::report(nUsageReporting::kResourceType_Preferences, 0);
HALReport(HALUsageReporting::kResourceType_Preferences, 0);
}
Preferences::~Preferences()
{
takeMutex(m_tableLock, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_tableLock);
deleteMutex(m_tableLock);
takeMutex(m_fileLock, SEMAPHORE_WAIT_FOREVER);
takeMutex(m_fileLock);
deleteSemaphore(m_fileOpStarted);
deleteMutex(m_fileLock);
}
@@ -325,7 +325,7 @@ void Preferences::Save()
{
Synchronized sync(m_fileLock);
m_writeTask.Start((uint32_t)this);
takeSemaphore(m_fileOpStarted, SEMAPHORE_WAIT_FOREVER);
takeSemaphore(m_fileOpStarted);
}
/**

View File

@@ -7,7 +7,7 @@
#include "Relay.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Resource.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -50,7 +50,7 @@ void Relay::InitRelay (uint8_t moduleNumber)
return;
}
nUsageReporting::report(nUsageReporting::kResourceType_Relay, m_channel, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_Relay, m_channel, moduleNumber - 1);
}
if (m_direction == kBothDirections || m_direction == kReverseOnly)
{
@@ -61,7 +61,7 @@ void Relay::InitRelay (uint8_t moduleNumber)
return;
}
nUsageReporting::report(nUsageReporting::kResourceType_Relay, m_channel + 128, moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_Relay, m_channel + 128, moduleNumber - 1);
}
m_module = DigitalModule::GetInstance(moduleNumber);
m_module->SetRelayForward(m_channel, false);

View File

@@ -7,9 +7,9 @@
#include "RobotBase.h"
#include "DriverStation.h"
#include "NetworkCommunication/FRCComm.h"
#include "NetworkCommunication/symModuleLink.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/symModuleLink.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Utility.h"
#include <cstring>
#include "HAL/HAL.h"
@@ -192,10 +192,10 @@ void RobotBase::startRobotTask(FUNCPTR factory)
#endif
// Let the framework know that we are starting a new user program so the Driver Station can disable.
FRC_NetworkCommunication_observeUserProgramStarting();
HALNetworkCommunicationObserveUserProgramStarting();
// Let the Usage Reporting framework know that there is a C++ program running
nUsageReporting::report(nUsageReporting::kResourceType_Language, nUsageReporting::kLanguage_CPlusPlus);
HALReport(HALUsageReporting::kResourceType_Language, HALUsageReporting::kLanguage_CPlusPlus);
// Start robot task
// This is done to ensure that the C++ robot task is spawned with the floating point

View File

@@ -10,7 +10,7 @@
#include "GenericHID.h"
#include "Joystick.h"
#include "Jaguar.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Utility.h"
#include "WPIErrors.h"
#include <math.h>
@@ -204,7 +204,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve)
static bool reported = false;
if (!reported)
{
nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_ArcadeRatioCurve);
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_ArcadeRatioCurve);
reported = true;
}
@@ -292,7 +292,7 @@ void RobotDrive::TankDrive(float leftValue, float rightValue, bool squaredInputs
static bool reported = false;
if (!reported)
{
nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_Tank);
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_Tank);
reported = true;
}
@@ -405,7 +405,7 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue, bool squaredInp
static bool reported = false;
if (!reported)
{
nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_ArcadeStandard);
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_ArcadeStandard);
reported = true;
}
@@ -487,7 +487,7 @@ void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation, float
static bool reported = false;
if (!reported)
{
nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_MecanumCartesian);
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_MecanumCartesian);
reported = true;
}
@@ -536,7 +536,7 @@ void RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rota
static bool reported = false;
if (!reported)
{
nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_MecanumPolar);
HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_MecanumPolar);
reported = true;
}

View File

@@ -9,7 +9,7 @@
#include "DigitalModule.h"
#include "DigitalInput.h"
#include "DigitalOutput.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.h"
#include "WPIErrors.h"
@@ -122,7 +122,7 @@ void SPI::Init(DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *miso)
static int32_t instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_SPI, instances);
HALReport(HALUsageReporting::kResourceType_SPI, instances);
}
/**

View File

@@ -6,7 +6,7 @@
#include "SerialPort.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "visa/visa.h"
#include <stdarg.h>
@@ -57,7 +57,7 @@ SerialPort::SerialPort(uint32_t baudRate, uint8_t dataBits, SerialPort::Parity p
//viInstallHandler(m_portHandle, VI_EVENT_IO_COMPLETION, ioCompleteHandler, this);
//viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_NULL);
nUsageReporting::report(nUsageReporting::kResourceType_SerialPort, 0);
HALReport(HALUsageReporting::kResourceType_SerialPort, 0);
}
/**

View File

@@ -6,7 +6,7 @@
#include "Servo.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "LiveWindow/LiveWindow.h"
constexpr float Servo::kMaxServoAngle;
@@ -25,7 +25,7 @@ void Servo::InitServo()
SetPeriodMultiplier(kPeriodMultiplier_4X);
LiveWindow::GetInstance()->AddActuator("Servo", GetModuleNumber(), GetChannel(), this);
nUsageReporting::report(nUsageReporting::kResourceType_Servo, GetChannel(), GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_Servo, GetChannel(), GetModuleNumber() - 1);
}
/**

View File

@@ -7,7 +7,7 @@
#include "SimpleRobot.h"
#include "DriverStation.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Timer.h"
#include "SmartDashboard/SmartDashboard.h"
#include "LiveWindow/LiveWindow.h"
@@ -100,7 +100,7 @@ void SimpleRobot::StartCompetition()
{
LiveWindow *lw = LiveWindow::GetInstance();
nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Simple);
HALReport(HALUsageReporting::kResourceType_Framework, HALUsageReporting::kFramework_Simple);
SmartDashboard::init();
NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);

View File

@@ -6,7 +6,7 @@
#include "SmartDashboard/SmartDashboard.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "SmartDashboard/NamedSendable.h"
#include "WPIErrors.h"
#include "networktables/NetworkTable.h"

View File

@@ -5,7 +5,7 @@
/*----------------------------------------------------------------------------*/
#include "Solenoid.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
@@ -38,7 +38,7 @@ void Solenoid::InitSolenoid()
}
LiveWindow::GetInstance()->AddActuator("Solenoid", m_moduleNumber, m_channel, this);
nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_channel, m_moduleNumber - 1);
HALReport(HALUsageReporting::kResourceType_Solenoid, m_channel, m_moduleNumber - 1);
}
/**

View File

@@ -7,7 +7,7 @@
#include "Talon.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "LiveWindow/LiveWindow.h"
/**
@@ -29,7 +29,7 @@ void Talon::InitTalon() {
SetPeriodMultiplier(kPeriodMultiplier_2X);
SetRaw(m_centerPwm);
nUsageReporting::report(nUsageReporting::kResourceType_Talon, GetChannel(), GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel(), GetModuleNumber() - 1);
LiveWindow::GetInstance()->AddActuator("Talon", GetModuleNumber(), GetChannel(), this);
}

View File

@@ -6,7 +6,7 @@
#include "Task.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include <errno.h>
#include <string.h>
@@ -33,7 +33,7 @@ Task::Task(const char* name, FUNCPTR function, int32_t priority, uint32_t stackS
static int32_t instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_Task, instances, 0, m_taskName);
HALReport(HALUsageReporting::kResourceType_Task, instances, 0, m_taskName);
}
Task::~Task()

View File

@@ -65,7 +65,7 @@ Timer::Timer()
{
//Creates a semaphore to control access to critical regions.
//Initially 'open'
m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
m_semaphore = initializeMutexNormal();
Reset();
}

View File

@@ -9,7 +9,7 @@
#include "Counter.h"
#include "DigitalInput.h"
#include "DigitalOutput.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Timer.h"
#include "Utility.h"
#include "WPIErrors.h"
@@ -58,9 +58,9 @@ void Ultrasonic::Initialize()
{
m_table = NULL;
bool originalMode = m_automaticEnabled;
if (m_semaphore == 0) m_semaphore = initializeSemaphore(SEMAPHORE_Q_PRIORITY, SEMAPHORE_FULL);
if (m_semaphore == 0) m_semaphore = initializeSemaphore(SEMAPHORE_FULL);
SetAutomaticMode(false); // kill task when adding a new sensor
takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER); // link this instance on the list
takeSemaphore(m_semaphore); // link this instance on the list
{
m_nextSensor = m_firstSensor;
m_firstSensor = this;
@@ -77,7 +77,7 @@ void Ultrasonic::Initialize()
static int instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_Ultrasonic, instances);
HALReport(HALUsageReporting::kResourceType_Ultrasonic, instances);
LiveWindow::GetInstance()->AddSensor("Ultrasonic", m_echoChannel->GetModuleForRouting(), m_echoChannel->GetChannel(), this);
}
@@ -176,7 +176,7 @@ Ultrasonic::~Ultrasonic()
}
wpi_assert(m_firstSensor != NULL);
takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER);
takeSemaphore(m_semaphore);
{
if (this == m_firstSensor)
{

View File

@@ -6,7 +6,7 @@
#include "Utility.h"
#include "NetworkCommunication/FRCComm.h"
//#include "NetworkCommunication/FRCComm.h"
#include "HAL/HAL.h"
#include "HAL/cpp/StackTrace.h"
#include "Task.h"
@@ -75,7 +75,7 @@ bool wpi_assert_impl(bool conditionValue,
// Print to console and send to remote dashboard
printf("\n\n>>>>%s", error);
setErrorData(error, strlen(error), 100);
HALSetErrorData(error, strlen(error), 100);
wpi_handleTracing();
if (suspendOnAssertEnabled) suspendTask(0);
@@ -111,7 +111,7 @@ void wpi_assertEqual_common_impl(int valueA,
// Print to console and send to remote dashboard
printf("\n\n>>>>%s", error);
setErrorData(error, strlen(error), 100);
HALSetErrorData(error, strlen(error), 100);
wpi_handleTracing();
if (suspendOnAssertEnabled) suspendTask(0);

View File

@@ -7,7 +7,7 @@
#include "Victor.h"
#include "DigitalModule.h"
#include "NetworkCommunication/UsageReporting.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "LiveWindow/LiveWindow.h"
/**
@@ -32,7 +32,7 @@ void Victor::InitVictor() {
SetRaw(m_centerPwm);
LiveWindow::GetInstance()->AddActuator("Victor", GetModuleNumber(), GetChannel(), this);
nUsageReporting::report(nUsageReporting::kResourceType_Victor, GetChannel(), GetModuleNumber() - 1);
HALReport(HALUsageReporting::kResourceType_Victor, GetChannel(), GetModuleNumber() - 1);
}
/**