merge in new upstream WPILib for 2014 (20130302 update)
diff --git a/aos/externals/WPILib/WPILib/ADXL345_I2C.cpp b/aos/externals/WPILib/WPILib/ADXL345_I2C.cpp
index 2a4040e..9cce2c2 100644
--- a/aos/externals/WPILib/WPILib/ADXL345_I2C.cpp
+++ b/aos/externals/WPILib/WPILib/ADXL345_I2C.cpp
@@ -9,11 +9,11 @@
#include "NetworkCommunication/UsageReporting.h"
#include "I2C.h"
-const UINT8 ADXL345_I2C::kAddress;
-const UINT8 ADXL345_I2C::kPowerCtlRegister;
-const UINT8 ADXL345_I2C::kDataFormatRegister;
-const UINT8 ADXL345_I2C::kDataRegister;
-const double ADXL345_I2C::kGsPerLSB;
+const uint8_t ADXL345_I2C::kAddress;
+const uint8_t ADXL345_I2C::kPowerCtlRegister;
+const uint8_t ADXL345_I2C::kDataFormatRegister;
+const uint8_t ADXL345_I2C::kDataRegister;
+constexpr double ADXL345_I2C::kGsPerLSB;
/**
* Constructor.
@@ -21,7 +21,7 @@
* @param moduleNumber The digital module that the sensor is plugged into (1 or 2).
* @param range The range (+ or -) that the accelerometer will measure.
*/
-ADXL345_I2C::ADXL345_I2C(UINT8 moduleNumber, ADXL345_I2C::DataFormat_Range range)
+ADXL345_I2C::ADXL345_I2C(uint8_t moduleNumber, ADXL345_I2C::DataFormat_Range range)
: m_i2c (NULL)
{
DigitalModule *module = DigitalModule::GetInstance(moduleNumber);
@@ -32,7 +32,7 @@
// Turn on the measurements
m_i2c->Write(kPowerCtlRegister, kPowerCtl_Measure);
// Specify the data format to read
- m_i2c->Write(kDataFormatRegister, kDataFormat_FullRes | (UINT8)range);
+ m_i2c->Write(kDataFormatRegister, kDataFormat_FullRes | (uint8_t)range);
nUsageReporting::report(nUsageReporting::kResourceType_ADXL345, nUsageReporting::kADXL345_I2C, moduleNumber - 1);
}
@@ -55,10 +55,10 @@
*/
double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis)
{
- INT16 rawAccel = 0;
+ int16_t rawAccel = 0;
if(m_i2c)
{
- m_i2c->Read(kDataRegister + (UINT8)axis, sizeof(rawAccel), (UINT8 *)&rawAccel);
+ m_i2c->Read(kDataRegister + (uint8_t)axis, sizeof(rawAccel), (uint8_t *)&rawAccel);
// Sensor is little endian... swap bytes
rawAccel = ((rawAccel >> 8) & 0xFF) | (rawAccel << 8);
@@ -74,13 +74,13 @@
ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations()
{
AllAxes data = {0.0, 0.0, 0.0};
- INT16 rawData[3];
+ int16_t rawData[3];
if (m_i2c)
{
- m_i2c->Read(kDataRegister, sizeof(rawData), (UINT8*)rawData);
+ m_i2c->Read(kDataRegister, sizeof(rawData), (uint8_t*)rawData);
// Sensor is little endian... swap bytes
- for (INT32 i=0; i<3; i++)
+ for (int32_t i=0; i<3; i++)
{
rawData[i] = ((rawData[i] >> 8) & 0xFF) | (rawData[i] << 8);
}
diff --git a/aos/externals/WPILib/WPILib/ADXL345_I2C.h b/aos/externals/WPILib/WPILib/ADXL345_I2C.h
index 295ff3e..8110ee2 100644
--- a/aos/externals/WPILib/WPILib/ADXL345_I2C.h
+++ b/aos/externals/WPILib/WPILib/ADXL345_I2C.h
@@ -20,11 +20,11 @@
class ADXL345_I2C : public SensorBase
{
protected:
- static const UINT8 kAddress = 0x3A;
- static const UINT8 kPowerCtlRegister = 0x2D;
- static const UINT8 kDataFormatRegister = 0x31;
- static const UINT8 kDataRegister = 0x32;
- static const double kGsPerLSB = 0.00390625;
+ static const uint8_t kAddress = 0x3A;
+ static const uint8_t kPowerCtlRegister = 0x2D;
+ static const uint8_t kDataFormatRegister = 0x31;
+ static const uint8_t kDataRegister = 0x32;
+ static constexpr double kGsPerLSB = 0.00390625;
enum PowerCtlFields {kPowerCtl_Link=0x20, kPowerCtl_AutoSleep=0x10, kPowerCtl_Measure=0x08, kPowerCtl_Sleep=0x04};
enum DataFormatFields {kDataFormat_SelfTest=0x80, kDataFormat_SPI=0x40, kDataFormat_IntInvert=0x20,
kDataFormat_FullRes=0x08, kDataFormat_Justify=0x04};
@@ -40,7 +40,7 @@
};
public:
- explicit ADXL345_I2C(UINT8 moduleNumber, DataFormat_Range range=kRange_2G);
+ explicit ADXL345_I2C(uint8_t moduleNumber, DataFormat_Range range=kRange_2G);
virtual ~ADXL345_I2C();
virtual double GetAcceleration(Axes axis);
virtual AllAxes GetAccelerations();
diff --git a/aos/externals/WPILib/WPILib/ADXL345_SPI.cpp b/aos/externals/WPILib/WPILib/ADXL345_SPI.cpp
index 42d8dea..8d279b0 100644
--- a/aos/externals/WPILib/WPILib/ADXL345_SPI.cpp
+++ b/aos/externals/WPILib/WPILib/ADXL345_SPI.cpp
@@ -10,10 +10,10 @@
#include "NetworkCommunication/UsageReporting.h"
#include "SPI.h"
-const UINT8 ADXL345_SPI::kPowerCtlRegister;
-const UINT8 ADXL345_SPI::kDataFormatRegister;
-const UINT8 ADXL345_SPI::kDataRegister;
-const double ADXL345_SPI::kGsPerLSB;
+const uint8_t ADXL345_SPI::kPowerCtlRegister;
+const uint8_t ADXL345_SPI::kDataFormatRegister;
+const uint8_t ADXL345_SPI::kDataRegister;
+constexpr double ADXL345_SPI::kGsPerLSB;
/**
* Constructor.
@@ -65,8 +65,8 @@
* @param cs The GPIO the CS (Chip Select) signal is wired to.
* @param range The range (+ or -) that the accelerometer will measure.
*/
-ADXL345_SPI::ADXL345_SPI(UINT8 moduleNumber, UINT32 clk, UINT32 mosi, UINT32 miso,
- UINT32 cs, ADXL345_SPI::DataFormat_Range range)
+ADXL345_SPI::ADXL345_SPI(uint8_t moduleNumber, uint32_t clk, uint32_t mosi, uint32_t miso,
+ uint32_t cs, ADXL345_SPI::DataFormat_Range range)
: m_clk (NULL)
, m_mosi (NULL)
, m_miso (NULL)
@@ -102,7 +102,7 @@
m_spi->Write((kPowerCtlRegister << 8) | kPowerCtl_Measure);
m_spi->Read();
// Specify the data format to read
- m_spi->Write((kDataFormatRegister << 8) | kDataFormat_FullRes | (UINT8)(range & 0x03));
+ m_spi->Write((kDataFormatRegister << 8) | kDataFormat_FullRes | (uint8_t)(range & 0x03));
m_spi->Read();
// 8-bit address and 16-bit data
@@ -138,11 +138,11 @@
*/
double ADXL345_SPI::GetAcceleration(ADXL345_SPI::Axes axis)
{
- INT16 rawAccel = 0;
+ int16_t rawAccel = 0;
if(m_spi)
{
- m_spi->Write(((kAddress_Read | kAddress_MultiByte | kDataRegister) + (UINT8)axis) << 16);
- rawAccel = (UINT16)m_spi->Read();
+ m_spi->Write(((kAddress_Read | kAddress_MultiByte | kDataRegister) + (uint8_t)axis) << 16);
+ rawAccel = (uint16_t)m_spi->Read();
// Sensor is little endian... swap bytes
rawAccel = ((rawAccel >> 8) & 0xFF) | (rawAccel << 8);
@@ -158,7 +158,7 @@
ADXL345_SPI::AllAxes ADXL345_SPI::GetAccelerations()
{
AllAxes data = {0.0, 0.0, 0.0};
- INT16 rawData[3];
+ int16_t rawData[3];
if (m_spi)
{
SPI::tFrameMode mode;
@@ -166,7 +166,7 @@
// Backup original settings.
DigitalOutput *cs = m_spi->GetSlaveSelect(&mode, &activeLow);
- UINT32 bitsPerWord = m_spi->GetBitsPerWord();
+ uint32_t bitsPerWord = m_spi->GetBitsPerWord();
// Initialize the chip select to inactive.
cs->Set(activeLow);
@@ -188,10 +188,10 @@
m_spi->SetBitsPerWord(16);
m_spi->ApplyConfig();
- for (INT32 i=0; i<3; i++)
+ for (int32_t i=0; i<3; i++)
{
// SPI Interface can't read enough data in a single transaction to read all axes at once.
- rawData[i] = (UINT16)m_spi->Read(true);
+ rawData[i] = (uint16_t)m_spi->Read(true);
// Sensor is little endian... swap bytes
rawData[i] = ((rawData[i] >> 8) & 0xFF) | (rawData[i] << 8);
}
diff --git a/aos/externals/WPILib/WPILib/ADXL345_SPI.h b/aos/externals/WPILib/WPILib/ADXL345_SPI.h
index ab8ebde..3e8a308 100644
--- a/aos/externals/WPILib/WPILib/ADXL345_SPI.h
+++ b/aos/externals/WPILib/WPILib/ADXL345_SPI.h
@@ -22,10 +22,10 @@
class ADXL345_SPI : public SensorBase
{
protected:
- static const UINT8 kPowerCtlRegister = 0x2D;
- static const UINT8 kDataFormatRegister = 0x31;
- static const UINT8 kDataRegister = 0x32;
- static const double kGsPerLSB = 0.00390625;
+ static const uint8_t kPowerCtlRegister = 0x2D;
+ static const uint8_t kDataFormatRegister = 0x31;
+ static const uint8_t kDataRegister = 0x32;
+ static constexpr double kGsPerLSB = 0.00390625;
enum SPIAddressFields {kAddress_Read=0x80, kAddress_MultiByte=0x40};
enum PowerCtlFields {kPowerCtl_Link=0x20, kPowerCtl_AutoSleep=0x10, kPowerCtl_Measure=0x08, kPowerCtl_Sleep=0x04};
enum DataFormatFields {kDataFormat_SelfTest=0x80, kDataFormat_SPI=0x40, kDataFormat_IntInvert=0x20,
@@ -46,7 +46,7 @@
DigitalOutput &cs, DataFormat_Range range=kRange_2G);
ADXL345_SPI(DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *miso,
DigitalOutput *cs, DataFormat_Range range=kRange_2G);
- ADXL345_SPI(UINT8 moduleNumber, UINT32 clk, UINT32 mosi, UINT32 miso, UINT32 cs,
+ ADXL345_SPI(uint8_t moduleNumber, uint32_t clk, uint32_t mosi, uint32_t miso, uint32_t cs,
DataFormat_Range range=kRange_2G);
virtual ~ADXL345_SPI();
virtual double GetAcceleration(Axes axis);
diff --git a/aos/externals/WPILib/WPILib/Accelerometer.cpp b/aos/externals/WPILib/WPILib/Accelerometer.cpp
index de8d05d..94bf6fa 100644
--- a/aos/externals/WPILib/WPILib/Accelerometer.cpp
+++ b/aos/externals/WPILib/WPILib/Accelerometer.cpp
@@ -15,6 +15,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);
@@ -27,7 +28,7 @@
* The accelerometer is assumed to be in the first analog module in the given analog channel. The
* constructor allocates desired analog channel.
*/
-Accelerometer::Accelerometer(UINT32 channel)
+Accelerometer::Accelerometer(uint32_t channel)
{
m_analogChannel = new AnalogChannel(channel);
m_allocatedChannel = true;
@@ -43,7 +44,7 @@
* @param moduleNumber The analog module (1 or 2).
* @param channel The analog channel (1..8)
*/
-Accelerometer::Accelerometer(UINT8 moduleNumber, UINT32 channel)
+Accelerometer::Accelerometer(uint8_t moduleNumber, uint32_t channel)
{
m_analogChannel = new AnalogChannel(moduleNumber, channel);
m_allocatedChannel = true;
diff --git a/aos/externals/WPILib/WPILib/Accelerometer.h b/aos/externals/WPILib/WPILib/Accelerometer.h
index 92f9619..10605a2 100644
--- a/aos/externals/WPILib/WPILib/Accelerometer.h
+++ b/aos/externals/WPILib/WPILib/Accelerometer.h
@@ -20,8 +20,8 @@
*/
class Accelerometer : public SensorBase, public PIDSource, public LiveWindowSendable {
public:
- explicit Accelerometer(UINT32 channel);
- Accelerometer(UINT8 moduleNumber, UINT32 channel);
+ explicit Accelerometer(uint32_t channel);
+ Accelerometer(uint8_t moduleNumber, uint32_t channel);
explicit Accelerometer(AnalogChannel *channel);
virtual ~Accelerometer();
diff --git a/aos/externals/WPILib/WPILib/AnalogChannel.cpp b/aos/externals/WPILib/WPILib/AnalogChannel.cpp
index 26708c1..d8b55ff 100644
--- a/aos/externals/WPILib/WPILib/AnalogChannel.cpp
+++ b/aos/externals/WPILib/WPILib/AnalogChannel.cpp
@@ -13,15 +13,16 @@
static Resource *channels = NULL;
-const UINT8 AnalogChannel::kAccumulatorModuleNumber;
-const UINT32 AnalogChannel::kAccumulatorNumChannels;
-const UINT32 AnalogChannel::kAccumulatorChannels[] = {1, 2};
+const uint8_t AnalogChannel::kAccumulatorModuleNumber;
+const uint32_t AnalogChannel::kAccumulatorNumChannels;
+const uint32_t AnalogChannel::kAccumulatorChannels[] = {1, 2};
/**
* Common initialization.
*/
-void AnalogChannel::InitChannel(UINT8 moduleNumber, UINT32 channel)
+void AnalogChannel::InitChannel(uint8_t moduleNumber, uint32_t channel)
{
+ m_table = NULL;
char buf[64];
Resource::CreateResourceObject(&channels, kAnalogModules * kAnalogChannels);
if (!CheckAnalogModule(moduleNumber))
@@ -56,7 +57,8 @@
{
m_accumulator = NULL;
}
- LiveWindow::GetInstance()->AddActuator("AnalogChannel",channel, GetModuleNumber(), this);
+ m_shouldUseVoltageForPID = false;
+ LiveWindow::GetInstance()->AddSensor("AnalogChannel",channel, GetModuleNumber(), this);
nUsageReporting::report(nUsageReporting::kResourceType_AnalogChannel, channel, GetModuleNumber() - 1);
}
@@ -66,7 +68,7 @@
* @param moduleNumber The analog module (1 or 2).
* @param channel The channel number to represent.
*/
-AnalogChannel::AnalogChannel(UINT8 moduleNumber, UINT32 channel)
+AnalogChannel::AnalogChannel(uint8_t moduleNumber, uint32_t channel)
{
InitChannel(moduleNumber, channel);
}
@@ -76,7 +78,7 @@
*
* @param channel The channel number to represent.
*/
-AnalogChannel::AnalogChannel(UINT32 channel)
+AnalogChannel::AnalogChannel(uint32_t channel)
{
InitChannel(GetDefaultAnalogModule(), channel);
}
@@ -106,7 +108,7 @@
* The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.
* @return A sample straight from this channel on the module.
*/
-INT16 AnalogChannel::GetValue()
+int16_t AnalogChannel::GetValue()
{
if (StatusIsFatal()) return 0;
return m_module->GetValue(m_channel);
@@ -121,7 +123,7 @@
* Use GetAverageVoltage() to get the analog value in calibrated units.
* @return A sample from the oversample and average engine for this channel.
*/
-INT32 AnalogChannel::GetAverageValue()
+int32_t AnalogChannel::GetAverageValue()
{
if (StatusIsFatal()) return 0;
return m_module->GetAverageValue(m_channel);
@@ -160,7 +162,7 @@
*
* @return Least significant bit weight.
*/
-UINT32 AnalogChannel::GetLSBWeight()
+uint32_t AnalogChannel::GetLSBWeight()
{
if (StatusIsFatal()) return 0;
return m_module->GetLSBWeight(m_channel);
@@ -175,7 +177,7 @@
*
* @return Offset constant.
*/
-INT32 AnalogChannel::GetOffset()
+int32_t AnalogChannel::GetOffset()
{
if (StatusIsFatal()) return 0;
return m_module->GetOffset(m_channel);
@@ -185,7 +187,7 @@
* Get the channel number.
* @return The channel number.
*/
-UINT32 AnalogChannel::GetChannel()
+uint32_t AnalogChannel::GetChannel()
{
if (StatusIsFatal()) return 0;
return m_channel;
@@ -195,7 +197,7 @@
* Get the module number.
* @return The module number.
*/
-UINT8 AnalogChannel::GetModuleNumber()
+uint8_t AnalogChannel::GetModuleNumber()
{
if (StatusIsFatal()) return 0;
return m_module->GetNumber();
@@ -209,7 +211,7 @@
*
* @param bits Number of bits of averaging.
*/
-void AnalogChannel::SetAverageBits(UINT32 bits)
+void AnalogChannel::SetAverageBits(uint32_t bits)
{
if (StatusIsFatal()) return;
m_module->SetAverageBits(m_channel, bits);
@@ -222,7 +224,7 @@
*
* @return Number of bits of averaging previously configured.
*/
-UINT32 AnalogChannel::GetAverageBits()
+uint32_t AnalogChannel::GetAverageBits()
{
if (StatusIsFatal()) return 0;
return m_module->GetAverageBits(m_channel);
@@ -236,7 +238,7 @@
*
* @param bits Number of bits of oversampling.
*/
-void AnalogChannel::SetOversampleBits(UINT32 bits)
+void AnalogChannel::SetOversampleBits(uint32_t bits)
{
if (StatusIsFatal()) return;
m_module->SetOversampleBits(m_channel, bits);
@@ -249,7 +251,7 @@
*
* @return Number of bits of oversampling previously configured.
*/
-UINT32 AnalogChannel::GetOversampleBits()
+uint32_t AnalogChannel::GetOversampleBits()
{
if (StatusIsFatal()) return 0;
return m_module->GetOversampleBits(m_channel);
@@ -264,7 +266,7 @@
{
if (StatusIsFatal()) return false;
if(m_module->GetNumber() != kAccumulatorModuleNumber) return false;
- for (UINT32 i=0; i<kAccumulatorNumChannels; i++)
+ for (uint32_t i=0; i<kAccumulatorNumChannels; i++)
{
if (m_channel == kAccumulatorChannels[i]) return true;
}
@@ -289,7 +291,7 @@
* This will be added to all values returned to the user.
* @param initialValue The value that the accumulator should start from when reset.
*/
-void AnalogChannel::SetAccumulatorInitialValue(INT64 initialValue)
+void AnalogChannel::SetAccumulatorInitialValue(int64_t initialValue)
{
if (StatusIsFatal()) return;
m_accumulatorOffset = initialValue;
@@ -321,7 +323,7 @@
* This center value is based on the output of the oversampled and averaged source from channel 1.
* Because of this, any non-zero oversample bits will affect the size of the value for this field.
*/
-void AnalogChannel::SetAccumulatorCenter(INT32 center)
+void AnalogChannel::SetAccumulatorCenter(int32_t center)
{
if (StatusIsFatal()) return;
if (m_accumulator == NULL)
@@ -337,7 +339,7 @@
/**
* Set the accumulator's deadband.
*/
-void AnalogChannel::SetAccumulatorDeadband(INT32 deadband)
+void AnalogChannel::SetAccumulatorDeadband(int32_t deadband)
{
if (StatusIsFatal()) return;
if (m_accumulator == NULL)
@@ -358,7 +360,7 @@
*
* @return The 64-bit value accumulated since the last Reset().
*/
-INT64 AnalogChannel::GetAccumulatorValue()
+int64_t AnalogChannel::GetAccumulatorValue()
{
if (StatusIsFatal()) return 0;
if (m_accumulator == NULL)
@@ -367,7 +369,7 @@
return 0;
}
tRioStatusCode localStatus = NiFpga_Status_Success;
- INT64 value = m_accumulator->readOutput_Value(&localStatus) + m_accumulatorOffset;
+ int64_t value = m_accumulator->readOutput_Value(&localStatus) + m_accumulatorOffset;
wpi_setError(localStatus);
return value;
}
@@ -379,7 +381,7 @@
*
* @return The number of times samples from the channel were accumulated.
*/
-UINT32 AnalogChannel::GetAccumulatorCount()
+uint32_t AnalogChannel::GetAccumulatorCount()
{
if (StatusIsFatal()) return 0;
if (m_accumulator == NULL)
@@ -388,7 +390,7 @@
return 0;
}
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 count = m_accumulator->readOutput_Count(&localStatus);
+ uint32_t count = m_accumulator->readOutput_Count(&localStatus);
wpi_setError(localStatus);
return count;
}
@@ -403,7 +405,7 @@
* @param value Pointer to the 64-bit accumulated output.
* @param count Pointer to the number of accumulation cycles.
*/
-void AnalogChannel::GetAccumulatorOutput(INT64 *value, UINT32 *count)
+void AnalogChannel::GetAccumulatorOutput(int64_t *value, uint32_t *count)
{
if (StatusIsFatal()) return;
if (m_accumulator == NULL)
@@ -425,14 +427,30 @@
}
/**
- * Get the Average voltage for the PID Source base object.
+ * Set whether to use voltage or value for PIDGet.
+ * This method determines whether PIDGet should use average voltage
+ * or value for PIDControllers for a particular channel. This is to
+ * preserve compatibility with existng programs and is likely to change
+ * in favor of voltage for 2015 and beyond.
+ * @param shouldUseVoltageForPID true if voltage should be used for PIDGet.
+ */
+void AnalogChannel::SetVoltageForPID(bool shouldUseVoltageForPID) {
+ m_shouldUseVoltageForPID = shouldUseVoltageForPID;
+}
+
+/**
+ * Get the Average value for the PID Source base object.
*
* @return The average voltage.
*/
double AnalogChannel::PIDGet()
{
if (StatusIsFatal()) return 0.0;
- return GetAverageValue();
+ if (m_shouldUseVoltageForPID) {
+ return GetAverageVoltage();
+ } else {
+ return GetAverageValue();
+ }
}
void AnalogChannel::UpdateTable() {
diff --git a/aos/externals/WPILib/WPILib/AnalogChannel.h b/aos/externals/WPILib/WPILib/AnalogChannel.h
index ab860d4..153640a 100644
--- a/aos/externals/WPILib/WPILib/AnalogChannel.h
+++ b/aos/externals/WPILib/WPILib/AnalogChannel.h
@@ -29,42 +29,43 @@
class AnalogChannel : public SensorBase, public PIDSource, public LiveWindowSendable
{
public:
- static const UINT8 kAccumulatorModuleNumber = 1;
- static const UINT32 kAccumulatorNumChannels = 2;
- static const UINT32 kAccumulatorChannels[kAccumulatorNumChannels];
+ static const uint8_t kAccumulatorModuleNumber = 1;
+ static const uint32_t kAccumulatorNumChannels = 2;
+ static const uint32_t kAccumulatorChannels[kAccumulatorNumChannels];
- AnalogChannel(UINT8 moduleNumber, UINT32 channel);
- explicit AnalogChannel(UINT32 channel);
+ AnalogChannel(uint8_t moduleNumber, uint32_t channel);
+ explicit AnalogChannel(uint32_t channel);
virtual ~AnalogChannel();
AnalogModule *GetModule();
- INT16 GetValue();
- INT32 GetAverageValue();
+ int16_t GetValue();
+ int32_t GetAverageValue();
float GetVoltage();
float GetAverageVoltage();
- UINT8 GetModuleNumber();
- UINT32 GetChannel();
+ uint8_t GetModuleNumber();
+ uint32_t GetChannel();
- void SetAverageBits(UINT32 bits);
- UINT32 GetAverageBits();
- void SetOversampleBits(UINT32 bits);
- UINT32 GetOversampleBits();
+ void SetAverageBits(uint32_t bits);
+ uint32_t GetAverageBits();
+ void SetOversampleBits(uint32_t bits);
+ uint32_t GetOversampleBits();
- UINT32 GetLSBWeight();
- INT32 GetOffset();
+ uint32_t GetLSBWeight();
+ int32_t GetOffset();
bool IsAccumulatorChannel();
void InitAccumulator();
- void SetAccumulatorInitialValue(INT64 value);
+ void SetAccumulatorInitialValue(int64_t value);
void ResetAccumulator();
- void SetAccumulatorCenter(INT32 center);
- void SetAccumulatorDeadband(INT32 deadband);
- INT64 GetAccumulatorValue();
- UINT32 GetAccumulatorCount();
- void GetAccumulatorOutput(INT64 *value, UINT32 *count);
+ void SetAccumulatorCenter(int32_t center);
+ void SetAccumulatorDeadband(int32_t deadband);
+ int64_t GetAccumulatorValue();
+ uint32_t GetAccumulatorCount();
+ void GetAccumulatorOutput(int64_t *value, uint32_t *count);
+ void SetVoltageForPID(bool shouldUseVoltageForPID);
double PIDGet();
@@ -76,11 +77,12 @@
ITable * GetTable();
private:
- void InitChannel(UINT8 moduleNumber, UINT32 channel);
- UINT32 m_channel;
+ void InitChannel(uint8_t moduleNumber, uint32_t channel);
+ uint32_t m_channel;
AnalogModule *m_module;
tAccumulator *m_accumulator;
- INT64 m_accumulatorOffset;
+ int64_t m_accumulatorOffset;
+ bool m_shouldUseVoltageForPID;
ITable *m_table;
};
diff --git a/aos/externals/WPILib/WPILib/AnalogModule.cpp b/aos/externals/WPILib/WPILib/AnalogModule.cpp
index 68e7940..9fd829b 100644
--- a/aos/externals/WPILib/WPILib/AnalogModule.cpp
+++ b/aos/externals/WPILib/WPILib/AnalogModule.cpp
@@ -13,7 +13,7 @@
const long AnalogModule::kTimebase; ///< 40 MHz clock
const long AnalogModule::kDefaultOversampleBits;
const long AnalogModule::kDefaultAverageBits;
-const float AnalogModule::kDefaultSampleRate;
+constexpr float AnalogModule::kDefaultSampleRate;
// Needs to be global since the protected resource spans both module singletons.
ReentrantSemaphore AnalogModule::m_registerWindowSemaphore;
@@ -26,7 +26,7 @@
* @param moduleNumber The analog module to get (1 or 2).
* @return A pointer to the AnalogModule.
*/
-AnalogModule* AnalogModule::GetInstance(UINT8 moduleNumber)
+AnalogModule* AnalogModule::GetInstance(uint8_t moduleNumber)
{
if (CheckAnalogModule(moduleNumber))
{
@@ -52,7 +52,7 @@
*
* @param moduleNumber The analog module to create (1 or 2).
*/
-AnalogModule::AnalogModule(UINT8 moduleNumber)
+AnalogModule::AnalogModule(uint8_t moduleNumber)
: Module(nLoadOut::kModuleType_Analog, moduleNumber)
, m_module (NULL)
, m_sampleRateSet (false)
@@ -65,7 +65,7 @@
SetNumChannelsToActivate(kAnalogChannels);
SetSampleRate(kDefaultSampleRate);
- for (UINT32 i = 0; i < kAnalogChannels; i++)
+ for (uint32_t i = 0; i < kAnalogChannels; i++)
{
m_module->writeScanList(i, i, &localStatus);
wpi_setError(localStatus);
@@ -97,8 +97,8 @@
m_sampleRateSet = true;
// Compute the convert rate
- UINT32 ticksPerSample = (UINT32)((float)kTimebase / samplesPerSecond);
- UINT32 ticksPerConversion = ticksPerSample / GetNumChannelsToActivate();
+ uint32_t ticksPerSample = (uint32_t)((float)kTimebase / samplesPerSecond);
+ uint32_t ticksPerConversion = ticksPerSample / GetNumChannelsToActivate();
// ticksPerConversion must be at least 80
if (ticksPerConversion < 80)
{
@@ -129,9 +129,9 @@
float AnalogModule::GetSampleRate()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 ticksPerConversion = m_module->readLoopTiming(&localStatus);
+ uint32_t ticksPerConversion = m_module->readLoopTiming(&localStatus);
wpi_setError(localStatus);
- UINT32 ticksPerSample = ticksPerConversion * GetNumActiveChannels();
+ uint32_t ticksPerSample = ticksPerConversion * GetNumActiveChannels();
return (float)kTimebase / (float)ticksPerSample;
}
@@ -140,10 +140,10 @@
*
* @return Active channels.
*/
-UINT32 AnalogModule::GetNumActiveChannels()
+uint32_t AnalogModule::GetNumActiveChannels()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 scanSize = m_module->readConfig_ScanSize(&localStatus);
+ uint32_t scanSize = m_module->readConfig_ScanSize(&localStatus);
wpi_setError(localStatus);
if (scanSize == 0)
return 8;
@@ -161,7 +161,7 @@
*
* @return Value to write to the active channels field.
*/
-UINT32 AnalogModule::GetNumChannelsToActivate()
+uint32_t AnalogModule::GetNumChannelsToActivate()
{
if(m_numChannelsToActivate == 0) return GetNumActiveChannels();
return m_numChannelsToActivate;
@@ -175,7 +175,7 @@
*
* @param channels Number of active channels.
*/
-void AnalogModule::SetNumChannelsToActivate(UINT32 channels)
+void AnalogModule::SetNumChannelsToActivate(uint32_t channels)
{
m_numChannelsToActivate = channels;
}
@@ -190,7 +190,7 @@
* @param channel Analog channel to configure.
* @param bits Number of bits to average.
*/
-void AnalogModule::SetAverageBits(UINT32 channel, UINT32 bits)
+void AnalogModule::SetAverageBits(uint32_t channel, uint32_t bits)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
m_module->writeAverageBits(channel - 1, bits, &localStatus);
@@ -206,10 +206,10 @@
* @param channel Channel to address.
* @return Bits to average.
*/
-UINT32 AnalogModule::GetAverageBits(UINT32 channel)
+uint32_t AnalogModule::GetAverageBits(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 result = m_module->readAverageBits(channel - 1, &localStatus);
+ uint32_t result = m_module->readAverageBits(channel - 1, &localStatus);
wpi_setError(localStatus);
return result;
}
@@ -224,7 +224,7 @@
* @param channel Analog channel to configure.
* @param bits Number of bits to oversample.
*/
-void AnalogModule::SetOversampleBits(UINT32 channel, UINT32 bits)
+void AnalogModule::SetOversampleBits(uint32_t channel, uint32_t bits)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
m_module->writeOversampleBits(channel - 1, bits, &localStatus);
@@ -240,10 +240,10 @@
* @param channel Channel to address.
* @return Bits to oversample.
*/
-UINT32 AnalogModule::GetOversampleBits(UINT32 channel)
+uint32_t AnalogModule::GetOversampleBits(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 result = m_module->readOversampleBits(channel - 1, &localStatus);
+ uint32_t result = m_module->readOversampleBits(channel - 1, &localStatus);
wpi_setError(localStatus);
return result;
}
@@ -256,9 +256,9 @@
*
* @return A sample straight from the channel on this module.
*/
-INT16 AnalogModule::GetValue(UINT32 channel)
+int16_t AnalogModule::GetValue(uint32_t channel)
{
- INT16 value;
+ int16_t value;
CheckAnalogChannel(channel);
tAI::tReadSelect readSelect;
@@ -271,7 +271,7 @@
Synchronized sync(m_registerWindowSemaphore);
m_module->writeReadSelect(readSelect, &localStatus);
m_module->strobeLatchOutput(&localStatus);
- value = (INT16) m_module->readOutput(&localStatus);
+ value = (int16_t) m_module->readOutput(&localStatus);
}
wpi_setError(localStatus);
@@ -290,9 +290,9 @@
* @param channel Channel number to read.
* @return A sample from the oversample and average engine for the channel.
*/
-INT32 AnalogModule::GetAverageValue(UINT32 channel)
+int32_t AnalogModule::GetAverageValue(uint32_t channel)
{
- INT32 value;
+ int32_t value;
CheckAnalogChannel(channel);
tAI::tReadSelect readSelect;
@@ -324,7 +324,7 @@
* @param voltage The voltage to convert.
* @return The raw value for the channel.
*/
-INT32 AnalogModule::VoltsToValue(INT32 channel, float voltage)
+int32_t AnalogModule::VoltsToValue(int32_t channel, float voltage)
{
if (voltage > 10.0)
{
@@ -336,9 +336,9 @@
voltage = -10.0;
wpi_setWPIError(VoltageOutOfRange);
}
- UINT32 LSBWeight = GetLSBWeight(channel);
- INT32 offset = GetOffset(channel);
- INT32 value = (INT32) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9));
+ uint32_t LSBWeight = GetLSBWeight(channel);
+ int32_t offset = GetOffset(channel);
+ int32_t value = (int32_t) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9));
return value;
}
@@ -350,11 +350,11 @@
* @param channel The channel to read.
* @return A scaled sample straight from the channel on this module.
*/
-float AnalogModule::GetVoltage(UINT32 channel)
+float AnalogModule::GetVoltage(uint32_t channel)
{
- INT16 value = GetValue(channel);
- UINT32 LSBWeight = GetLSBWeight(channel);
- INT32 offset = GetOffset(channel);
+ int16_t value = GetValue(channel);
+ uint32_t LSBWeight = GetLSBWeight(channel);
+ int32_t offset = GetOffset(channel);
float voltage = LSBWeight * 1.0e-9 * value - offset * 1.0e-9;
return voltage;
}
@@ -369,12 +369,12 @@
* @param channel The channel to read.
* @return A scaled sample from the output of the oversample and average engine for the channel.
*/
-float AnalogModule::GetAverageVoltage(UINT32 channel)
+float AnalogModule::GetAverageVoltage(uint32_t channel)
{
- INT32 value = GetAverageValue(channel);
- UINT32 LSBWeight = GetLSBWeight(channel);
- INT32 offset = GetOffset(channel);
- UINT32 oversampleBits = GetOversampleBits(channel);
+ int32_t value = GetAverageValue(channel);
+ uint32_t LSBWeight = GetLSBWeight(channel);
+ int32_t offset = GetOffset(channel);
+ uint32_t oversampleBits = GetOversampleBits(channel);
float voltage = ((LSBWeight * 1.0e-9 * value) / (float)(1 << oversampleBits)) - offset * 1.0e-9;
return voltage;
}
@@ -389,10 +389,10 @@
* @param channel The channel to get calibration data for.
* @return Least significant bit weight.
*/
-UINT32 AnalogModule::GetLSBWeight(UINT32 channel)
+uint32_t AnalogModule::GetLSBWeight(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(m_module->getSystemIndex(), channel - 1, (INT32*)&localStatus);
+ uint32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(m_module->getSystemIndex(), channel - 1, (int32_t*)&localStatus);
wpi_setError(localStatus);
return lsbWeight;
}
@@ -407,10 +407,10 @@
* @param channel The channel to get calibration data for.
* @return Offset constant.
*/
-INT32 AnalogModule::GetOffset(UINT32 channel)
+int32_t AnalogModule::GetOffset(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- INT32 offset = FRC_NetworkCommunication_nAICalibration_getOffset(m_module->getSystemIndex(), channel - 1, (INT32*)&localStatus);
+ int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(m_module->getSystemIndex(), channel - 1, (int32_t*)&localStatus);
wpi_setError(localStatus);
return offset;
}
diff --git a/aos/externals/WPILib/WPILib/AnalogModule.h b/aos/externals/WPILib/WPILib/AnalogModule.h
index 3ed44ca..9b98c60 100644
--- a/aos/externals/WPILib/WPILib/AnalogModule.h
+++ b/aos/externals/WPILib/WPILib/AnalogModule.h
@@ -25,38 +25,38 @@
static const long kTimebase = 40000000; ///< 40 MHz clock
static const long kDefaultOversampleBits = 0;
static const long kDefaultAverageBits = 7;
- static const float kDefaultSampleRate = 50000.0;
+ static constexpr float kDefaultSampleRate = 50000.0;
void SetSampleRate(float samplesPerSecond);
float GetSampleRate();
- void SetAverageBits(UINT32 channel, UINT32 bits);
- UINT32 GetAverageBits(UINT32 channel);
- void SetOversampleBits(UINT32 channel, UINT32 bits);
- UINT32 GetOversampleBits(UINT32 channel);
- INT16 GetValue(UINT32 channel);
- INT32 GetAverageValue(UINT32 channel);
- float GetAverageVoltage(UINT32 channel);
- float GetVoltage(UINT32 channel);
- UINT32 GetLSBWeight(UINT32 channel);
- INT32 GetOffset(UINT32 channel);
- INT32 VoltsToValue(INT32 channel, float voltage);
+ void SetAverageBits(uint32_t channel, uint32_t bits);
+ uint32_t GetAverageBits(uint32_t channel);
+ void SetOversampleBits(uint32_t channel, uint32_t bits);
+ uint32_t GetOversampleBits(uint32_t channel);
+ int16_t GetValue(uint32_t channel);
+ int32_t GetAverageValue(uint32_t channel);
+ float GetAverageVoltage(uint32_t channel);
+ float GetVoltage(uint32_t channel);
+ uint32_t GetLSBWeight(uint32_t channel);
+ int32_t GetOffset(uint32_t channel);
+ int32_t VoltsToValue(int32_t channel, float voltage);
- static AnalogModule* GetInstance(UINT8 moduleNumber);
+ static AnalogModule* GetInstance(uint8_t moduleNumber);
protected:
- explicit AnalogModule(UINT8 moduleNumber);
+ explicit AnalogModule(uint8_t moduleNumber);
virtual ~AnalogModule();
private:
static ReentrantSemaphore m_registerWindowSemaphore;
- UINT32 GetNumActiveChannels();
- UINT32 GetNumChannelsToActivate();
- void SetNumChannelsToActivate(UINT32 channels);
+ uint32_t GetNumActiveChannels();
+ uint32_t GetNumChannelsToActivate();
+ void SetNumChannelsToActivate(uint32_t channels);
tAI *m_module;
bool m_sampleRateSet;
- UINT32 m_numChannelsToActivate;
+ uint32_t m_numChannelsToActivate;
};
#endif
diff --git a/aos/externals/WPILib/WPILib/AnalogPotentiometer.cpp b/aos/externals/WPILib/WPILib/AnalogPotentiometer.cpp
new file mode 100644
index 0000000..fc43ce4
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/AnalogPotentiometer.cpp
@@ -0,0 +1,144 @@
+#include "AnalogPotentiometer.h"
+
+/**
+ * Class for reading analog potentiometers. Analog potentiometers read
+ * in an analog voltage that corresponds to a position. Usually the
+ * position is either degrees or meters. However, if no conversion is
+ * given it remains volts.
+ *
+ */
+ void AnalogPotentiometer::InitPot(int slot, int channel, double scale, double offset) {
+ m_module = slot;
+ m_channel = channel;
+ m_scale = scale;
+ m_offset = offset;
+ m_analog_channel = new AnalogChannel(slot, channel);
+ }
+
+ /**
+ * AnalogPotentiometer constructor.
+ *
+ * Use the scaling and offset values so that the output produces
+ * meaningful values. I.E: you have a 270 degree potentiometer and
+ * you want the output to be degrees with the halfway point as 0
+ * degrees. The scale value is 270.0(degrees)/5.0(volts) and the
+ * offset is -135.0 since the halfway point after scaling is 135
+ * degrees.
+ *
+ * @param slot The analog module this potentiometer is plugged into.
+ * @param channel The analog channel this potentiometer is plugged into.
+ * @param scale The scaling to multiply the voltage by to get a meaningful unit.
+ * @param offset The offset to add to the scaled value for controlling the zero value
+ */
+ AnalogPotentiometer::AnalogPotentiometer(int slot, int channel, double scale, double offset) {
+ InitPot(slot, channel, scale, offset);
+ }
+
+ /**
+ * AnalogPotentiometer constructor.
+ *
+ * Use the scaling and offset values so that the output produces
+ * meaningful values. I.E: you have a 270 degree potentiometer and
+ * you want the output to be degrees with the halfway point as 0
+ * degrees. The scale value is 270.0(degrees)/5.0(volts) and the
+ * offset is -135.0 since the halfway point after scaling is 135
+ * degrees.
+ *
+ * @param channel The analog channel this potentiometer is plugged into.
+ * @param scale The scaling to multiply the voltage by to get a meaningful unit.
+ * @param offset The offset to add to the scaled value for controlling the zero value
+ */
+ AnalogPotentiometer::AnalogPotentiometer(int channel, double scale, double offset) {
+ InitPot(1, channel, scale, offset);
+ }
+
+ /**
+ * AnalogPotentiometer constructor.
+ *
+ * Use the scaling and offset values so that the output produces
+ * meaningful values. I.E: you have a 270 degree potentiometer and
+ * you want the output to be degrees with the halfway point as 0
+ * degrees. The scale value is 270.0(degrees)/5.0(volts) and the
+ * offset is -135.0 since the halfway point after scaling is 135
+ * degrees.
+ *
+ * @param channel The analog channel this potentiometer is plugged into.
+ * @param scale The scaling to multiply the voltage by to get a meaningful unit.
+ */
+ AnalogPotentiometer::AnalogPotentiometer(int channel, double scale) {
+ InitPot(1, channel, scale, 0);
+ }
+
+ /**
+ * AnalogPotentiometer constructor.
+ *
+ * @param channel The analog channel this potentiometer is plugged into.
+ */
+ AnalogPotentiometer::AnalogPotentiometer(int channel) {
+ InitPot(1, channel, 1, 0);
+ }
+
+ /**
+ * Get the current reading of the potentiomere.
+ *
+ * @return The current position of the potentiometer.
+ */
+ double AnalogPotentiometer::Get() {
+ return m_analog_channel->GetVoltage() * m_scale + m_offset;
+ }
+
+
+ /**
+ * Implement the PIDSource interface.
+ *
+ * @return The current reading.
+ */
+ double AnalogPotentiometer::PIDGet() {
+ return Get();
+ }
+
+ /*
+ * Live Window code, only does anything if live window is activated.
+ */
+ std::string AnalogPotentiometer::GetSmartDashboardType(){
+ return "Analog Input";
+ }
+
+ ITable *m_table;
+
+ /**
+ * {@inheritDoc}
+ */
+ void AnalogPotentiometer::InitTable(ITable *subtable) {
+ m_table = subtable;
+ UpdateTable();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void AnalogPotentiometer::UpdateTable() {
+ if (m_table != NULL) {
+ m_table->PutNumber("Value", Get());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ ITable * AnalogPotentiometer::GetTable(){
+ return m_table;
+ }
+
+ /**
+ * Analog Channels don't have to do anything special when entering the LiveWindow.
+ * {@inheritDoc}
+ */
+ void AnalogPotentiometer::StartLiveWindowMode() {}
+
+ /**
+ * Analog Channels don't have to do anything special when exiting the LiveWindow.
+ * {@inheritDoc}
+ */
+ void AnalogPotentiometer::StopLiveWindowMode() {}
+
diff --git a/aos/externals/WPILib/WPILib/AnalogPotentiometer.h b/aos/externals/WPILib/WPILib/AnalogPotentiometer.h
new file mode 100644
index 0000000..1c42255
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/AnalogPotentiometer.h
@@ -0,0 +1,38 @@
+#ifndef _ANALOG_POTENTIOMETER_H
+#define _ANALOG_POTENTIOMETER_H
+
+#include "Interfaces/Potentiometer.h"
+#include "LiveWindow/LiveWindowSendable.h"
+#include "AnalogChannel.h"
+
+/**
+ * Class for reading analog potentiometers. Analog potentiometers read
+ * in an analog voltage that corresponds to a position. Usually the
+ * position is either degrees or meters. However, if no conversion is
+ * given it remains volts.
+ *
+ * @author Alex Henning
+ */
+class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
+private:
+ int m_module, m_channel;
+ double m_scale, m_offset;
+ AnalogChannel *m_analog_channel;
+ void InitPot(int slot, int channel, double scale, double offset);
+ ITable *m_table;
+public:
+ AnalogPotentiometer(int slot, int channel, double scale, double offset);
+ AnalogPotentiometer(int channel, double scale, double offset);
+ AnalogPotentiometer(int channel, double scale);
+ AnalogPotentiometer(int channel);
+ double Get();
+ double PIDGet();
+ std::string GetSmartDashboardType();
+ void InitTable(ITable *subtable);
+ void UpdateTable();
+ ITable * GetTable();
+ void StartLiveWindowMode();
+ void StopLiveWindowMode();
+};
+
+#endif
diff --git a/aos/externals/WPILib/WPILib/AnalogTrigger.cpp b/aos/externals/WPILib/WPILib/AnalogTrigger.cpp
index 2deeb54..fff2365 100644
--- a/aos/externals/WPILib/WPILib/AnalogTrigger.cpp
+++ b/aos/externals/WPILib/WPILib/AnalogTrigger.cpp
@@ -18,15 +18,15 @@
* Initialize an analog trigger from a slot and channel.
* This is the common code for the two constructors that use a slot and channel.
*/
-void AnalogTrigger::InitTrigger(UINT8 moduleNumber, UINT32 channel)
+void AnalogTrigger::InitTrigger(uint8_t moduleNumber, uint32_t channel)
{
Resource::CreateResourceObject(&triggers, tAnalogTrigger::kNumSystems);
- UINT32 index = triggers->Allocate("Analog Trigger", this);
+ uint32_t index = triggers->Allocate("Analog Trigger", this);
if (index == ~0ul)
{
return;
}
- m_index = (UINT8)index;
+ m_index = (uint8_t)index;
m_channel = channel;
m_analogModule = AnalogModule::GetInstance(moduleNumber);
@@ -45,7 +45,7 @@
*
* @param channel The analog channel (1..8).
*/
-AnalogTrigger::AnalogTrigger(UINT32 channel)
+AnalogTrigger::AnalogTrigger(uint32_t channel)
{
InitTrigger(GetDefaultAnalogModule(), channel);
}
@@ -56,7 +56,7 @@
* @param moduleNumber The analog module (1 or 2).
* @param channel The analog channel (1..8).
*/
-AnalogTrigger::AnalogTrigger(UINT8 moduleNumber, UINT32 channel)
+AnalogTrigger::AnalogTrigger(uint8_t moduleNumber, uint32_t channel)
{
InitTrigger(moduleNumber, channel);
}
@@ -82,7 +82,7 @@
* The limits are given in ADC codes. If oversampling is used, the units must be scaled
* appropriately.
*/
-void AnalogTrigger::SetLimitsRaw(INT32 lower, INT32 upper)
+void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper)
{
if (StatusIsFatal()) return;
if (lower > upper)
@@ -148,7 +148,7 @@
* This is the FPGA index of this analog trigger instance.
* @return The index of the analog trigger.
*/
-UINT32 AnalogTrigger::GetIndex()
+uint32_t AnalogTrigger::GetIndex()
{
if (StatusIsFatal()) return ~0ul;
return m_index;
diff --git a/aos/externals/WPILib/WPILib/AnalogTrigger.h b/aos/externals/WPILib/WPILib/AnalogTrigger.h
index 2975be4..d4b1a4b 100644
--- a/aos/externals/WPILib/WPILib/AnalogTrigger.h
+++ b/aos/externals/WPILib/WPILib/AnalogTrigger.h
@@ -17,27 +17,27 @@
{
friend class AnalogTriggerOutput;
public:
- AnalogTrigger(UINT8 moduleNumber, UINT32 channel);
- explicit AnalogTrigger(UINT32 channel);
+ AnalogTrigger(uint8_t moduleNumber, uint32_t channel);
+ explicit AnalogTrigger(uint32_t channel);
explicit AnalogTrigger(AnalogChannel *channel);
virtual ~AnalogTrigger();
void SetLimitsVoltage(float lower, float upper);
- void SetLimitsRaw(INT32 lower, INT32 upper);
+ void SetLimitsRaw(int32_t lower, int32_t upper);
void SetAveraged(bool useAveragedValue);
void SetFiltered(bool useFilteredValue);
- UINT32 GetIndex();
+ uint32_t GetIndex();
bool GetInWindow();
bool GetTriggerState();
AnalogTriggerOutput *CreateOutput(AnalogTriggerOutput::Type type);
private:
- void InitTrigger(UINT8 moduleNumber, UINT32 channel);
+ void InitTrigger(uint8_t moduleNumber, uint32_t channel);
- UINT8 m_index;
+ uint8_t m_index;
tAnalogTrigger *m_trigger;
AnalogModule *m_analogModule;
- UINT32 m_channel;
+ uint32_t m_channel;
};
#endif
diff --git a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp
index beeb788..415e3f9 100644
--- a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp
+++ b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp
@@ -57,7 +57,7 @@
/**
* @return The value to be written to the channel field of a routing mux.
*/
-UINT32 AnalogTriggerOutput::GetChannelForRouting()
+uint32_t AnalogTriggerOutput::GetChannelForRouting()
{
return (m_trigger->m_index << 2) + m_outputType;
}
@@ -65,7 +65,7 @@
/**
* @return The value to be written to the module field of a routing mux.
*/
-UINT32 AnalogTriggerOutput::GetModuleForRouting()
+uint32_t AnalogTriggerOutput::GetModuleForRouting()
{
return m_trigger->m_index >> 2;
}
diff --git a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h
index 61d9ae5..83e4450 100644
--- a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h
+++ b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h
@@ -49,8 +49,8 @@
bool Get();
// DigitalSource interface
- virtual UINT32 GetChannelForRouting();
- virtual UINT32 GetModuleForRouting();
+ virtual uint32_t GetChannelForRouting();
+ virtual uint32_t GetModuleForRouting();
virtual bool GetAnalogTriggerForRouting();
protected:
AnalogTriggerOutput(AnalogTrigger *trigger, Type outputType);
diff --git a/aos/externals/WPILib/WPILib/Base.h b/aos/externals/WPILib/WPILib/Base.h
index ea2dc34..eb11f96 100644
--- a/aos/externals/WPILib/WPILib/Base.h
+++ b/aos/externals/WPILib/WPILib/Base.h
@@ -7,6 +7,11 @@
#ifndef _BASE_H
#define _BASE_H
+// If don't have C++11, define constexpr as const for WindRiver
+#if __cplusplus < 201103L
+#define constexpr const
+#endif
+
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
diff --git a/aos/externals/WPILib/WPILib/Buttons/Button.cpp b/aos/externals/WPILib/WPILib/Buttons/Button.cpp
index ea955f7..020cb94 100644
--- a/aos/externals/WPILib/WPILib/Buttons/Button.cpp
+++ b/aos/externals/WPILib/WPILib/Buttons/Button.cpp
@@ -32,3 +32,19 @@
void Button::WhenReleased(Command *command) {
WhenInactive(command);
}
+
+/**
+ * Cancels the specificed command when the button is pressed
+ * @param The command to be canceled
+ */
+void Button::CancelWhenPressed(Command *command) {
+ CancelWhenActive(command);
+}
+
+/**
+ * Toggle the specified command when the button is pressed
+ * @param The command to be toggled
+ */
+void Button::ToggleWhenPressed(Command *command) {
+ ToggleWhenActive(command);
+}
diff --git a/aos/externals/WPILib/WPILib/Buttons/Button.h b/aos/externals/WPILib/WPILib/Buttons/Button.h
index e2893b0..c491111 100644
--- a/aos/externals/WPILib/WPILib/Buttons/Button.h
+++ b/aos/externals/WPILib/WPILib/Buttons/Button.h
@@ -28,6 +28,8 @@
virtual void WhenPressed(Command *command);
virtual void WhileHeld(Command *command);
virtual void WhenReleased(Command *command);
+ virtual void CancelWhenPressed(Command *command);
+ virtual void ToggleWhenPressed(Command *command);
};
#endif
diff --git a/aos/externals/WPILib/WPILib/Buttons/CancelButtonScheduler.cpp b/aos/externals/WPILib/WPILib/Buttons/CancelButtonScheduler.cpp
new file mode 100644
index 0000000..5562158
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Buttons/CancelButtonScheduler.cpp
@@ -0,0 +1,29 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#include "Buttons/CancelButtonScheduler.h"
+
+#include "Buttons/Button.h"
+#include "Commands/Command.h"
+
+CancelButtonScheduler::CancelButtonScheduler(bool last, Trigger *button, Command *orders) :
+ ButtonScheduler(last, button, orders)
+{
+ pressedLast = m_button->Grab();
+}
+
+void CancelButtonScheduler::Execute()
+{
+ if (m_button->Grab()) {
+ if (!pressedLast) {
+ pressedLast = true;
+ m_command->Cancel();
+ }
+ } else {
+ pressedLast = false;
+ }
+}
+
diff --git a/aos/externals/WPILib/WPILib/Buttons/CancelButtonScheduler.h b/aos/externals/WPILib/WPILib/Buttons/CancelButtonScheduler.h
new file mode 100644
index 0000000..0491213
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Buttons/CancelButtonScheduler.h
@@ -0,0 +1,25 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef __CANCEL_BUTTON_SCHEDULER_H__
+#define __CANCEL_BUTTON_SCHEDULER_H__
+
+#include "Buttons/ButtonScheduler.h"
+
+class Trigger;
+class Command;
+
+class CancelButtonScheduler : public ButtonScheduler
+{
+public:
+ CancelButtonScheduler(bool last, Trigger *button, Command *orders);
+ virtual ~CancelButtonScheduler() {}
+ virtual void Execute();
+private:
+ bool pressedLast;
+};
+
+#endif
diff --git a/aos/externals/WPILib/WPILib/Buttons/ToggleButtonScheduler.cpp b/aos/externals/WPILib/WPILib/Buttons/ToggleButtonScheduler.cpp
new file mode 100644
index 0000000..ed72160
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Buttons/ToggleButtonScheduler.cpp
@@ -0,0 +1,32 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#include "Buttons/ToggleButtonScheduler.h"
+
+#include "Buttons/Button.h"
+#include "Commands/Command.h"
+
+ToggleButtonScheduler::ToggleButtonScheduler(bool last, Trigger *button,
+ Command *orders) :
+ ButtonScheduler(last, button, orders) {
+ pressedLast = m_button->Grab();
+}
+
+void ToggleButtonScheduler::Execute() {
+ if (m_button->Grab()) {
+ if (!pressedLast) {
+ pressedLast = true;
+ if (m_command->IsRunning()) {
+ m_command->Cancel();
+ } else {
+ m_command->Start();
+ }
+ }
+ } else {
+ pressedLast = false;
+ }
+}
+
diff --git a/aos/externals/WPILib/WPILib/Buttons/ToggleButtonScheduler.h b/aos/externals/WPILib/WPILib/Buttons/ToggleButtonScheduler.h
new file mode 100644
index 0000000..e0987e5
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Buttons/ToggleButtonScheduler.h
@@ -0,0 +1,25 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef __TOGGLE_BUTTON_SCHEDULER_H__
+#define __TOGGLE_BUTTON_SCHEDULER_H__
+
+#include "Buttons/ButtonScheduler.h"
+
+class Trigger;
+class Command;
+
+class ToggleButtonScheduler : public ButtonScheduler
+{
+public:
+ ToggleButtonScheduler(bool last, Trigger *button, Command *orders);
+ virtual ~ToggleButtonScheduler() {}
+ virtual void Execute();
+private:
+ bool pressedLast;
+};
+
+#endif
diff --git a/aos/externals/WPILib/WPILib/Buttons/Trigger.cpp b/aos/externals/WPILib/WPILib/Buttons/Trigger.cpp
index 8ee5a4d..55b865b 100644
--- a/aos/externals/WPILib/WPILib/Buttons/Trigger.cpp
+++ b/aos/externals/WPILib/WPILib/Buttons/Trigger.cpp
@@ -9,6 +9,8 @@
#include "Buttons/HeldButtonScheduler.h"
#include "Buttons/PressedButtonScheduler.h"
#include "Buttons/ReleasedButtonScheduler.h"
+#include "Buttons/ToggleButtonScheduler.h"
+#include "Buttons/CancelButtonScheduler.h"
Trigger::Trigger() {
m_table = NULL;
@@ -47,7 +49,15 @@
rbs->Start();
}
+void Trigger::CancelWhenActive(Command *command) {
+ CancelButtonScheduler *cbs = new CancelButtonScheduler(Grab(), this, command);
+ cbs->Start();
+}
+void Trigger::ToggleWhenActive(Command *command) {
+ ToggleButtonScheduler *tbs = new ToggleButtonScheduler(Grab(), this, command);
+ tbs->Start();
+}
std::string Trigger::GetSmartDashboardType(){
return "Button";
diff --git a/aos/externals/WPILib/WPILib/Buttons/Trigger.h b/aos/externals/WPILib/WPILib/Buttons/Trigger.h
index da7c1b8..509fc82 100644
--- a/aos/externals/WPILib/WPILib/Buttons/Trigger.h
+++ b/aos/externals/WPILib/WPILib/Buttons/Trigger.h
@@ -36,6 +36,8 @@
void WhenActive(Command *command);
void WhileActive(Command *command);
void WhenInactive(Command *command);
+ void CancelWhenActive(Command *command);
+ void ToggleWhenActive(Command *command);
virtual void InitTable(ITable* table);
virtual ITable* GetTable();
diff --git a/aos/externals/WPILib/WPILib/CAN/JaguarCANDriver.h b/aos/externals/WPILib/WPILib/CAN/JaguarCANDriver.h
index 0f8afe4..171dcd6 100644
--- a/aos/externals/WPILib/WPILib/CAN/JaguarCANDriver.h
+++ b/aos/externals/WPILib/WPILib/CAN/JaguarCANDriver.h
@@ -14,13 +14,15 @@
#ifndef __JaguarCANDriver_h__
#define __JaguarCANDriver_h__
+#include <vxWorks.h>
+
#ifdef __cplusplus
extern "C"
{
#endif
- void FRC_NetworkCommunication_JaguarCANDriver_sendMessage(UINT32 messageID, const UINT8 *data, UINT8 dataSize, INT32 *status);
- void FRC_NetworkCommunication_JaguarCANDriver_receiveMessage(UINT32 *messageID, UINT8 *data, UINT8 *dataSize, UINT32 timeoutMs, INT32 *status);
+ void FRC_NetworkCommunication_JaguarCANDriver_sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t *status);
+ void FRC_NetworkCommunication_JaguarCANDriver_receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, uint32_t timeoutMs, int32_t *status);
#ifdef __cplusplus
}
diff --git a/aos/externals/WPILib/WPILib/CANJaguar.cpp b/aos/externals/WPILib/WPILib/CANJaguar.cpp
index ec55460..bafa8a1 100644
--- a/aos/externals/WPILib/WPILib/CANJaguar.cpp
+++ b/aos/externals/WPILib/WPILib/CANJaguar.cpp
@@ -23,14 +23,15 @@
#define kFullMessageIDMask (CAN_MSGID_API_M | CAN_MSGID_MFR_M | CAN_MSGID_DTYPE_M)
-const INT32 CANJaguar::kControllerRate;
-const double CANJaguar::kApproxBusVoltage;
+const int32_t CANJaguar::kControllerRate;
+constexpr double CANJaguar::kApproxBusVoltage;
/**
* Common initialization code called by all constructors.
*/
void CANJaguar::InitCANJaguar()
{
+ m_table = NULL;
m_transactionSemaphore = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
if (m_deviceNumber < 1 || m_deviceNumber > 63)
{
@@ -39,7 +40,7 @@
wpi_setWPIErrorWithContext(ParameterOutOfRange, buf);
return;
}
- UINT32 fwVer = GetFirmwareVersion();
+ uint32_t fwVer = GetFirmwareVersion();
if (StatusIsFatal())
return;
// 3330 was the first shipping RDK firmware version for the Jaguar
@@ -78,7 +79,7 @@
*
* @param deviceNumber The the address of the Jaguar on the CAN bus.
*/
-CANJaguar::CANJaguar(UINT8 deviceNumber, ControlMode controlMode)
+CANJaguar::CANJaguar(uint8_t deviceNumber, ControlMode controlMode)
: m_deviceNumber (deviceNumber)
, m_controlMode (controlMode)
, m_transactionSemaphore (NULL)
@@ -109,11 +110,11 @@
* @param outputValue The set-point to sent to the motor controller.
* @param syncGroup The update group to add this Set() to, pending UpdateSyncGroup(). If 0, update immediately.
*/
-void CANJaguar::Set(float outputValue, UINT8 syncGroup)
+void CANJaguar::Set(float outputValue, uint8_t syncGroup)
{
- UINT32 messageID;
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint32_t messageID;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
if (m_safetyHelper && !m_safetyHelper->IsAlive())
{
@@ -180,42 +181,42 @@
*/
float CANJaguar::Get()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
switch(m_controlMode)
{
case kPercentVbus:
getTransaction(LM_API_VOLT_SET, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackPercentage(dataBuffer);
}
break;
case kSpeed:
getTransaction(LM_API_SPD_SET, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kPosition:
getTransaction(LM_API_POS_SET, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kCurrent:
getTransaction(LM_API_ICTRL_SET, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackFXP8_8(dataBuffer);
}
break;
case kVoltage:
getTransaction(LM_API_VCOMP_SET, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackFXP8_8(dataBuffer);
}
@@ -253,69 +254,69 @@
}
}
-UINT8 CANJaguar::packPercentage(UINT8 *buffer, double value)
+uint8_t CANJaguar::packPercentage(uint8_t *buffer, double value)
{
- INT16 intValue = (INT16)(value * 32767.0);
- *((INT16*)buffer) = swap16(intValue);
- return sizeof(INT16);
+ int16_t intValue = (int16_t)(value * 32767.0);
+ *((int16_t*)buffer) = swap16(intValue);
+ return sizeof(int16_t);
}
-UINT8 CANJaguar::packFXP8_8(UINT8 *buffer, double value)
+uint8_t CANJaguar::packFXP8_8(uint8_t *buffer, double value)
{
- INT16 intValue = (INT16)(value * 256.0);
- *((INT16*)buffer) = swap16(intValue);
- return sizeof(INT16);
+ int16_t intValue = (int16_t)(value * 256.0);
+ *((int16_t*)buffer) = swap16(intValue);
+ return sizeof(int16_t);
}
-UINT8 CANJaguar::packFXP16_16(UINT8 *buffer, double value)
+uint8_t CANJaguar::packFXP16_16(uint8_t *buffer, double value)
{
- INT32 intValue = (INT32)(value * 65536.0);
- *((INT32*)buffer) = swap32(intValue);
- return sizeof(INT32);
+ int32_t intValue = (int32_t)(value * 65536.0);
+ *((int32_t*)buffer) = swap32(intValue);
+ return sizeof(int32_t);
}
-UINT8 CANJaguar::packINT16(UINT8 *buffer, INT16 value)
+uint8_t CANJaguar::packint16_t(uint8_t *buffer, int16_t value)
{
- *((INT16*)buffer) = swap16(value);
- return sizeof(INT16);
+ *((int16_t*)buffer) = swap16(value);
+ return sizeof(int16_t);
}
-UINT8 CANJaguar::packINT32(UINT8 *buffer, INT32 value)
+uint8_t CANJaguar::packint32_t(uint8_t *buffer, int32_t value)
{
- *((INT32*)buffer) = swap32(value);
- return sizeof(INT32);
+ *((int32_t*)buffer) = swap32(value);
+ return sizeof(int32_t);
}
-double CANJaguar::unpackPercentage(UINT8 *buffer)
+double CANJaguar::unpackPercentage(uint8_t *buffer)
{
- INT16 value = *((INT16*)buffer);
+ int16_t value = *((int16_t*)buffer);
value = swap16(value);
return value / 32767.0;
}
-double CANJaguar::unpackFXP8_8(UINT8 *buffer)
+double CANJaguar::unpackFXP8_8(uint8_t *buffer)
{
- INT16 value = *((INT16*)buffer);
+ int16_t value = *((int16_t*)buffer);
value = swap16(value);
return value / 256.0;
}
-double CANJaguar::unpackFXP16_16(UINT8 *buffer)
+double CANJaguar::unpackFXP16_16(uint8_t *buffer)
{
- INT32 value = *((INT32*)buffer);
+ int32_t value = *((int32_t*)buffer);
value = swap32(value);
return value / 65536.0;
}
-INT16 CANJaguar::unpackINT16(UINT8 *buffer)
+int16_t CANJaguar::unpackint16_t(uint8_t *buffer)
{
- INT16 value = *((INT16*)buffer);
+ int16_t value = *((int16_t*)buffer);
return swap16(value);
}
-INT32 CANJaguar::unpackINT32(UINT8 *buffer)
+int32_t CANJaguar::unpackint32_t(uint8_t *buffer)
{
- INT32 value = *((INT32*)buffer);
+ int32_t value = *((int32_t*)buffer);
return swap32(value);
}
@@ -330,19 +331,19 @@
* @param dataSize Specify how much of the data in "data" to send
* @return Status of send call
*/
-INT32 CANJaguar::sendMessage(UINT32 messageID, const UINT8 *data, UINT8 dataSize)
+int32_t CANJaguar::sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize)
{
- static const UINT32 kTrustedMessages[] = {
+ static const uint32_t kTrustedMessages[] = {
LM_API_VOLT_T_EN, LM_API_VOLT_T_SET, LM_API_SPD_T_EN, LM_API_SPD_T_SET,
LM_API_VCOMP_T_EN, LM_API_VCOMP_T_SET, LM_API_POS_T_EN, LM_API_POS_T_SET,
LM_API_ICTRL_T_EN, LM_API_ICTRL_T_SET};
- INT32 status=0;
+ int32_t status=0;
- for (UINT8 i=0; i<(sizeof(kTrustedMessages)/sizeof(kTrustedMessages[0])); i++)
+ for (uint8_t i=0; i<(sizeof(kTrustedMessages)/sizeof(kTrustedMessages[0])); i++)
{
if ((kFullMessageIDMask & messageID) == kTrustedMessages[i])
{
- UINT8 dataBuffer[8];
+ uint8_t dataBuffer[8];
dataBuffer[0] = 0;
dataBuffer[1] = 0;
// Make sure the data will still fit after adjusting for the token.
@@ -352,7 +353,7 @@
wpi_setGlobalWPIErrorWithContext(ParameterOutOfRange, "dataSize > 6");
return 0;
}
- for (UINT8 j=0; j < dataSize; j++)
+ for (uint8_t j=0; j < dataSize; j++)
{
dataBuffer[j + 2] = data[j];
}
@@ -373,11 +374,11 @@
* @param timeout Specify how long to wait for a message (in seconds)
* @return Status of receive call
*/
-INT32 CANJaguar::receiveMessage(UINT32 *messageID, UINT8 *data, UINT8 *dataSize, float timeout)
+int32_t CANJaguar::receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, float timeout)
{
- INT32 status = 0;
+ int32_t status = 0;
FRC_NetworkCommunication_JaguarCANDriver_receiveMessage(messageID, data, dataSize,
- (UINT32)(timeout * 1000), &status);
+ (uint32_t)(timeout * 1000), &status);
return status;
}
@@ -391,10 +392,10 @@
* @param data The up to 8 bytes of data to be sent with the message
* @param dataSize Specify how much of the data in "data" to send
*/
-void CANJaguar::setTransaction(UINT32 messageID, const UINT8 *data, UINT8 dataSize)
+void CANJaguar::setTransaction(uint32_t messageID, const uint8_t *data, uint8_t dataSize)
{
- UINT32 ackMessageID = LM_API_ACK | m_deviceNumber;
- INT32 localStatus = 0;
+ uint32_t ackMessageID = LM_API_ACK | m_deviceNumber;
+ int32_t localStatus = 0;
// If there was an error on this object and it wasn't a timeout, refuse to talk to the device
// Call ClearError() on the object to try again
@@ -426,10 +427,10 @@
* @param data The up to 8 bytes of data that was received with the message
* @param dataSize Indicates how much data was received
*/
-void CANJaguar::getTransaction(UINT32 messageID, UINT8 *data, UINT8 *dataSize)
+void CANJaguar::getTransaction(uint32_t messageID, uint8_t *data, uint8_t *dataSize)
{
- UINT32 targetedMessageID = messageID | m_deviceNumber;
- INT32 localStatus = 0;
+ uint32_t targetedMessageID = messageID | m_deviceNumber;
+ int32_t localStatus = 0;
// If there was an error on this object and it wasn't a timeout, refuse to talk to the device
// Call ClearError() on the object to try again
@@ -467,10 +468,10 @@
*/
void CANJaguar::SetSpeedReference(SpeedReference reference)
{
- UINT8 dataBuffer[8];
+ uint8_t dataBuffer[8];
dataBuffer[0] = reference;
- setTransaction(LM_API_SPD_REF, dataBuffer, sizeof(UINT8));
+ setTransaction(LM_API_SPD_REF, dataBuffer, sizeof(uint8_t));
}
/**
@@ -480,11 +481,11 @@
*/
CANJaguar::SpeedReference CANJaguar::GetSpeedReference()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_SPD_REF, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT8))
+ if (dataSize == sizeof(uint8_t))
{
return (SpeedReference)*dataBuffer;
}
@@ -501,10 +502,10 @@
*/
void CANJaguar::SetPositionReference(PositionReference reference)
{
- UINT8 dataBuffer[8];
+ uint8_t dataBuffer[8];
dataBuffer[0] = reference;
- setTransaction(LM_API_POS_REF, dataBuffer, sizeof(UINT8));
+ setTransaction(LM_API_POS_REF, dataBuffer, sizeof(uint8_t));
}
/**
@@ -514,11 +515,11 @@
*/
CANJaguar::PositionReference CANJaguar::GetPositionReference()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_POS_REF, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT8))
+ if (dataSize == sizeof(uint8_t))
{
return (PositionReference)*dataBuffer;
}
@@ -534,8 +535,8 @@
*/
void CANJaguar::SetPID(double p, double i, double d)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
switch(m_controlMode)
{
@@ -577,8 +578,8 @@
*/
double CANJaguar::GetP()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
switch(m_controlMode)
{
@@ -588,21 +589,21 @@
break;
case kSpeed:
getTransaction(LM_API_SPD_PC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kPosition:
getTransaction(LM_API_POS_PC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kCurrent:
getTransaction(LM_API_ICTRL_PC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
@@ -618,8 +619,8 @@
*/
double CANJaguar::GetI()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
switch(m_controlMode)
{
@@ -629,21 +630,21 @@
break;
case kSpeed:
getTransaction(LM_API_SPD_IC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kPosition:
getTransaction(LM_API_POS_IC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kCurrent:
getTransaction(LM_API_ICTRL_IC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
@@ -659,8 +660,8 @@
*/
double CANJaguar::GetD()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
switch(m_controlMode)
{
@@ -670,21 +671,21 @@
break;
case kSpeed:
getTransaction(LM_API_SPD_DC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kPosition:
getTransaction(LM_API_POS_DC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
break;
case kCurrent:
getTransaction(LM_API_ICTRL_DC, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
@@ -705,8 +706,8 @@
*/
void CANJaguar::EnableControl(double encoderInitialPosition)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize = 0;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize = 0;
switch(m_controlMode)
{
@@ -736,8 +737,8 @@
*/
void CANJaguar::DisableControl()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize = 0;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize = 0;
switch(m_controlMode)
{
@@ -787,11 +788,11 @@
*/
CANJaguar::ControlMode CANJaguar::GetControlMode()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_CMODE, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT8))
+ if (dataSize == sizeof(int8_t))
{
return (ControlMode)dataBuffer[0];
}
@@ -805,11 +806,11 @@
*/
float CANJaguar::GetBusVoltage()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_VOLTBUS, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackFXP8_8(dataBuffer);
}
@@ -823,12 +824,12 @@
*/
float CANJaguar::GetOutputVoltage()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
// Read the volt out which is in Volts units.
getTransaction(LM_API_STATUS_VOUT, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackFXP8_8(dataBuffer);
}
@@ -842,11 +843,11 @@
*/
float CANJaguar::GetOutputCurrent()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_CURRENT, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackFXP8_8(dataBuffer);
}
@@ -860,11 +861,11 @@
*/
float CANJaguar::GetTemperature()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_TEMP, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT16))
+ if (dataSize == sizeof(int16_t))
{
return unpackFXP8_8(dataBuffer);
}
@@ -878,11 +879,11 @@
*/
double CANJaguar::GetPosition()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_POS, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
@@ -896,11 +897,11 @@
*/
double CANJaguar::GetSpeed()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_SPD, dataBuffer, &dataSize);
- if (dataSize == sizeof(INT32))
+ if (dataSize == sizeof(int32_t))
{
return unpackFXP16_16(dataBuffer);
}
@@ -914,11 +915,11 @@
*/
bool CANJaguar::GetForwardLimitOK()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_LIMIT, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT8))
+ if (dataSize == sizeof(uint8_t))
{
return (*dataBuffer & kForwardLimit) != 0;
}
@@ -932,11 +933,11 @@
*/
bool CANJaguar::GetReverseLimitOK()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_LIMIT, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT8))
+ if (dataSize == sizeof(uint8_t))
{
return (*dataBuffer & kReverseLimit) != 0;
}
@@ -948,15 +949,15 @@
*
* @return A bit-mask of faults defined by the "Faults" enum.
*/
-UINT16 CANJaguar::GetFaults()
+uint16_t CANJaguar::GetFaults()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_FAULT, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT16))
+ if (dataSize == sizeof(uint16_t))
{
- return unpackINT16(dataBuffer);
+ return unpackint16_t(dataBuffer);
}
return 0;
}
@@ -971,11 +972,11 @@
*/
bool CANJaguar::GetPowerCycled()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_STATUS_POWER, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT8))
+ if (dataSize == sizeof(uint8_t))
{
bool powerCycled = (*dataBuffer != 0);
@@ -983,7 +984,7 @@
if (powerCycled)
{
dataBuffer[0] = 1;
- setTransaction(LM_API_STATUS_POWER, dataBuffer, sizeof(UINT8));
+ setTransaction(LM_API_STATUS_POWER, dataBuffer, sizeof(uint8_t));
}
return powerCycled;
@@ -1001,8 +1002,8 @@
*/
void CANJaguar::SetVoltageRampRate(double rampRate)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
switch(m_controlMode)
{
@@ -1024,16 +1025,16 @@
*
* @return The firmware version. 0 if the device did not respond.
*/
-UINT32 CANJaguar::GetFirmwareVersion()
+uint32_t CANJaguar::GetFirmwareVersion()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
// Set the MSB to tell the 2CAN that this is a remote message.
getTransaction(0x80000000 | CAN_MSGID_API_FIRMVER, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT32))
+ if (dataSize == sizeof(uint32_t))
{
- return unpackINT32(dataBuffer);
+ return unpackint32_t(dataBuffer);
}
return 0;
}
@@ -1043,13 +1044,13 @@
*
* @return The hardware version. 1: Jaguar, 2: Black Jaguar
*/
-UINT8 CANJaguar::GetHardwareVersion()
+uint8_t CANJaguar::GetHardwareVersion()
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
getTransaction(LM_API_HWVER, dataBuffer, &dataSize);
- if (dataSize == sizeof(UINT8)+sizeof(UINT8))
+ if (dataSize == sizeof(uint8_t)+sizeof(uint8_t))
{
if (*dataBuffer == m_deviceNumber)
{
@@ -1069,10 +1070,10 @@
*/
void CANJaguar::ConfigNeutralMode(NeutralMode mode)
{
- UINT8 dataBuffer[8];
+ uint8_t dataBuffer[8];
dataBuffer[0] = mode;
- setTransaction(LM_API_CFG_BRAKE_COAST, dataBuffer, sizeof(UINT8));
+ setTransaction(LM_API_CFG_BRAKE_COAST, dataBuffer, sizeof(uint8_t));
}
/**
@@ -1080,12 +1081,12 @@
*
* @param codesPerRev The number of counts per revolution in 1X mode.
*/
-void CANJaguar::ConfigEncoderCodesPerRev(UINT16 codesPerRev)
+void CANJaguar::ConfigEncoderCodesPerRev(uint16_t codesPerRev)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
- dataSize = packINT16(dataBuffer, codesPerRev);
+ dataSize = packint16_t(dataBuffer, codesPerRev);
setTransaction(LM_API_CFG_ENC_LINES, dataBuffer, dataSize);
}
@@ -1097,12 +1098,12 @@
*
* @param turns The number of turns of the potentiometer
*/
-void CANJaguar::ConfigPotentiometerTurns(UINT16 turns)
+void CANJaguar::ConfigPotentiometerTurns(uint16_t turns)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
- dataSize = packINT16(dataBuffer, turns);
+ dataSize = packint16_t(dataBuffer, turns);
setTransaction(LM_API_CFG_POT_TURNS, dataBuffer, dataSize);
}
@@ -1118,8 +1119,8 @@
*/
void CANJaguar::ConfigSoftPositionLimits(double forwardLimitPosition, double reverseLimitPosition)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
dataSize = packFXP16_16(dataBuffer, forwardLimitPosition);
dataBuffer[dataSize++] = forwardLimitPosition > reverseLimitPosition;
@@ -1130,7 +1131,7 @@
setTransaction(LM_API_CFG_LIMIT_REV, dataBuffer, dataSize);
dataBuffer[0] = kLimitMode_SoftPositionLimits;
- setTransaction(LM_API_CFG_LIMIT_MODE, dataBuffer, sizeof(UINT8));
+ setTransaction(LM_API_CFG_LIMIT_MODE, dataBuffer, sizeof(uint8_t));
}
/**
@@ -1140,10 +1141,10 @@
*/
void CANJaguar::DisableSoftPositionLimits()
{
- UINT8 dataBuffer[8];
+ uint8_t dataBuffer[8];
dataBuffer[0] = kLimitMode_SwitchInputsOnly;
- setTransaction(LM_API_CFG_LIMIT_MODE, dataBuffer, sizeof(UINT8));
+ setTransaction(LM_API_CFG_LIMIT_MODE, dataBuffer, sizeof(uint8_t));
}
/**
@@ -1156,8 +1157,8 @@
*/
void CANJaguar::ConfigMaxOutputVoltage(double voltage)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
m_maxOutputVoltage = voltage;
dataSize = packFXP8_8(dataBuffer, voltage);
@@ -1174,11 +1175,11 @@
*/
void CANJaguar::ConfigFaultTime(float faultTime)
{
- UINT8 dataBuffer[8];
- UINT8 dataSize;
+ uint8_t dataBuffer[8];
+ uint8_t dataSize;
// Message takes ms
- dataSize = packINT16(dataBuffer, (INT16)(faultTime * 1000.0));
+ dataSize = packint16_t(dataBuffer, (int16_t)(faultTime * 1000.0));
setTransaction(LM_API_CFG_FAULT_TIME, dataBuffer, dataSize);
}
@@ -1187,7 +1188,7 @@
*
* @param syncGroup A bitmask of groups to generate synchronous output.
*/
-void CANJaguar::UpdateSyncGroup(UINT8 syncGroup)
+void CANJaguar::UpdateSyncGroup(uint8_t syncGroup)
{
sendMessage(CAN_MSGID_API_SYNC, &syncGroup, sizeof(syncGroup));
}
@@ -1248,11 +1249,15 @@
}
void CANJaguar::StartLiveWindowMode() {
- m_table->AddTableListener("Value", this, true);
+ if (m_table != NULL) {
+ m_table->AddTableListener("Value", this, true);
+ }
}
void CANJaguar::StopLiveWindowMode() {
- m_table->RemoveTableListener(this);
+ if (m_table != NULL) {
+ m_table->RemoveTableListener(this);
+ }
}
std::string CANJaguar::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/CANJaguar.h b/aos/externals/WPILib/WPILib/CANJaguar.h
index 0bb38b1..55ec1b0 100644
--- a/aos/externals/WPILib/WPILib/CANJaguar.h
+++ b/aos/externals/WPILib/WPILib/CANJaguar.h
@@ -29,8 +29,8 @@
{
public:
// The internal PID control loop in the Jaguar runs at 1kHz.
- static const INT32 kControllerRate = 1000;
- static const double kApproxBusVoltage = 12.0;
+ static const int32_t kControllerRate = 1000;
+ static constexpr double kApproxBusVoltage = 12.0;
typedef enum {kPercentVbus, kCurrent, kSpeed, kPosition, kVoltage} ControlMode;
typedef enum {kCurrentFault = 1, kTemperatureFault = 2, kBusVoltageFault = 4, kGateDriverFault = 8} Faults;
@@ -40,12 +40,12 @@
typedef enum {kNeutralMode_Jumper = 0, kNeutralMode_Brake = 1, kNeutralMode_Coast = 2} NeutralMode;
typedef enum {kLimitMode_SwitchInputsOnly = 0, kLimitMode_SoftPositionLimits = 1} LimitMode;
- explicit CANJaguar(UINT8 deviceNumber, ControlMode controlMode = kPercentVbus);
+ explicit CANJaguar(uint8_t deviceNumber, ControlMode controlMode = kPercentVbus);
virtual ~CANJaguar();
// SpeedController interface
virtual float Get();
- virtual void Set(float value, UINT8 syncGroup=0);
+ virtual void Set(float value, uint8_t syncGroup=0);
virtual void Disable();
// PIDOutput interface
@@ -72,20 +72,20 @@
double GetSpeed();
bool GetForwardLimitOK();
bool GetReverseLimitOK();
- UINT16 GetFaults();
+ uint16_t GetFaults();
bool GetPowerCycled();
void SetVoltageRampRate(double rampRate);
- virtual UINT32 GetFirmwareVersion();
- UINT8 GetHardwareVersion();
+ virtual uint32_t GetFirmwareVersion();
+ uint8_t GetHardwareVersion();
void ConfigNeutralMode(NeutralMode mode);
- void ConfigEncoderCodesPerRev(UINT16 codesPerRev);
- void ConfigPotentiometerTurns(UINT16 turns);
+ void ConfigEncoderCodesPerRev(uint16_t codesPerRev);
+ void ConfigPotentiometerTurns(uint16_t turns);
void ConfigSoftPositionLimits(double forwardLimitPosition, double reverseLimitPosition);
void DisableSoftPositionLimits();
void ConfigMaxOutputVoltage(double voltage);
void ConfigFaultTime(float faultTime);
- static void UpdateSyncGroup(UINT8 syncGroup);
+ static void UpdateSyncGroup(uint8_t syncGroup);
void SetExpiration(float timeout);
float GetExpiration();
@@ -96,23 +96,23 @@
void GetDescription(char *desc);
protected:
- UINT8 packPercentage(UINT8 *buffer, double value);
- UINT8 packFXP8_8(UINT8 *buffer, double value);
- UINT8 packFXP16_16(UINT8 *buffer, double value);
- UINT8 packINT16(UINT8 *buffer, INT16 value);
- UINT8 packINT32(UINT8 *buffer, INT32 value);
- double unpackPercentage(UINT8 *buffer);
- double unpackFXP8_8(UINT8 *buffer);
- double unpackFXP16_16(UINT8 *buffer);
- INT16 unpackINT16(UINT8 *buffer);
- INT32 unpackINT32(UINT8 *buffer);
- virtual void setTransaction(UINT32 messageID, const UINT8 *data, UINT8 dataSize);
- virtual void getTransaction(UINT32 messageID, UINT8 *data, UINT8 *dataSize);
+ uint8_t packPercentage(uint8_t *buffer, double value);
+ uint8_t packFXP8_8(uint8_t *buffer, double value);
+ uint8_t packFXP16_16(uint8_t *buffer, double value);
+ uint8_t packint16_t(uint8_t *buffer, int16_t value);
+ uint8_t packint32_t(uint8_t *buffer, int32_t value);
+ double unpackPercentage(uint8_t *buffer);
+ double unpackFXP8_8(uint8_t *buffer);
+ double unpackFXP16_16(uint8_t *buffer);
+ int16_t unpackint16_t(uint8_t *buffer);
+ int32_t unpackint32_t(uint8_t *buffer);
+ virtual void setTransaction(uint32_t messageID, const uint8_t *data, uint8_t dataSize);
+ virtual void getTransaction(uint32_t messageID, uint8_t *data, uint8_t *dataSize);
- static INT32 sendMessage(UINT32 messageID, const UINT8 *data, UINT8 dataSize);
- static INT32 receiveMessage(UINT32 *messageID, UINT8 *data, UINT8 *dataSize, float timeout = 0.02);
+ static int32_t sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize);
+ static int32_t receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, float timeout = 0.02);
- UINT8 m_deviceNumber;
+ uint8_t m_deviceNumber;
ControlMode m_controlMode;
SEM_ID m_transactionSemaphore;
double m_maxOutputVoltage;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/chipObjectAliases.h b/aos/externals/WPILib/WPILib/ChipObject/chipObjectAliases.h
new file mode 100644
index 0000000..2b2bb48
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/ChipObject/chipObjectAliases.h
@@ -0,0 +1,10 @@
+// Copyright (c) National Instruments 2008. All Rights Reserved.
+// Do Not Edit... this file is generated!
+
+#ifndef __chipObjectAliases_h__
+#define __chipObjectAliases_h__
+
+#define nInvariantFPGANamespace nFRC_C0EF_1_1_0
+#define nRuntimeFPGANamespace nFRC_2012_1_6_4
+
+#endif // __chipObjectAliases_h__
diff --git a/aos/externals/WPILib/WPILib/ChipObject/fpgainterfacecapi/NiFpga.h b/aos/externals/WPILib/WPILib/ChipObject/fpgainterfacecapi/NiFpga.h
new file mode 100644
index 0000000..8e8f88d
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/ChipObject/fpgainterfacecapi/NiFpga.h
@@ -0,0 +1,2435 @@
+/*
+ * FPGA Interface C API 13.0 header file.
+ *
+ * Copyright (c) 2013,
+ * National Instruments Corporation.
+ * All rights reserved.
+ */
+
+#ifndef __NiFpga_h__
+#define __NiFpga_h__
+
+/*
+ * Determine platform details.
+ */
+#if defined(_M_IX86) \
+ || defined(_M_X64) \
+ || defined(_M_AMD64) \
+ || defined(i386) \
+ || defined(__i386) \
+ || defined(__i386__) \
+ || defined(__i486__) \
+ || defined(__i586__) \
+ || defined(__i686__) \
+ || defined(__amd64__) \
+ || defined(__amd64) \
+ || defined(__x86_64__) \
+ || defined(__x86_64) \
+ || defined(__IA32__) \
+ || defined(_X86_) \
+ || defined(__THW_INTEL__) \
+ || defined(__I86__) \
+ || defined(__INTEL__) \
+ || defined(__X86__) \
+ || defined(__386__) \
+ || defined(__I86__) \
+ || defined(M_I386) \
+ || defined(M_I86) \
+ || defined(_M_I386) \
+ || defined(_M_I86)
+ #if defined(_WIN32) \
+ || defined(_WIN64) \
+ || defined(__WIN32__) \
+ || defined(__TOS_WIN__) \
+ || defined(__WINDOWS__) \
+ || defined(_WINDOWS) \
+ || defined(__WINDOWS_386__) \
+ || defined(__CYGWIN__)
+ /* Either Windows or Phar Lap ETS. */
+ #define NiFpga_Windows 1
+ #elif defined(__linux__) \
+ || defined(__linux) \
+ || defined(linux) \
+ || defined(__gnu_linux__)
+ #define NiFpga_Linux 1
+ #else
+ #error Unsupported OS.
+ #endif
+#elif defined(__powerpc) \
+ || defined(__powerpc__) \
+ || defined(__POWERPC__) \
+ || defined(__ppc__) \
+ || defined(__PPC) \
+ || defined(_M_PPC) \
+ || defined(_ARCH_PPC) \
+ || defined(__PPC__) \
+ || defined(__ppc)
+ #if defined(__vxworks)
+ #define NiFpga_VxWorks 1
+ #else
+ #error Unsupported OS.
+ #endif
+#elif defined(__arm__) \
+ || defined(__thumb__) \
+ || defined(__TARGET_ARCH_ARM) \
+ || defined(__TARGET_ARCH_THUMB) \
+ || defined(_ARM) \
+ || defined(_M_ARM) \
+ || defined(_M_ARMT)
+ #if defined(__linux__) \
+ || defined(__linux) \
+ || defined(linux) \
+ || defined(__gnu_linux__)
+ #define NiFpga_Linux 1
+ #else
+ #error Unsupported OS.
+ #endif
+#else
+ #error Unsupported architecture.
+#endif
+
+/*
+ * Determine compiler.
+ */
+#if defined(_MSC_VER)
+ #define NiFpga_Msvc 1
+#elif defined(__GNUC__)
+ #define NiFpga_Gcc 1
+#elif defined(_CVI_) && !defined(_TPC_)
+ #define NiFpga_Cvi 1
+ /* Enables CVI Library Protection Errors. */
+ #pragma EnableLibraryRuntimeChecking
+#else
+ /* Unknown compiler. */
+#endif
+
+/*
+ * Determine compliance with different C/C++ language standards.
+ */
+#if defined(__cplusplus)
+ #define NiFpga_Cpp 1
+ #if __cplusplus >= 199707L
+ #define NiFpga_Cpp98 1
+ #if __cplusplus >= 201103L
+ #define NiFpga_Cpp11 1
+ #endif
+ #endif
+#endif
+#if defined(__STDC__)
+ #define NiFpga_C89 1
+ #if defined(__STDC_VERSION__)
+ #define NiFpga_C90 1
+ #if __STDC_VERSION__ >= 199409L
+ #define NiFpga_C94 1
+ #if __STDC_VERSION__ >= 199901L
+ #define NiFpga_C99 1
+ #if __STDC_VERSION__ >= 201112L
+ #define NiFpga_C11 1
+ #endif
+ #endif
+ #endif
+ #endif
+#endif
+
+/*
+ * Determine ability to inline functions.
+ */
+#if NiFpga_Cpp || NiFpga_C99
+ /* The inline keyword exists in C++ and C99. */
+ #define NiFpga_Inline inline
+#elif NiFpga_Msvc
+ /* Visual C++ (at least since 6.0) also supports an alternate keyword. */
+ #define NiFpga_Inline __inline
+#elif NiFpga_Gcc
+ /* GCC (at least since 2.95.2) also supports an alternate keyword. */
+ #define NiFpga_Inline __inline__
+#elif !defined(NiFpga_Inline)
+ /*
+ * Disable inlining if inline support is unknown. To manually enable
+ * inlining, #define the following macro before #including NiFpga.h:
+ *
+ * #define NiFpga_Inline inline
+ */
+ #define NiFpga_Inline
+#endif
+
+/*
+ * Define exact-width integer types, if they have not already been defined.
+ */
+#if NiFpga_ExactWidthIntegerTypesDefined \
+ || defined(_STDINT) \
+ || defined(_STDINT_H) \
+ || defined(_STDINT_H_) \
+ || defined(_INTTYPES_H) \
+ || defined(_INTTYPES_H_) \
+ || defined(_SYS_STDINT_H) \
+ || defined(_SYS_STDINT_H_) \
+ || defined(_SYS_INTTYPES_H) \
+ || defined(_SYS_INTTYPES_H_) \
+ || defined(_STDINT_H_INCLUDED) \
+ || defined(_MSC_STDINT_H_) \
+ || defined(_PSTDINT_H_INCLUDED)
+ /* Assume that exact-width integer types have already been defined. */
+#elif NiFpga_VxWorks
+ /* VxWorks (at least 6.3 and earlier) did not have stdint.h. */
+ #include <types/vxTypes.h>
+#elif NiFpga_C99 \
+ || NiFpga_Gcc /* GCC (at least since 3.0) has a stdint.h. */ \
+ || defined(HAVE_STDINT_H)
+ /* Assume that stdint.h can be included. */
+ #include <stdint.h>
+#elif NiFpga_Msvc \
+ || NiFpga_Cvi
+ /* Manually define exact-width integer types. */
+ typedef signed char int8_t;
+ typedef unsigned char uint8_t;
+ typedef short int16_t;
+ typedef unsigned short uint16_t;
+ typedef int int32_t;
+ typedef unsigned int uint32_t;
+ typedef __int64 int64_t;
+ typedef unsigned __int64 uint64_t;
+#else
+ /*
+ * Exact-width integer types must be defined by the user, and the following
+ * macro must be #defined, before #including NiFpga.h:
+ *
+ * #define NiFpga_ExactWidthIntegerTypesDefined 1
+ */
+ #error Exact-width integer types must be defined by the user. See comment.
+#endif
+
+/* Included for definition of size_t. */
+#include <stddef.h>
+
+#if NiFpga_Cpp
+extern "C"
+{
+#endif
+
+/**
+ * A boolean value; either NiFpga_False or NiFpga_True.
+ */
+typedef uint8_t NiFpga_Bool;
+
+/**
+ * Represents a false condition.
+ */
+static const NiFpga_Bool NiFpga_False = 0;
+
+/**
+ * Represents a true condition.
+ */
+static const NiFpga_Bool NiFpga_True = 1;
+
+/**
+ * Represents the resulting status of a function call through its return value.
+ * 0 is success, negative values are errors, and positive values are warnings.
+ */
+typedef int32_t NiFpga_Status;
+
+/**
+ * No errors or warnings.
+ */
+static const NiFpga_Status NiFpga_Status_Success = 0;
+
+/**
+ * The timeout expired before the FIFO operation could complete.
+ */
+static const NiFpga_Status NiFpga_Status_FifoTimeout = -50400;
+
+/**
+ * A memory allocation failed. Try again after rebooting.
+ */
+static const NiFpga_Status NiFpga_Status_MemoryFull = -52000;
+
+/**
+ * An unexpected software error occurred.
+ */
+static const NiFpga_Status NiFpga_Status_SoftwareFault = -52003;
+
+/**
+ * A parameter to a function was not valid. This could be a NULL pointer, a bad
+ * value, etc.
+ */
+static const NiFpga_Status NiFpga_Status_InvalidParameter = -52005;
+
+/**
+ * A required resource was not found. The NiFpga.* library, the RIO resource, or
+ * some other resource may be missing.
+ */
+static const NiFpga_Status NiFpga_Status_ResourceNotFound = -52006;
+
+/**
+ * A required resource was not properly initialized. This could occur if
+ * NiFpga_Initialize was not called or a required NiFpga_IrqContext was not
+ * reserved.
+ */
+static const NiFpga_Status NiFpga_Status_ResourceNotInitialized = -52010;
+
+/**
+ * The FPGA is already running.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaAlreadyRunning = -61003;
+
+/**
+ * An error occurred downloading the VI to the FPGA device. Verify that
+ * the target is connected and powered and that the resource of the target
+ * is properly configured.
+ */
+static const NiFpga_Status NiFpga_Status_DownloadError = -61018;
+
+/**
+ * The bitfile was not compiled for the specified resource's device type.
+ */
+static const NiFpga_Status NiFpga_Status_DeviceTypeMismatch = -61024;
+
+/**
+ * An error was detected in the communication between the host computer and the
+ * FPGA target.
+ */
+static const NiFpga_Status NiFpga_Status_CommunicationTimeout = -61046;
+
+/**
+ * The timeout expired before any of the IRQs were asserted.
+ */
+static const NiFpga_Status NiFpga_Status_IrqTimeout = -61060;
+
+/**
+ * The specified bitfile is invalid or corrupt.
+ */
+static const NiFpga_Status NiFpga_Status_CorruptBitfile = -61070;
+
+/**
+ * The requested FIFO depth is invalid. It is either 0 or an amount not
+ * supported by the hardware.
+ */
+static const NiFpga_Status NiFpga_Status_BadDepth = -61072;
+
+/**
+ * The number of FIFO elements is invalid. Either the number is greater than the
+ * depth of the host memory DMA FIFO, or more elements were requested for
+ * release than had been acquired.
+ */
+static const NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073;
+
+/**
+ * A hardware clocking error occurred. A derived clock lost lock with its base
+ * clock during the execution of the LabVIEW FPGA VI. If any base clocks with
+ * derived clocks are referencing an external source, make sure that the
+ * external source is connected and within the supported frequency, jitter,
+ * accuracy, duty cycle, and voltage specifications. Also verify that the
+ * characteristics of the base clock match the configuration specified in the
+ * FPGA Base Clock Properties. If all base clocks with derived clocks are
+ * generated from free-running, on-board sources, please contact National
+ * Instruments technical support at ni.com/support.
+ */
+static const NiFpga_Status NiFpga_Status_ClockLostLock = -61083;
+
+/**
+ * The operation could not be performed because the FPGA is busy. Stop all
+ * activities on the FPGA before requesting this operation. If the target is in
+ * Scan Interface programming mode, put it in FPGA Interface programming mode.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaBusy = -61141;
+
+/**
+ * The operation could not be performed because the FPGA is busy operating in
+ * FPGA Interface C API mode. Stop all activities on the FPGA before requesting
+ * this operation.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterfaceCApi = -61200;
+
+/**
+ * The chassis is in Scan Interface programming mode. In order to run FPGA VIs,
+ * you must go to the chassis properties page, select FPGA programming mode, and
+ * deploy settings.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaBusyScanInterface = -61201;
+
+/**
+ * The operation could not be performed because the FPGA is busy operating in
+ * FPGA Interface mode. Stop all activities on the FPGA before requesting this
+ * operation.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterface = -61202;
+
+/**
+ * The operation could not be performed because the FPGA is busy operating in
+ * Interactive mode. Stop all activities on the FPGA before requesting this
+ * operation.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaBusyInteractive = -61203;
+
+/**
+ * The operation could not be performed because the FPGA is busy operating in
+ * Emulation mode. Stop all activities on the FPGA before requesting this
+ * operation.
+ */
+static const NiFpga_Status NiFpga_Status_FpgaBusyEmulation = -61204;
+
+/**
+ * LabVIEW FPGA does not support the Reset method for bitfiles that allow
+ * removal of implicit enable signals in single-cycle Timed Loops.
+ */
+static const NiFpga_Status NiFpga_Status_ResetCalledWithImplicitEnableRemoval = -61211;
+
+/**
+ * LabVIEW FPGA does not support the Abort method for bitfiles that allow
+ * removal of implicit enable signals in single-cycle Timed Loops.
+ */
+static const NiFpga_Status NiFpga_Status_AbortCalledWithImplicitEnableRemoval = -61212;
+
+/**
+ * LabVIEW FPGA does not support Close and Reset if Last Reference for bitfiles
+ * that allow removal of implicit enable signals in single-cycle Timed Loops.
+ * Pass the NiFpga_CloseAttribute_NoResetIfLastSession attribute to NiFpga_Close
+ * instead of 0.
+ */
+static const NiFpga_Status NiFpga_Status_CloseAndResetCalledWithImplicitEnableRemoval = -61213;
+
+/**
+ * For bitfiles that allow removal of implicit enable signals in single-cycle
+ * Timed Loops, LabVIEW FPGA does not support this method prior to running the
+ * bitfile.
+ */
+static const NiFpga_Status NiFpga_Status_ImplicitEnableRemovalButNotYetRun = -61214;
+
+/**
+ * Bitfiles that allow removal of implicit enable signals in single-cycle Timed
+ * Loops can run only once. Download the bitfile again before re-running the VI.
+ */
+static const NiFpga_Status NiFpga_Status_RunAfterStoppedCalledWithImplicitEnableRemoval = -61215;
+
+/**
+ * A gated clock has violated the handshaking protocol. If you are using
+ * external gated clocks, ensure that they follow the required clock gating
+ * protocol. If you are generating your clocks internally, please contact
+ * National Instruments Technical Support.
+ */
+static const NiFpga_Status NiFpga_Status_GatedClockHandshakingViolation = -61216;
+
+/**
+ * The number of elements requested must be less than or equal to the number of
+ * unacquired elements left in the host memory DMA FIFO. There are currently
+ * fewer unacquired elements left in the FIFO than are being requested. Release
+ * some acquired elements before acquiring more elements.
+ */
+static const NiFpga_Status NiFpga_Status_ElementsNotPermissibleToBeAcquired = -61219;
+
+/**
+ * An unexpected internal error occurred.
+ */
+static const NiFpga_Status NiFpga_Status_InternalError = -61499;
+
+/**
+ * The NI-RIO driver was unable to allocate memory for a FIFO. This can happen
+ * when the combined depth of all DMA FIFOs exceeds the maximum depth for the
+ * controller, or when the controller runs out of system memory. You may be able
+ * to reconfigure the controller with a greater maximum FIFO depth. For more
+ * information, refer to the NI KnowledgeBase article 65OF2ERQ.
+ */
+static const NiFpga_Status NiFpga_Status_TotalDmaFifoDepthExceeded = -63003;
+
+/**
+ * Access to the remote system was denied. Use MAX to check the Remote Device
+ * Access settings under Software>>NI-RIO>>NI-RIO Settings on the remote system.
+ */
+static const NiFpga_Status NiFpga_Status_AccessDenied = -63033;
+
+/**
+ * The NI-RIO software on the host is not compatible with the software on the
+ * target. Upgrade the NI-RIO software on the host in order to connect to this
+ * target.
+ */
+static const NiFpga_Status NiFpga_Status_HostVersionMismatch = -63038;
+
+/**
+ * A connection could not be established to the specified remote device. Ensure
+ * that the device is on and accessible over the network, that NI-RIO software
+ * is installed, and that the RIO server is running and properly configured.
+ */
+static const NiFpga_Status NiFpga_Status_RpcConnectionError = -63040;
+
+/**
+ * The RPC session is invalid. The target may have reset or been rebooted. Check
+ * the network connection and retry the operation.
+ */
+static const NiFpga_Status NiFpga_Status_RpcSessionError = -63043;
+
+/**
+ * The operation could not complete because another session is accessing the
+ * FIFO. Close the other session and retry.
+ */
+static const NiFpga_Status NiFpga_Status_FifoReserved = -63082;
+
+/**
+ * A Configure FIFO, Stop FIFO, Read FIFO, or Write FIFO function was called
+ * while the host had acquired elements of the FIFO. Release all acquired
+ * elements before configuring, stopping, reading, or writing.
+ */
+static const NiFpga_Status NiFpga_Status_FifoElementsCurrentlyAcquired = -63083;
+
+/**
+ * A function was called using a misaligned address. The address must be a
+ * multiple of the size of the datatype.
+ */
+static const NiFpga_Status NiFpga_Status_MisalignedAccess = -63084;
+
+/**
+ * The FPGA Read/Write Control Function is accessing a control or indicator
+ * with data that exceeds the maximum size supported on the current target.
+ * Refer to the hardware documentation for the limitations on data types for
+ * this target.
+ */
+static const NiFpga_Status NiFpga_Status_ControlOrIndicatorTooLarge = -63085;
+
+/**
+ * A valid .lvbitx bitfile is required. If you are using a valid .lvbitx
+ * bitfile, the bitfile may not be compatible with the software you are using.
+ * Determine which version of LabVIEW was used to make the bitfile, update your
+ * software to that version or later, and try again.
+ */
+static const NiFpga_Status NiFpga_Status_BitfileReadError = -63101;
+
+/**
+ * The specified signature does not match the signature of the bitfile. If the
+ * bitfile has been recompiled, regenerate the C API and rebuild the
+ * application.
+ */
+static const NiFpga_Status NiFpga_Status_SignatureMismatch = -63106;
+
+/**
+ * The bitfile you are trying to use is not compatible with the version of
+ * NI-RIO installed on the target and/or the host. Determine which versions of
+ * NI-RIO and LabVIEW were used to make the bitfile, update the software on the
+ * target and host to that version or later, and try again.
+ */
+static const NiFpga_Status NiFpga_Status_IncompatibleBitfile = -63107;
+
+/**
+ * Either the supplied resource name is invalid as a RIO resource name, or the
+ * device was not found. Use MAX to find the proper resource name for the
+ * intended device.
+ */
+static const NiFpga_Status NiFpga_Status_InvalidResourceName = -63192;
+
+/**
+ * The requested feature is not supported.
+ */
+static const NiFpga_Status NiFpga_Status_FeatureNotSupported = -63193;
+
+/**
+ * The NI-RIO software on the target system is not compatible with this
+ * software. Upgrade the NI-RIO software on the target system.
+ */
+static const NiFpga_Status NiFpga_Status_VersionMismatch = -63194;
+
+/**
+ * The session is invalid or has been closed.
+ */
+static const NiFpga_Status NiFpga_Status_InvalidSession = -63195;
+
+/**
+ * The maximum number of open FPGA sessions has been reached. Close some open
+ * sessions.
+ */
+static const NiFpga_Status NiFpga_Status_OutOfHandles = -63198;
+
+/**
+ * Tests whether a status is an error.
+ *
+ * @param status status to check for an error
+ * @return whether the status was an error
+ */
+static NiFpga_Inline NiFpga_Bool NiFpga_IsError(const NiFpga_Status status)
+{
+ return status < NiFpga_Status_Success;
+}
+
+/**
+ * Tests whether a status is not an error. Success and warnings are not errors.
+ *
+ * @param status status to check for an error
+ * @return whether the status was a success or warning
+ */
+static NiFpga_Inline NiFpga_Bool NiFpga_IsNotError(const NiFpga_Status status)
+{
+ return status >= NiFpga_Status_Success;
+}
+
+/**
+ * Conditionally sets the status to a new value. The previous status is
+ * preserved unless the new status is more of an error, which means that
+ * warnings and errors overwrite successes, and errors overwrite warnings. New
+ * errors do not overwrite older errors, and new warnings do not overwrite
+ * older warnings.
+ *
+ * @param status status to conditionally set
+ * @param newStatus new status value that may be set
+ * @return the resulting status
+ */
+static NiFpga_Inline NiFpga_Status NiFpga_MergeStatus(
+ NiFpga_Status* const status,
+ const NiFpga_Status newStatus)
+{
+ if (!status)
+ return NiFpga_Status_InvalidParameter;
+ if (NiFpga_IsNotError(*status)
+ && (*status == NiFpga_Status_Success || NiFpga_IsError(newStatus)))
+ *status = newStatus;
+ return *status;
+}
+
+/**
+ * This macro evaluates the expression only if the status is not an error. The
+ * expression must evaluate to an NiFpga_Status, such as a call to any NiFpga_*
+ * function, because the status will be set to the returned status if the
+ * expression is evaluated.
+ *
+ * You can use this macro to mimic status chaining in LabVIEW, where the status
+ * does not have to be explicitly checked after each call. Such code may look
+ * like the following example.
+ *
+ * NiFpga_Status status = NiFpga_Status_Success;
+ * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...));
+ * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...));
+ * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...));
+ *
+ * @param status status to check for an error
+ * @param expression expression to call if the incoming status is not an error
+ */
+#define NiFpga_IfIsNotError(status, expression) \
+ if (NiFpga_IsNotError(status)) \
+ NiFpga_MergeStatus(&status, (expression)); \
+
+/**
+ * You must call this function before all other function calls. This function
+ * loads the NiFpga library so that all the other functions will work. If this
+ * function succeeds, you must call NiFpga_Finalize after all other function
+ * calls.
+ *
+ * @warning This function is not thread safe.
+ *
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Initialize(void);
+
+/**
+ * You must call this function after all other function calls if
+ * NiFpga_Initialize succeeds. This function unloads the NiFpga library.
+ *
+ * @warning This function is not thread safe.
+ *
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Finalize(void);
+
+/**
+ * A handle to an FPGA session.
+ */
+typedef uint32_t NiFpga_Session;
+
+/**
+ * Attributes that NiFpga_Open accepts.
+ */
+typedef enum
+{
+ NiFpga_OpenAttribute_NoRun = 1
+} NiFpga_OpenAttribute;
+
+/**
+ * Opens a session to the FPGA. This call ensures that the contents of the
+ * bitfile are programmed to the FPGA. The FPGA runs unless the
+ * NiFpga_OpenAttribute_NoRun attribute is used.
+ *
+ * Because different operating systems have different default current working
+ * directories for applications, you must pass an absolute path for the bitfile
+ * parameter. If you pass only the filename instead of an absolute path, the
+ * operating system may not be able to locate the bitfile. For example, the
+ * default current working directories are C:\ni-rt\system\ for Phar Lap ETS and
+ * /c/ for VxWorks. Because the generated *_Bitfile constant is a #define to a
+ * string literal, you can use C/C++ string-literal concatenation to form an
+ * absolute path. For example, if the bitfile is in the root directory of a
+ * Phar Lap ETS system, pass the following for the bitfile parameter.
+ *
+ * "C:\\" NiFpga_MyApplication_Bitfile
+ *
+ * @param bitfile path to the bitfile
+ * @param signature signature of the bitfile
+ * @param resource RIO resource string to open ("RIO0" or "rio://mysystem/RIO")
+ * @param attribute bitwise OR of any NiFpga_OpenAttributes, or 0
+ * @param session outputs the session handle, which must be closed when no
+ * longer needed
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Open(const char* bitfile,
+ const char* signature,
+ const char* resource,
+ uint32_t attribute,
+ NiFpga_Session* session);
+
+/**
+ * Attributes that NiFpga_Close accepts.
+ */
+typedef enum
+{
+ NiFpga_CloseAttribute_NoResetIfLastSession = 1
+} NiFpga_CloseAttribute;
+
+/**
+ * Closes the session to the FPGA. The FPGA resets unless either another session
+ * is still open or you use the NiFpga_CloseAttribute_NoResetIfLastSession
+ * attribute.
+ *
+ * @param session handle to a currently open session
+ * @param attribute bitwise OR of any NiFpga_CloseAttributes, or 0
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Close(NiFpga_Session session,
+ uint32_t attribute);
+
+/**
+ * Attributes that NiFpga_Run accepts.
+ */
+typedef enum
+{
+ NiFpga_RunAttribute_WaitUntilDone = 1
+} NiFpga_RunAttribute;
+
+/**
+ * Runs the FPGA VI on the target. If you use NiFpga_RunAttribute_WaitUntilDone,
+ * NiFpga_Run blocks the thread until the FPGA finishes running.
+ *
+ * @param session handle to a currently open session
+ * @param attribute bitwise OR of any NiFpga_RunAttributes, or 0
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Run(NiFpga_Session session,
+ uint32_t attribute);
+
+/**
+ * Aborts the FPGA VI.
+ *
+ * @param session handle to a currently open session
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Abort(NiFpga_Session session);
+
+/**
+ * Resets the FPGA VI.
+ *
+ * @param session handle to a currently open session
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Reset(NiFpga_Session session);
+
+/**
+ * Re-downloads the FPGA bitstream to the target.
+ *
+ * @param session handle to a currently open session
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_Download(NiFpga_Session session);
+
+/**
+ * Reads a boolean value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadBool(NiFpga_Session session,
+ uint32_t indicator,
+ NiFpga_Bool* value);
+
+/**
+ * Reads a signed 8-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadI8(NiFpga_Session session,
+ uint32_t indicator,
+ int8_t* value);
+
+/**
+ * Reads an unsigned 8-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadU8(NiFpga_Session session,
+ uint32_t indicator,
+ uint8_t* value);
+
+/**
+ * Reads a signed 16-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadI16(NiFpga_Session session,
+ uint32_t indicator,
+ int16_t* value);
+
+/**
+ * Reads an unsigned 16-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadU16(NiFpga_Session session,
+ uint32_t indicator,
+ uint16_t* value);
+
+/**
+ * Reads a signed 32-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadI32(NiFpga_Session session,
+ uint32_t indicator,
+ int32_t* value);
+
+/**
+ * Reads an unsigned 32-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadU32(NiFpga_Session session,
+ uint32_t indicator,
+ uint32_t* value);
+
+/**
+ * Reads a signed 64-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadI64(NiFpga_Session session,
+ uint32_t indicator,
+ int64_t* value);
+
+/**
+ * Reads an unsigned 64-bit integer value from a given indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param value outputs the value that was read
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadU64(NiFpga_Session session,
+ uint32_t indicator,
+ uint64_t* value);
+
+/**
+ * Writes a boolean value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteBool(NiFpga_Session session,
+ uint32_t control,
+ NiFpga_Bool value);
+
+/**
+ * Writes a signed 8-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteI8(NiFpga_Session session,
+ uint32_t control,
+ int8_t value);
+
+/**
+ * Writes an unsigned 8-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteU8(NiFpga_Session session,
+ uint32_t control,
+ uint8_t value);
+
+/**
+ * Writes a signed 16-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteI16(NiFpga_Session session,
+ uint32_t control,
+ int16_t value);
+
+/**
+ * Writes an unsigned 16-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteU16(NiFpga_Session session,
+ uint32_t control,
+ uint16_t value);
+
+/**
+ * Writes a signed 32-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteI32(NiFpga_Session session,
+ uint32_t control,
+ int32_t value);
+
+/**
+ * Writes an unsigned 32-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteU32(NiFpga_Session session,
+ uint32_t control,
+ uint32_t value);
+
+/**
+ * Writes a signed 64-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteI64(NiFpga_Session session,
+ uint32_t control,
+ int64_t value);
+
+/**
+ * Writes an unsigned 64-bit integer value to a given control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param value value to write
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteU64(NiFpga_Session session,
+ uint32_t control,
+ uint64_t value);
+
+/**
+ * Reads an entire array of boolean values from a given array indicator or
+ * control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayBool(NiFpga_Session session,
+ uint32_t indicator,
+ NiFpga_Bool* array,
+ size_t size);
+
+/**
+ * Reads an entire array of signed 8-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayI8(NiFpga_Session session,
+ uint32_t indicator,
+ int8_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of unsigned 8-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayU8(NiFpga_Session session,
+ uint32_t indicator,
+ uint8_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of signed 16-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayI16(NiFpga_Session session,
+ uint32_t indicator,
+ int16_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of unsigned 16-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayU16(NiFpga_Session session,
+ uint32_t indicator,
+ uint16_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of signed 32-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayI32(NiFpga_Session session,
+ uint32_t indicator,
+ int32_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of unsigned 32-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayU32(NiFpga_Session session,
+ uint32_t indicator,
+ uint32_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of signed 64-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayI64(NiFpga_Session session,
+ uint32_t indicator,
+ int64_t* array,
+ size_t size);
+
+/**
+ * Reads an entire array of unsigned 64-bit integer values from a given array
+ * indicator or control.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * indicator or control.
+ *
+ * @param session handle to a currently open session
+ * @param indicator indicator or control from which to read
+ * @param array outputs the entire array that was read
+ * @param size exact number of elements in the indicator or control
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadArrayU64(NiFpga_Session session,
+ uint32_t indicator,
+ uint64_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of boolean values to a given array control or
+ * indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayBool(NiFpga_Session session,
+ uint32_t control,
+ const NiFpga_Bool* array,
+ size_t size);
+
+/**
+ * Writes an entire array of signed 8-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayI8(NiFpga_Session session,
+ uint32_t control,
+ const int8_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of unsigned 8-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayU8(NiFpga_Session session,
+ uint32_t control,
+ const uint8_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of signed 16-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayI16(NiFpga_Session session,
+ uint32_t control,
+ const int16_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of unsigned 16-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayU16(NiFpga_Session session,
+ uint32_t control,
+ const uint16_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of signed 32-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayI32(NiFpga_Session session,
+ uint32_t control,
+ const int32_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of unsigned 32-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayU32(NiFpga_Session session,
+ uint32_t control,
+ const uint32_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of signed 64-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayI64(NiFpga_Session session,
+ uint32_t control,
+ const int64_t* array,
+ size_t size);
+
+/**
+ * Writes an entire array of unsigned 64-bit integer values to a given array
+ * control or indicator.
+ *
+ * @warning The size passed must be the exact number of elements in the
+ * control or indicator.
+ *
+ * @param session handle to a currently open session
+ * @param control control or indicator to which to write
+ * @param array entire array to write
+ * @param size exact number of elements in the control or indicator
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteArrayU64(NiFpga_Session session,
+ uint32_t control,
+ const uint64_t* array,
+ size_t size);
+
+/**
+ * Enumeration of all 32 possible IRQs. Multiple IRQs can be bitwise ORed
+ * together like this:
+ *
+ * NiFpga_Irq_3 | NiFpga_Irq_23
+ */
+typedef enum
+{
+ NiFpga_Irq_0 = 1 << 0,
+ NiFpga_Irq_1 = 1 << 1,
+ NiFpga_Irq_2 = 1 << 2,
+ NiFpga_Irq_3 = 1 << 3,
+ NiFpga_Irq_4 = 1 << 4,
+ NiFpga_Irq_5 = 1 << 5,
+ NiFpga_Irq_6 = 1 << 6,
+ NiFpga_Irq_7 = 1 << 7,
+ NiFpga_Irq_8 = 1 << 8,
+ NiFpga_Irq_9 = 1 << 9,
+ NiFpga_Irq_10 = 1 << 10,
+ NiFpga_Irq_11 = 1 << 11,
+ NiFpga_Irq_12 = 1 << 12,
+ NiFpga_Irq_13 = 1 << 13,
+ NiFpga_Irq_14 = 1 << 14,
+ NiFpga_Irq_15 = 1 << 15,
+ NiFpga_Irq_16 = 1 << 16,
+ NiFpga_Irq_17 = 1 << 17,
+ NiFpga_Irq_18 = 1 << 18,
+ NiFpga_Irq_19 = 1 << 19,
+ NiFpga_Irq_20 = 1 << 20,
+ NiFpga_Irq_21 = 1 << 21,
+ NiFpga_Irq_22 = 1 << 22,
+ NiFpga_Irq_23 = 1 << 23,
+ NiFpga_Irq_24 = 1 << 24,
+ NiFpga_Irq_25 = 1 << 25,
+ NiFpga_Irq_26 = 1 << 26,
+ NiFpga_Irq_27 = 1 << 27,
+ NiFpga_Irq_28 = 1 << 28,
+ NiFpga_Irq_29 = 1 << 29,
+ NiFpga_Irq_30 = 1 << 30,
+ NiFpga_Irq_31 = 1U << 31
+} NiFpga_Irq;
+
+/**
+ * Represents an infinite timeout.
+ */
+static const uint32_t NiFpga_InfiniteTimeout = 0xFFFFFFFF;
+
+/**
+ * See NiFpga_ReserveIrqContext for more information.
+ */
+typedef void* NiFpga_IrqContext;
+
+/**
+ * IRQ contexts are single-threaded; only one thread can wait with a particular
+ * context at any given time. Clients must reserve as many contexts as the
+ * application requires.
+ *
+ * If a context is successfully reserved (the returned status is not an error),
+ * it must be unreserved later. Otherwise a memory leak will occur.
+ *
+ * @param session handle to a currently open session
+ * @param context outputs the IRQ context
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReserveIrqContext(NiFpga_Session session,
+ NiFpga_IrqContext* context);
+
+/**
+ * Unreserves an IRQ context obtained from NiFpga_ReserveIrqContext.
+ *
+ * @param session handle to a currently open session
+ * @param context IRQ context to unreserve
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_UnreserveIrqContext(NiFpga_Session session,
+ NiFpga_IrqContext context);
+
+/**
+ * This is a blocking function that stops the calling thread until the FPGA
+ * asserts any IRQ in the irqs parameter, or until the function call times out.
+ * Before calling this function, you must use NiFpga_ReserveIrqContext to
+ * reserve an IRQ context. No other threads can use the same context when this
+ * function is called.
+ *
+ * You can use the irqsAsserted parameter to determine which IRQs were asserted
+ * for each function call.
+ *
+ * @param session handle to a currently open session
+ * @param context IRQ context with which to wait
+ * @param irqs bitwise OR of NiFpga_Irqs
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param irqsAsserted if non-NULL, outputs bitwise OR of IRQs that were
+ * asserted
+ * @param timedOut if non-NULL, outputs whether the timeout expired
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WaitOnIrqs(NiFpga_Session session,
+ NiFpga_IrqContext context,
+ uint32_t irqs,
+ uint32_t timeout,
+ uint32_t* irqsAsserted,
+ NiFpga_Bool* timedOut);
+
+/**
+ * Acknowledges an IRQ or set of IRQs.
+ *
+ * @param session handle to a currently open session
+ * @param irqs bitwise OR of NiFpga_Irqs
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcknowledgeIrqs(NiFpga_Session session,
+ uint32_t irqs);
+
+/**
+ * Specifies the depth of the host memory part of the DMA FIFO. This method is
+ * optional. In order to see the actual depth configured, use
+ * NiFpga_ConfigureFifo2.
+ *
+ * @param session handle to a currently open session
+ * @param fifo FIFO to configure
+ * @param depth requested number of elements in the host memory part of the
+ * DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ConfigureFifo(NiFpga_Session session,
+ uint32_t fifo,
+ size_t depth);
+
+/**
+ * Specifies the depth of the host memory part of the DMA FIFO. This method is
+ * optional.
+ *
+ * @param session handle to a currently open session
+ * @param fifo FIFO to configure
+ * @param requestedDepth requested number of elements in the host memory part
+ * of the DMA FIFO
+ * @param actualDepth if non-NULL, outputs the actual number of elements in the
+ * host memory part of the DMA FIFO, which may be more than
+ * the requested number
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ConfigureFifo2(NiFpga_Session session,
+ uint32_t fifo,
+ size_t requestedDepth,
+ size_t* actualDepth);
+
+/**
+ * Starts a FIFO. This method is optional.
+ *
+ * @param session handle to a currently open session
+ * @param fifo FIFO to start
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_StartFifo(NiFpga_Session session,
+ uint32_t fifo);
+
+/**
+ * Stops a FIFO. This method is optional.
+ *
+ * @param session handle to a currently open session
+ * @param fifo FIFO to stop
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_StopFifo(NiFpga_Session session,
+ uint32_t fifo);
+
+/**
+ * Reads from a target-to-host FIFO of booleans.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoBool(NiFpga_Session session,
+ uint32_t fifo,
+ NiFpga_Bool* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of signed 8-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoI8(NiFpga_Session session,
+ uint32_t fifo,
+ int8_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of unsigned 8-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoU8(NiFpga_Session session,
+ uint32_t fifo,
+ uint8_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of signed 16-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoI16(NiFpga_Session session,
+ uint32_t fifo,
+ int16_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of unsigned 16-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoU16(NiFpga_Session session,
+ uint32_t fifo,
+ uint16_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of signed 32-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoI32(NiFpga_Session session,
+ uint32_t fifo,
+ int32_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of unsigned 32-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoU32(NiFpga_Session session,
+ uint32_t fifo,
+ uint32_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of signed 64-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoI64(NiFpga_Session session,
+ uint32_t fifo,
+ int64_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Reads from a target-to-host FIFO of unsigned 64-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param data outputs the data that was read
+ * @param numberOfElements number of elements to read
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReadFifoU64(NiFpga_Session session,
+ uint32_t fifo,
+ uint64_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* elementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of booleans.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoBool(NiFpga_Session session,
+ uint32_t fifo,
+ const NiFpga_Bool* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of signed 8-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoI8(NiFpga_Session session,
+ uint32_t fifo,
+ const int8_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of unsigned 8-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoU8(NiFpga_Session session,
+ uint32_t fifo,
+ const uint8_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of signed 16-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoI16(NiFpga_Session session,
+ uint32_t fifo,
+ const int16_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of unsigned 16-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoU16(NiFpga_Session session,
+ uint32_t fifo,
+ const uint16_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of signed 32-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoI32(NiFpga_Session session,
+ uint32_t fifo,
+ const int32_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of unsigned 32-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoU32(NiFpga_Session session,
+ uint32_t fifo,
+ const uint32_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of signed 64-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoI64(NiFpga_Session session,
+ uint32_t fifo,
+ const int64_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Writes to a host-to-target FIFO of unsigned 64-bit integers.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param data data to write
+ * @param numberOfElements number of elements to write
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param emptyElementsRemaining if non-NULL, outputs the number of empty
+ * elements remaining in the host memory part of
+ * the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_WriteFifoU64(NiFpga_Session session,
+ uint32_t fifo,
+ const uint64_t* data,
+ size_t numberOfElements,
+ uint32_t timeout,
+ size_t* emptyElementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of booleans.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsBool(
+ NiFpga_Session session,
+ uint32_t fifo,
+ NiFpga_Bool** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of signed 8-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsI8(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int8_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of unsigned 8-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsU8(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint8_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of signed 16-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsI16(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int16_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of unsigned 16-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsU16(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint16_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of signed 32-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsI32(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int32_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of unsigned 32-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsU32(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint32_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of signed 64-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsI64(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int64_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for reading from a target-to-host FIFO of unsigned 64-bit
+ * integers.
+ *
+ * Acquiring, reading, and releasing FIFO elements prevents the need to copy
+ * the contents of elements from the host memory buffer to a separate
+ * user-allocated buffer before reading. The FPGA target cannot write to
+ * elements acquired by the host. Therefore, the host must release elements
+ * after reading them. The number of elements acquired may differ from the
+ * number of elements requested if, for example, the number of elements
+ * requested reaches the end of the host memory buffer. Always release all
+ * acquired elements before closing the session. Do not attempt to access FIFO
+ * elements after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo target-to-host FIFO from which to read
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoReadElementsU64(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint64_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of booleans.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsBool(
+ NiFpga_Session session,
+ uint32_t fifo,
+ NiFpga_Bool** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of signed 8-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsI8(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int8_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of unsigned 8-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsU8(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint8_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of signed 16-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsI16(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int16_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of unsigned 16-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsU16(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint16_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of signed 32-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsI32(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int32_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of unsigned 32-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsU32(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint32_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of signed 64-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsI64(
+ NiFpga_Session session,
+ uint32_t fifo,
+ int64_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Acquires elements for writing to a host-to-target FIFO of unsigned 64-bit
+ * integers.
+ *
+ * Acquiring, writing, and releasing FIFO elements prevents the need to write
+ * first into a separate user-allocated buffer and then copy the contents of
+ * elements to the host memory buffer. The FPGA target cannot read elements
+ * acquired by the host. Therefore, the host must release elements after
+ * writing to them. The number of elements acquired may differ from the number
+ * of elements requested if, for example, the number of elements requested
+ * reaches the end of the host memory buffer. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo host-to-target FIFO to which to write
+ * @param elements outputs a pointer to the elements acquired
+ * @param elementsRequested requested number of elements
+ * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout
+ * @param elementsAcquired actual number of elements acquired, which may be
+ * less than the requested number
+ * @param elementsRemaining if non-NULL, outputs the number of elements
+ * remaining in the host memory part of the DMA FIFO
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_AcquireFifoWriteElementsU64(
+ NiFpga_Session session,
+ uint32_t fifo,
+ uint64_t** elements,
+ size_t elementsRequested,
+ uint32_t timeout,
+ size_t* elementsAcquired,
+ size_t* elementsRemaining);
+
+/**
+ * Releases previously acquired FIFO elements.
+ *
+ * The FPGA target cannot read elements acquired by the host. Therefore, the
+ * host must release elements after acquiring them. Always release all acquired
+ * elements before closing the session. Do not attempt to access FIFO elements
+ * after the elements are released or the session is closed.
+ *
+ * @param session handle to a currently open session
+ * @param fifo FIFO from which to release elements
+ * @param elements number of elements to release
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_ReleaseFifoElements(NiFpga_Session session,
+ uint32_t fifo,
+ size_t elements);
+
+/**
+ * Gets an endpoint reference to a peer-to-peer FIFO.
+ *
+ * @param session handle to a currently open session
+ * @param fifo peer-to-peer FIFO
+ * @param endpoint outputs the endpoint reference
+ * @return result of the call
+ */
+NiFpga_Status NiFpga_GetPeerToPeerFifoEndpoint(NiFpga_Session session,
+ uint32_t fifo,
+ uint32_t* endpoint);
+
+#if NiFpga_Cpp
+}
+#endif
+
+#endif
diff --git a/aos/externals/WPILib/WPILib/ChipObject/printFpgaVersion.h b/aos/externals/WPILib/WPILib/ChipObject/printFpgaVersion.h
new file mode 100644
index 0000000..044e0ef
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/ChipObject/printFpgaVersion.h
@@ -0,0 +1,42 @@
+// Copyright (c) National Instruments 2008. All Rights Reserved.
+
+#ifndef __printFPGAVersion_h__
+#define __printFPGAVersion_h__
+
+namespace nFPGA
+{
+
+template<typename ttGlobal>
+inline void printFPGAVersion(ttGlobal &global)
+{
+ tRioStatusCode cleanStatus=0;
+ uint32_t hardwareGuid[4];
+ tSystemInterface &system = *global.getSystemInterface();
+ system.getHardwareFpgaSignature(hardwareGuid, &cleanStatus);
+ const uint32_t *softwareGuid = system.getExpectedFPGASignature();
+ printf("FPGA Hardware GUID: 0x");
+ for(int i=0; i<4; i++)
+ {
+ printf("%08X", hardwareGuid[i]);
+ }
+ printf("\n");
+ printf("FPGA Software GUID: 0x");
+ for(int i=0; i<4; i++)
+ {
+ printf("%08X", softwareGuid[i]);
+ }
+ printf("\n");
+ uint16_t fpgaHardwareVersion = global.readVersion(&cleanStatus);
+ uint16_t fpgaSoftwareVersion = system.getExpectedFPGAVersion();
+ printf("FPGA Hardware Version: %X\n", fpgaHardwareVersion);
+ printf("FPGA Software Version: %X\n", fpgaSoftwareVersion);
+ uint32_t fpgaHardwareRevision = global.readRevision(&cleanStatus);
+ uint32_t fpgaSoftwareRevision = system.getExpectedFPGARevision();
+ printf("FPGA Hardware Revision: %X.%X.%X\n", (fpgaHardwareRevision >> 20) & 0xFFF, (fpgaHardwareRevision >> 12) & 0xFF, fpgaHardwareRevision & 0xFFF);
+ printf("FPGA Software Revision: %X.%X.%X\n", (fpgaSoftwareRevision >> 20) & 0xFFF, (fpgaSoftwareRevision >> 12) & 0xFF, fpgaSoftwareRevision & 0xFFF);
+}
+
+}
+
+#endif // __tSystemInterface_h__
+
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tAI.h b/aos/externals/WPILib/WPILib/ChipObject/tAI.h
index 38b3f8e..6316af6 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tAI.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tAI.h
@@ -30,9 +30,15 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Channel : 3;
unsigned Module : 1;
unsigned Averaged : 1;
+#else
+ unsigned Averaged : 1;
+ unsigned Module : 1;
+ unsigned Channel : 3;
+#endif
};
struct{
unsigned value : 5;
@@ -41,8 +47,13 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned ScanSize : 3;
unsigned ConvertRate : 26;
+#else
+ unsigned ConvertRate : 26;
+ unsigned ScanSize : 3;
+#endif
};
struct{
unsigned value : 29;
@@ -64,18 +75,18 @@
typedef enum
{
- kNumScanListElements = 8,
- } tScanList_IfaceConstants;
+ } tLoopTiming_IfaceConstants;
- virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
- virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0;
+ virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0;
typedef enum
{
- } tLoopTiming_IfaceConstants;
+ kNumOversampleBitsElements = 8,
+ } tOversampleBits_IfaceConstants;
- virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0;
+ virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
+ virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0;
typedef enum
@@ -89,11 +100,11 @@
typedef enum
{
- kNumOversampleBitsElements = 8,
- } tOversampleBits_IfaceConstants;
+ kNumScanListElements = 8,
+ } tScanList_IfaceConstants;
- virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
- virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0;
+ virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
+ virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0;
@@ -106,6 +117,13 @@
typedef enum
{
+ } tLatchOutput_IfaceConstants;
+
+ virtual void strobeLatchOutput(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
} tReadSelect_IfaceConstants;
virtual void writeReadSelect(tReadSelect value, tRioStatusCode *status) = 0;
@@ -118,13 +136,6 @@
virtual bool readReadSelect_Averaged(tRioStatusCode *status) = 0;
- typedef enum
- {
- } tLatchOutput_IfaceConstants;
-
- virtual void strobeLatchOutput(tRioStatusCode *status) = 0;
-
-
private:
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tAccumulator.h b/aos/externals/WPILib/WPILib/ChipObject/tAccumulator.h
index 370848c..d182882 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tAccumulator.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tAccumulator.h
@@ -60,19 +60,19 @@
typedef enum
{
- } tReset_IfaceConstants;
-
- virtual void strobeReset(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
} tDeadband_IfaceConstants;
virtual void writeDeadband(signed int value, tRioStatusCode *status) = 0;
virtual signed int readDeadband(tRioStatusCode *status) = 0;
+ typedef enum
+ {
+ } tReset_IfaceConstants;
+
+ virtual void strobeReset(tRioStatusCode *status) = 0;
+
+
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tAlarm.h b/aos/externals/WPILib/WPILib/ChipObject/tAlarm.h
index 2e542a2..a1c2f51 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tAlarm.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tAlarm.h
@@ -30,20 +30,20 @@
typedef enum
{
- } tTriggerTime_IfaceConstants;
-
- virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0;
- virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
} tEnable_IfaceConstants;
virtual void writeEnable(bool value, tRioStatusCode *status) = 0;
virtual bool readEnable(tRioStatusCode *status) = 0;
+ typedef enum
+ {
+ } tTriggerTime_IfaceConstants;
+
+ virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0;
+ virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0;
+
+
private:
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tAnalogTrigger.h b/aos/externals/WPILib/WPILib/ChipObject/tAnalogTrigger.h
index a05f19d..4fabd9c 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tAnalogTrigger.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tAnalogTrigger.h
@@ -30,10 +30,17 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned InHysteresis : 1;
unsigned OverLimit : 1;
unsigned Rising : 1;
unsigned Falling : 1;
+#else
+ unsigned Falling : 1;
+ unsigned Rising : 1;
+ unsigned OverLimit : 1;
+ unsigned InHysteresis : 1;
+#endif
};
struct{
unsigned value : 4;
@@ -42,12 +49,21 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Channel : 3;
unsigned Module : 1;
unsigned Averaged : 1;
unsigned Filter : 1;
unsigned FloatingRollover : 1;
signed RolloverLimit : 8;
+#else
+ signed RolloverLimit : 8;
+ unsigned FloatingRollover : 1;
+ unsigned Filter : 1;
+ unsigned Averaged : 1;
+ unsigned Module : 1;
+ unsigned Channel : 3;
+#endif
};
struct{
unsigned value : 15;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tCounter.h b/aos/externals/WPILib/WPILib/ChipObject/tCounter.h
index 83d409b..200ffb3 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tCounter.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tCounter.h
@@ -30,8 +30,13 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Direction : 1;
signed Value : 31;
+#else
+ signed Value : 31;
+ unsigned Direction : 1;
+#endif
};
struct{
unsigned value : 32;
@@ -40,6 +45,7 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned UpSource_Channel : 4;
unsigned UpSource_Module : 1;
unsigned UpSource_AnalogTrigger : 1;
@@ -57,6 +63,25 @@
unsigned Mode : 2;
unsigned PulseLengthThreshold : 6;
unsigned Enable : 1;
+#else
+ unsigned Enable : 1;
+ unsigned PulseLengthThreshold : 6;
+ unsigned Mode : 2;
+ unsigned DownFallingEdge : 1;
+ unsigned DownRisingEdge : 1;
+ unsigned UpFallingEdge : 1;
+ unsigned UpRisingEdge : 1;
+ unsigned IndexActiveHigh : 1;
+ unsigned IndexSource_AnalogTrigger : 1;
+ unsigned IndexSource_Module : 1;
+ unsigned IndexSource_Channel : 4;
+ unsigned DownSource_AnalogTrigger : 1;
+ unsigned DownSource_Module : 1;
+ unsigned DownSource_Channel : 4;
+ unsigned UpSource_AnalogTrigger : 1;
+ unsigned UpSource_Module : 1;
+ unsigned UpSource_Channel : 4;
+#endif
};
struct{
unsigned value : 32;
@@ -65,9 +90,15 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Period : 23;
signed Count : 8;
unsigned Stalled : 1;
+#else
+ unsigned Stalled : 1;
+ signed Count : 8;
+ unsigned Period : 23;
+#endif
};
struct{
unsigned value : 32;
@@ -76,9 +107,15 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned StallPeriod : 24;
unsigned AverageSize : 7;
unsigned UpdateWhenEmpty : 1;
+#else
+ unsigned UpdateWhenEmpty : 1;
+ unsigned AverageSize : 7;
+ unsigned StallPeriod : 24;
+#endif
};
struct{
unsigned value : 32;
@@ -139,13 +176,6 @@
typedef enum
{
- } tReset_IfaceConstants;
-
- virtual void strobeReset(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
} tTimerOutput_IfaceConstants;
virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0;
@@ -156,6 +186,13 @@
typedef enum
{
+ } tReset_IfaceConstants;
+
+ virtual void strobeReset(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
} tTimerConfig_IfaceConstants;
virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tDIO.h b/aos/externals/WPILib/WPILib/ChipObject/tDIO.h
index 909e72c..d9852c9 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tDIO.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tDIO.h
@@ -30,8 +30,13 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Period : 16;
unsigned MinHigh : 16;
+#else
+ unsigned MinHigh : 16;
+ unsigned Period : 16;
+#endif
};
struct{
unsigned value : 32;
@@ -40,9 +45,15 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned RelayFwd : 8;
unsigned RelayRev : 8;
unsigned I2CHeader : 4;
+#else
+ unsigned I2CHeader : 4;
+ unsigned RelayRev : 8;
+ unsigned RelayFwd : 8;
+#endif
};
struct{
unsigned value : 20;
@@ -51,10 +62,17 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Transaction : 1;
unsigned Done : 1;
unsigned Aborted : 1;
unsigned DataReceivedHigh : 24;
+#else
+ unsigned DataReceivedHigh : 24;
+ unsigned Aborted : 1;
+ unsigned Done : 1;
+ unsigned Transaction : 1;
+#endif
};
struct{
unsigned value : 27;
@@ -63,29 +81,54 @@
typedef
union{
struct{
- unsigned PeriodPower : 4;
- unsigned OutputSelect_0 : 4;
- unsigned OutputSelect_1 : 4;
- unsigned OutputSelect_2 : 4;
- unsigned OutputSelect_3 : 4;
- };
- struct{
- unsigned value : 20;
- };
- } tDO_PWMConfig;
- typedef
- union{
- struct{
+#ifdef __vxworks
unsigned Address : 8;
unsigned BytesToRead : 3;
unsigned BytesToWrite : 3;
unsigned DataToSendHigh : 16;
unsigned BitwiseHandshake : 1;
+#else
+ unsigned BitwiseHandshake : 1;
+ unsigned DataToSendHigh : 16;
+ unsigned BytesToWrite : 3;
+ unsigned BytesToRead : 3;
+ unsigned Address : 8;
+#endif
};
struct{
unsigned value : 31;
};
} tI2CConfig;
+ typedef
+ union{
+ struct{
+#ifdef __vxworks
+ unsigned PeriodPower : 4;
+ unsigned OutputSelect_0 : 4;
+ unsigned OutputSelect_1 : 4;
+ unsigned OutputSelect_2 : 4;
+ unsigned OutputSelect_3 : 4;
+#else
+ unsigned OutputSelect_3 : 4;
+ unsigned OutputSelect_2 : 4;
+ unsigned OutputSelect_1 : 4;
+ unsigned OutputSelect_0 : 4;
+ unsigned PeriodPower : 4;
+#endif
+ };
+ struct{
+ unsigned value : 20;
+ };
+ } tDO_PWMConfig;
+
+
+ typedef enum
+ {
+ kNumFilterSelectElements = 16,
+ } tFilterSelect_IfaceConstants;
+
+ virtual void writeFilterSelect(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
+ virtual unsigned char readFilterSelect(unsigned char bitfield_index, tRioStatusCode *status) = 0;
typedef enum
@@ -106,15 +149,6 @@
typedef enum
{
- kNumFilterSelectElements = 16,
- } tFilterSelect_IfaceConstants;
-
- virtual void writeFilterSelect(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
- virtual unsigned char readFilterSelect(unsigned char bitfield_index, tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
kNumFilterPeriodElements = 3,
} tFilterPeriod_IfaceConstants;
@@ -132,6 +166,14 @@
typedef enum
{
+ } tPulse_IfaceConstants;
+
+ virtual void writePulse(unsigned short value, tRioStatusCode *status) = 0;
+ virtual unsigned short readPulse(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
} tSlowValue_IfaceConstants;
virtual void writeSlowValue(tSlowValue value, tRioStatusCode *status) = 0;
@@ -171,10 +213,10 @@
typedef enum
{
- } tPulse_IfaceConstants;
+ } tPulseLength_IfaceConstants;
- virtual void writePulse(unsigned short value, tRioStatusCode *status) = 0;
- virtual unsigned short readPulse(tRioStatusCode *status) = 0;
+ virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0;
+ virtual unsigned char readPulseLength(tRioStatusCode *status) = 0;
typedef enum
@@ -205,9 +247,20 @@
typedef enum
{
- } tI2CStart_IfaceConstants;
+ } tI2CConfig_IfaceConstants;
- virtual void strobeI2CStart(tRioStatusCode *status) = 0;
+ virtual void writeI2CConfig(tI2CConfig value, tRioStatusCode *status) = 0;
+ virtual void writeI2CConfig_Address(unsigned char value, tRioStatusCode *status) = 0;
+ virtual void writeI2CConfig_BytesToRead(unsigned char value, tRioStatusCode *status) = 0;
+ virtual void writeI2CConfig_BytesToWrite(unsigned char value, tRioStatusCode *status) = 0;
+ virtual void writeI2CConfig_DataToSendHigh(unsigned short value, tRioStatusCode *status) = 0;
+ virtual void writeI2CConfig_BitwiseHandshake(bool value, tRioStatusCode *status) = 0;
+ virtual tI2CConfig readI2CConfig(tRioStatusCode *status) = 0;
+ virtual unsigned char readI2CConfig_Address(tRioStatusCode *status) = 0;
+ virtual unsigned char readI2CConfig_BytesToRead(tRioStatusCode *status) = 0;
+ virtual unsigned char readI2CConfig_BytesToWrite(tRioStatusCode *status) = 0;
+ virtual unsigned short readI2CConfig_DataToSendHigh(tRioStatusCode *status) = 0;
+ virtual bool readI2CConfig_BitwiseHandshake(tRioStatusCode *status) = 0;
typedef enum
@@ -230,28 +283,9 @@
typedef enum
{
- } tPulseLength_IfaceConstants;
+ } tI2CStart_IfaceConstants;
- virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0;
- virtual unsigned char readPulseLength(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
- } tI2CConfig_IfaceConstants;
-
- virtual void writeI2CConfig(tI2CConfig value, tRioStatusCode *status) = 0;
- virtual void writeI2CConfig_Address(unsigned char value, tRioStatusCode *status) = 0;
- virtual void writeI2CConfig_BytesToRead(unsigned char value, tRioStatusCode *status) = 0;
- virtual void writeI2CConfig_BytesToWrite(unsigned char value, tRioStatusCode *status) = 0;
- virtual void writeI2CConfig_DataToSendHigh(unsigned short value, tRioStatusCode *status) = 0;
- virtual void writeI2CConfig_BitwiseHandshake(bool value, tRioStatusCode *status) = 0;
- virtual tI2CConfig readI2CConfig(tRioStatusCode *status) = 0;
- virtual unsigned char readI2CConfig_Address(tRioStatusCode *status) = 0;
- virtual unsigned char readI2CConfig_BytesToRead(tRioStatusCode *status) = 0;
- virtual unsigned char readI2CConfig_BytesToWrite(tRioStatusCode *status) = 0;
- virtual unsigned short readI2CConfig_DataToSendHigh(tRioStatusCode *status) = 0;
- virtual bool readI2CConfig_BitwiseHandshake(tRioStatusCode *status) = 0;
+ virtual void strobeI2CStart(tRioStatusCode *status) = 0;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tDMA.h b/aos/externals/WPILib/WPILib/ChipObject/tDMA.h
index 68fbb92..c46cad2 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tDMA.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tDMA.h
@@ -28,6 +28,7 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Pause : 1;
unsigned Enable_AI0_Low : 1;
unsigned Enable_AI0_High : 1;
@@ -48,6 +49,28 @@
unsigned Enable_Encoders : 1;
unsigned Enable_EncoderTimers : 1;
unsigned ExternalClock : 1;
+#else
+ unsigned ExternalClock : 1;
+ unsigned Enable_EncoderTimers : 1;
+ unsigned Enable_Encoders : 1;
+ unsigned Enable_CounterTimers_High : 1;
+ unsigned Enable_CounterTimers_Low : 1;
+ unsigned Enable_Counters_High : 1;
+ unsigned Enable_Counters_Low : 1;
+ unsigned Enable_AnalogTriggers : 1;
+ unsigned Enable_DI : 1;
+ unsigned Enable_Accumulator1 : 1;
+ unsigned Enable_Accumulator0 : 1;
+ unsigned Enable_AIAveraged1_High : 1;
+ unsigned Enable_AIAveraged1_Low : 1;
+ unsigned Enable_AI1_High : 1;
+ unsigned Enable_AI1_Low : 1;
+ unsigned Enable_AIAveraged0_High : 1;
+ unsigned Enable_AIAveraged0_Low : 1;
+ unsigned Enable_AI0_High : 1;
+ unsigned Enable_AI0_Low : 1;
+ unsigned Pause : 1;
+#endif
};
struct{
unsigned value : 20;
@@ -56,11 +79,19 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned ExternalClockSource_Channel : 4;
unsigned ExternalClockSource_Module : 1;
unsigned ExternalClockSource_AnalogTrigger : 1;
unsigned RisingEdge : 1;
unsigned FallingEdge : 1;
+#else
+ unsigned FallingEdge : 1;
+ unsigned RisingEdge : 1;
+ unsigned ExternalClockSource_AnalogTrigger : 1;
+ unsigned ExternalClockSource_Module : 1;
+ unsigned ExternalClockSource_Channel : 4;
+#endif
};
struct{
unsigned value : 8;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tDMAManager.h b/aos/externals/WPILib/WPILib/ChipObject/tDMAManager.h
index edc774a..ce292b1 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tDMAManager.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tDMAManager.h
@@ -4,7 +4,6 @@
#ifndef __tDMAManager_h__
#define __tDMAManager_h__
-#include "NiRio.h"
#include "tSystem.h"
namespace nFPGA
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tEncoder.h b/aos/externals/WPILib/WPILib/ChipObject/tEncoder.h
index 53a770a..0b68067 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tEncoder.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tEncoder.h
@@ -30,8 +30,13 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Direction : 1;
signed Value : 31;
+#else
+ signed Value : 31;
+ unsigned Direction : 1;
+#endif
};
struct{
unsigned value : 32;
@@ -40,6 +45,7 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned ASource_Channel : 4;
unsigned ASource_Module : 1;
unsigned ASource_AnalogTrigger : 1;
@@ -52,6 +58,20 @@
unsigned IndexActiveHigh : 1;
unsigned Reverse : 1;
unsigned Enable : 1;
+#else
+ unsigned Enable : 1;
+ unsigned Reverse : 1;
+ unsigned IndexActiveHigh : 1;
+ unsigned IndexSource_AnalogTrigger : 1;
+ unsigned IndexSource_Module : 1;
+ unsigned IndexSource_Channel : 4;
+ unsigned BSource_AnalogTrigger : 1;
+ unsigned BSource_Module : 1;
+ unsigned BSource_Channel : 4;
+ unsigned ASource_AnalogTrigger : 1;
+ unsigned ASource_Module : 1;
+ unsigned ASource_Channel : 4;
+#endif
};
struct{
unsigned value : 21;
@@ -60,9 +80,15 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Period : 23;
signed Count : 8;
unsigned Stalled : 1;
+#else
+ unsigned Stalled : 1;
+ signed Count : 8;
+ unsigned Period : 23;
+#endif
};
struct{
unsigned value : 32;
@@ -71,9 +97,15 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned StallPeriod : 24;
unsigned AverageSize : 7;
unsigned UpdateWhenEmpty : 1;
+#else
+ unsigned UpdateWhenEmpty : 1;
+ unsigned AverageSize : 7;
+ unsigned StallPeriod : 24;
+#endif
};
struct{
unsigned value : 32;
@@ -124,13 +156,6 @@
typedef enum
{
- } tReset_IfaceConstants;
-
- virtual void strobeReset(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
} tTimerOutput_IfaceConstants;
virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0;
@@ -141,6 +166,13 @@
typedef enum
{
+ } tReset_IfaceConstants;
+
+ virtual void strobeReset(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
} tTimerConfig_IfaceConstants;
virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tGlobal.h b/aos/externals/WPILib/WPILib/ChipObject/tGlobal.h
index 19faf8d..2dbbbe7 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tGlobal.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tGlobal.h
@@ -37,17 +37,17 @@
typedef enum
{
- } tFPGA_LED_IfaceConstants;
+ } tLocalTime_IfaceConstants;
- virtual void writeFPGA_LED(bool value, tRioStatusCode *status) = 0;
- virtual bool readFPGA_LED(tRioStatusCode *status) = 0;
+ virtual unsigned int readLocalTime(tRioStatusCode *status) = 0;
typedef enum
{
- } tLocalTime_IfaceConstants;
+ } tFPGA_LED_IfaceConstants;
- virtual unsigned int readLocalTime(tRioStatusCode *status) = 0;
+ virtual void writeFPGA_LED(bool value, tRioStatusCode *status) = 0;
+ virtual bool readFPGA_LED(tRioStatusCode *status) = 0;
typedef enum
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tInterrupt.h b/aos/externals/WPILib/WPILib/ChipObject/tInterrupt.h
index 319591d..519f6b3 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tInterrupt.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tInterrupt.h
@@ -30,12 +30,21 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned Source_Channel : 4;
unsigned Source_Module : 1;
unsigned Source_AnalogTrigger : 1;
unsigned RisingEdge : 1;
unsigned FallingEdge : 1;
unsigned WaitForAck : 1;
+#else
+ unsigned WaitForAck : 1;
+ unsigned FallingEdge : 1;
+ unsigned RisingEdge : 1;
+ unsigned Source_AnalogTrigger : 1;
+ unsigned Source_Module : 1;
+ unsigned Source_Channel : 4;
+#endif
};
struct{
unsigned value : 9;
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tInterruptManager.h b/aos/externals/WPILib/WPILib/ChipObject/tInterruptManager.h
index d7e96a2..b8fb361 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tInterruptManager.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tInterruptManager.h
@@ -4,9 +4,18 @@
#ifndef __tInterruptManager_h__
#define __tInterruptManager_h__
-#include "NiRio.h"
#include "tSystem.h"
-#include <semLib.h>
+
+namespace ni
+{
+ namespace dsc
+ {
+ namespace osdep
+ {
+ class CriticalSection;
+ }
+ }
+}
namespace nFPGA
{
@@ -24,6 +33,8 @@
void disable(tRioStatusCode *status);
bool isEnabled(tRioStatusCode *status);
private:
+ class tInterruptThread;
+ friend class tInterruptThread;
void handler();
static int handlerWrapper(tInterruptManager *pInterrupt);
@@ -32,7 +43,7 @@
void unreserve(tRioStatusCode *status);
tInterruptHandler _handler;
uint32_t _interruptMask;
- int32_t _taskId;
+ tInterruptThread *_thread;
NiFpga_IrqContext _rioContext;
bool _watcher;
bool _enabled;
@@ -40,7 +51,7 @@
// maintain the interrupts that are already dealt with.
static uint32_t _globalInterruptMask;
- static SEM_ID _globalInterruptMaskSemaphore;
+ static ni::dsc::osdep::CriticalSection *_globalInterruptMaskSemaphore;
};
}
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tSPI.h b/aos/externals/WPILib/WPILib/ChipObject/tSPI.h
index f113604..c74ec9b 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tSPI.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tSPI.h
@@ -28,8 +28,13 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned ReceivedDataOverflow : 1;
unsigned Idle : 1;
+#else
+ unsigned Idle : 1;
+ unsigned ReceivedDataOverflow : 1;
+#endif
};
struct{
unsigned value : 2;
@@ -38,6 +43,7 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned BusBitWidth : 8;
unsigned ClockHalfPeriodDelay : 8;
unsigned MSBfirst : 1;
@@ -47,6 +53,17 @@
unsigned FramePolarity : 1;
unsigned WriteOnly : 1;
unsigned ClockPolarity : 1;
+#else
+ unsigned ClockPolarity : 1;
+ unsigned WriteOnly : 1;
+ unsigned FramePolarity : 1;
+ unsigned LatchLast : 1;
+ unsigned LatchFirst : 1;
+ unsigned DataOnFalling : 1;
+ unsigned MSBfirst : 1;
+ unsigned ClockHalfPeriodDelay : 8;
+ unsigned BusBitWidth : 8;
+#endif
};
struct{
unsigned value : 23;
@@ -55,6 +72,7 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned SCLK_Channel : 4;
unsigned SCLK_Module : 1;
unsigned MOSI_Channel : 4;
@@ -63,6 +81,16 @@
unsigned MISO_Module : 1;
unsigned SS_Channel : 4;
unsigned SS_Module : 1;
+#else
+ unsigned SS_Module : 1;
+ unsigned SS_Channel : 4;
+ unsigned MISO_Module : 1;
+ unsigned MISO_Channel : 4;
+ unsigned MOSI_Module : 1;
+ unsigned MOSI_Channel : 4;
+ unsigned SCLK_Module : 1;
+ unsigned SCLK_Channel : 4;
+#endif
};
struct{
unsigned value : 20;
@@ -82,9 +110,17 @@
typedef enum
{
- } tReadReceivedData_IfaceConstants;
+ } tReceivedData_IfaceConstants;
- virtual void strobeReadReceivedData(tRioStatusCode *status) = 0;
+ virtual unsigned int readReceivedData(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
+ } tDataToLoad_IfaceConstants;
+
+ virtual void writeDataToLoad(unsigned int value, tRioStatusCode *status) = 0;
+ virtual unsigned int readDataToLoad(tRioStatusCode *status) = 0;
typedef enum
@@ -115,17 +151,23 @@
typedef enum
{
- } tReceivedData_IfaceConstants;
+ } tClearReceivedData_IfaceConstants;
- virtual unsigned int readReceivedData(tRioStatusCode *status) = 0;
+ virtual void strobeClearReceivedData(tRioStatusCode *status) = 0;
typedef enum
{
- } tDataToLoad_IfaceConstants;
+ } tReceivedElements_IfaceConstants;
- virtual void writeDataToLoad(unsigned int value, tRioStatusCode *status) = 0;
- virtual unsigned int readDataToLoad(tRioStatusCode *status) = 0;
+ virtual unsigned short readReceivedElements(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
+ } tLoad_IfaceConstants;
+
+ virtual void strobeLoad(tRioStatusCode *status) = 0;
typedef enum
@@ -161,32 +203,18 @@
typedef enum
{
- } tClearReceivedData_IfaceConstants;
-
- virtual void strobeClearReceivedData(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
- } tReceivedElements_IfaceConstants;
-
- virtual unsigned short readReceivedElements(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
- } tLoad_IfaceConstants;
-
- virtual void strobeLoad(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
} tAvailableToLoad_IfaceConstants;
virtual unsigned short readAvailableToLoad(tRioStatusCode *status) = 0;
+ typedef enum
+ {
+ } tReadReceivedData_IfaceConstants;
+
+ virtual void strobeReadReceivedData(tRioStatusCode *status) = 0;
+
+
private:
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tSystem.h b/aos/externals/WPILib/WPILib/ChipObject/tSystem.h
index b5dccf0..eb55be1 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tSystem.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tSystem.h
@@ -4,8 +4,8 @@
#ifndef __tSystem_h__
#define __tSystem_h__
-#include "NiRio.h"
-#include <vxWorks.h>
+#include "fpgainterfacecapi/NiFpga.h"
+typedef NiFpga_Status tRioStatusCode;
#define FRC_FPGA_PRELOAD_BITFILE
diff --git a/aos/externals/WPILib/WPILib/ChipObject/tWatchdog.h b/aos/externals/WPILib/WPILib/ChipObject/tWatchdog.h
index f5ef16a..d4a4cba 100644
--- a/aos/externals/WPILib/WPILib/ChipObject/tWatchdog.h
+++ b/aos/externals/WPILib/WPILib/ChipObject/tWatchdog.h
@@ -28,10 +28,17 @@
typedef
union{
struct{
+#ifdef __vxworks
unsigned SystemActive : 1;
unsigned Alive : 1;
unsigned SysDisableCount : 15;
unsigned DisableCount : 15;
+#else
+ unsigned DisableCount : 15;
+ unsigned SysDisableCount : 15;
+ unsigned Alive : 1;
+ unsigned SystemActive : 1;
+#endif
};
struct{
unsigned value : 32;
@@ -53,14 +60,6 @@
typedef enum
{
- } tImmortal_IfaceConstants;
-
- virtual void writeImmortal(bool value, tRioStatusCode *status) = 0;
- virtual bool readImmortal(tRioStatusCode *status) = 0;
-
-
- typedef enum
- {
} tKill_IfaceConstants;
virtual void strobeKill(tRioStatusCode *status) = 0;
@@ -75,6 +74,13 @@
typedef enum
{
+ } tTimer_IfaceConstants;
+
+ virtual unsigned int readTimer(tRioStatusCode *status) = 0;
+
+
+ typedef enum
+ {
} tExpiration_IfaceConstants;
virtual void writeExpiration(unsigned int value, tRioStatusCode *status) = 0;
@@ -83,9 +89,10 @@
typedef enum
{
- } tTimer_IfaceConstants;
+ } tImmortal_IfaceConstants;
- virtual unsigned int readTimer(tRioStatusCode *status) = 0;
+ virtual void writeImmortal(bool value, tRioStatusCode *status) = 0;
+ virtual bool readImmortal(tRioStatusCode *status) = 0;
diff --git a/aos/externals/WPILib/WPILib/Compressor.cpp b/aos/externals/WPILib/WPILib/Compressor.cpp
index 265c761..0c973f1 100644
--- a/aos/externals/WPILib/WPILib/Compressor.cpp
+++ b/aos/externals/WPILib/WPILib/Compressor.cpp
@@ -42,18 +42,19 @@
*
* You MUST start the compressor by calling the Start() method.
*/
-void Compressor::InitCompressor(UINT8 pressureSwitchModuleNumber,
- UINT32 pressureSwitchChannel,
- UINT8 compresssorRelayModuleNumber,
- UINT32 compressorRelayChannel)
+void Compressor::InitCompressor(uint8_t pressureSwitchModuleNumber,
+ uint32_t pressureSwitchChannel,
+ uint8_t compresssorRelayModuleNumber,
+ uint32_t compressorRelayChannel)
{
+ m_table = NULL;
m_enabled = false;
m_pressureSwitch = new DigitalInput(pressureSwitchModuleNumber, pressureSwitchChannel);
m_relay = new Relay(compresssorRelayModuleNumber, compressorRelayChannel, Relay::kForwardOnly);
nUsageReporting::report(nUsageReporting::kResourceType_Compressor, 0);
- if (!m_task.Start((INT32)this))
+ if (!m_task.Start((int32_t)this))
{
wpi_setWPIError(CompressorTaskError);
}
@@ -70,10 +71,10 @@
* @param compresssorRelayModuleNumber The digital module that the compressor relay is attached to.
* @param compressorRelayChannel The relay channel that the compressor relay is attached to.
*/
-Compressor::Compressor(UINT8 pressureSwitchModuleNumber,
- UINT32 pressureSwitchChannel,
- UINT8 compresssorRelayModuleNumber,
- UINT32 compressorRelayChannel)
+Compressor::Compressor(uint8_t pressureSwitchModuleNumber,
+ uint32_t pressureSwitchChannel,
+ uint8_t compresssorRelayModuleNumber,
+ uint32_t compressorRelayChannel)
: m_task ("Compressor", (FUNCPTR)CompressorChecker)
{
InitCompressor(pressureSwitchModuleNumber,
@@ -92,7 +93,7 @@
* @param pressureSwitchChannel The GPIO channel that the pressure switch is attached to.
* @param compressorRelayChannel The relay channel that the compressor relay is attached to.
*/
-Compressor::Compressor(UINT32 pressureSwitchChannel, UINT32 compressorRelayChannel)
+Compressor::Compressor(uint32_t pressureSwitchChannel, uint32_t compressorRelayChannel)
: m_task ("Compressor", (FUNCPTR)CompressorChecker)
{
InitCompressor(GetDefaultDigitalModule(),
@@ -128,7 +129,7 @@
*
* @return The current state of the pressure switch.
*/
-UINT32 Compressor::GetPressureSwitchValue()
+uint32_t Compressor::GetPressureSwitchValue()
{
return m_pressureSwitch->Get();
}
diff --git a/aos/externals/WPILib/WPILib/Compressor.h b/aos/externals/WPILib/WPILib/Compressor.h
index 04f58ef..cd68af4 100644
--- a/aos/externals/WPILib/WPILib/Compressor.h
+++ b/aos/externals/WPILib/WPILib/Compressor.h
@@ -26,15 +26,15 @@
class Compressor: public SensorBase, public LiveWindowSendable
{
public:
- Compressor(UINT32 pressureSwitchChannel, UINT32 compressorRelayChannel);
- Compressor(UINT8 pressureSwitchModuleNumber, UINT32 pressureSwitchChannel,
- UINT8 compresssorRelayModuleNumber, UINT32 compressorRelayChannel);
+ Compressor(uint32_t pressureSwitchChannel, uint32_t compressorRelayChannel);
+ Compressor(uint8_t pressureSwitchModuleNumber, uint32_t pressureSwitchChannel,
+ uint8_t compresssorRelayModuleNumber, uint32_t compressorRelayChannel);
~Compressor();
void Start();
void Stop();
bool Enabled();
- UINT32 GetPressureSwitchValue();
+ uint32_t GetPressureSwitchValue();
void SetRelayValue(Relay::Value relayValue);
void UpdateTable();
@@ -45,8 +45,8 @@
ITable * GetTable();
private:
- void InitCompressor(UINT8 pressureSwitchModuleNumber, UINT32 pressureSwitchChannel,
- UINT8 compresssorRelayModuleNumber, UINT32 compressorRelayChannel);
+ void InitCompressor(uint8_t pressureSwitchModuleNumber, uint32_t pressureSwitchChannel,
+ uint8_t compresssorRelayModuleNumber, uint32_t compressorRelayChannel);
DigitalInput *m_pressureSwitch;
Relay *m_relay;
diff --git a/aos/externals/WPILib/WPILib/Counter.cpp b/aos/externals/WPILib/WPILib/Counter.cpp
index e7c17ad..bf77743 100644
--- a/aos/externals/WPILib/WPILib/Counter.cpp
+++ b/aos/externals/WPILib/WPILib/Counter.cpp
@@ -19,8 +19,9 @@
*/
void Counter::InitCounter(Mode mode)
{
+ m_table = NULL;
Resource::CreateResourceObject(&counters, tCounter::kNumSystems);
- UINT32 index = counters->Allocate("Counter", this);
+ uint32_t index = counters->Allocate("Counter", this);
if (index == ~0ul)
{
return;
@@ -81,7 +82,7 @@
* Create an instance of a Counter object.
* Create an up-Counter instance given a channel. The default digital module is assumed.
*/
-Counter::Counter(UINT32 channel) :
+Counter::Counter(uint32_t channel) :
m_upSource(NULL),
m_downSource(NULL),
m_counter(NULL)
@@ -97,7 +98,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The channel in the digital module
*/
-Counter::Counter(UINT8 moduleNumber, UINT32 channel) :
+Counter::Counter(uint8_t moduleNumber, uint32_t channel) :
m_upSource(NULL),
m_downSource(NULL),
m_counter(NULL)
@@ -191,7 +192,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The digital channel (1..14).
*/
-void Counter::SetUpSource(UINT8 moduleNumber, UINT32 channel)
+void Counter::SetUpSource(uint8_t moduleNumber, uint32_t channel)
{
if (StatusIsFatal()) return;
SetUpSource(new DigitalInput(moduleNumber, channel));
@@ -202,7 +203,7 @@
* Set the upsource for the counter as a digital input channel.
* The slot will be the default digital module slot.
*/
-void Counter::SetUpSource(UINT32 channel)
+void Counter::SetUpSource(uint32_t channel)
{
if (StatusIsFatal()) return;
SetUpSource(GetDefaultDigitalModule(), channel);
@@ -320,7 +321,7 @@
* Set the down counting source to be a digital input channel.
* The slot will be set to the default digital module slot.
*/
-void Counter::SetDownSource(UINT32 channel)
+void Counter::SetDownSource(uint32_t channel)
{
if (StatusIsFatal()) return;
SetDownSource(new DigitalInput(channel));
@@ -333,7 +334,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The digital channel (1..14).
*/
-void Counter::SetDownSource(UINT8 moduleNumber, UINT32 channel)
+void Counter::SetDownSource(uint8_t moduleNumber, uint32_t channel)
{
if (StatusIsFatal()) return;
SetDownSource(new DigitalInput(moduleNumber, channel));
@@ -498,10 +499,40 @@
if (StatusIsFatal()) return;
tRioStatusCode localStatus = NiFpga_Status_Success;
m_counter->writeConfig_Mode(kPulseLength, &localStatus);
- m_counter->writeConfig_PulseLengthThreshold((UINT32)(threshold * 1.0e6) * kSystemClockTicksPerMicrosecond, &localStatus);
+ m_counter->writeConfig_PulseLengthThreshold((uint32_t)(threshold * 1.0e6) * kSystemClockTicksPerMicrosecond, &localStatus);
wpi_setError(localStatus);
}
+
+ /**
+ * Get the Samples to Average which specifies the number of samples of the timer to
+ * average when calculating the period. Perform averaging to account for
+ * mechanical imperfections or as oversampling to increase resolution.
+ * @return SamplesToAverage The number of samples being averaged (from 1 to 127)
+ */
+ int Counter::GetSamplesToAverage()
+ {
+ tRioStatusCode localStatus = NiFpga_Status_Success;
+ return m_counter->readTimerConfig_AverageSize(&localStatus);
+ wpi_setError(localStatus);
+ }
+
+/**
+ * Set the Samples to Average which specifies the number of samples of the timer to
+ * average when calculating the period. Perform averaging to account for
+ * mechanical imperfections or as oversampling to increase resolution.
+ * @param samplesToAverage The number of samples to average from 1 to 127.
+ */
+ void Counter::SetSamplesToAverage (int samplesToAverage) {
+ tRioStatusCode localStatus = NiFpga_Status_Success;
+ if (samplesToAverage < 1 || samplesToAverage > 127)
+ {
+ wpi_setWPIErrorWithContext(ParameterOutOfRange, "Average counter values must be between 1 and 127");
+ }
+ m_counter->writeTimerConfig_AverageSize(samplesToAverage, &localStatus);
+ wpi_setError(localStatus);
+ }
+
/**
* Start the Counter counting.
* This enables the counter and it starts accumulating counts from the associated
@@ -520,11 +551,11 @@
* Read the value at this instant. It may still be running, so it reflects the current value. Next
* time it is read, it might have a different value.
*/
-INT32 Counter::Get()
+int32_t Counter::Get()
{
if (StatusIsFatal()) return 0;
tRioStatusCode localStatus = NiFpga_Status_Success;
- INT32 value = m_counter->readOutput_Value(&localStatus);
+ int32_t value = m_counter->readOutput_Value(&localStatus);
wpi_setError(localStatus);
return value;
}
@@ -592,7 +623,7 @@
{
if (StatusIsFatal()) return;
tRioStatusCode localStatus = NiFpga_Status_Success;
- m_counter->writeTimerConfig_StallPeriod((UINT32)(maxPeriod * 1.0e6), &localStatus);
+ m_counter->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6), &localStatus);
wpi_setError(localStatus);
}
diff --git a/aos/externals/WPILib/WPILib/Counter.h b/aos/externals/WPILib/WPILib/Counter.h
index 8b7230d..fff1328 100644
--- a/aos/externals/WPILib/WPILib/Counter.h
+++ b/aos/externals/WPILib/WPILib/Counter.h
@@ -24,8 +24,8 @@
typedef enum {kTwoPulse=0, kSemiperiod=1, kPulseLength=2, kExternalDirection=3} Mode;
Counter();
- explicit Counter(UINT32 channel);
- Counter(UINT8 moduleNumber, UINT32 channel);
+ explicit Counter(uint32_t channel);
+ Counter(uint8_t moduleNumber, uint32_t channel);
explicit Counter(DigitalSource *source);
explicit Counter(DigitalSource &source);
explicit Counter(AnalogTrigger *trigger);
@@ -33,8 +33,8 @@
Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted);
virtual ~Counter();
- void SetUpSource(UINT32 channel);
- void SetUpSource(UINT8 moduleNumber, UINT32 channel);
+ void SetUpSource(uint32_t channel);
+ void SetUpSource(uint8_t moduleNumber, uint32_t channel);
void SetUpSource(AnalogTrigger *analogTrigger, AnalogTriggerOutput::Type triggerType);
void SetUpSource(AnalogTrigger &analogTrigger, AnalogTriggerOutput::Type triggerType);
void SetUpSource(DigitalSource *source);
@@ -42,8 +42,8 @@
void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
void ClearUpSource();
- void SetDownSource(UINT32 channel);
- void SetDownSource(UINT8 moduleNumber, UINT32 channel);
+ void SetDownSource(uint32_t channel);
+ void SetDownSource(uint8_t moduleNumber, uint32_t channel);
void SetDownSource(AnalogTrigger *analogTrigger, AnalogTriggerOutput::Type triggerType);
void SetDownSource(AnalogTrigger &analogTrigger, AnalogTriggerOutput::Type triggerType);
void SetDownSource(DigitalSource *source);
@@ -60,7 +60,7 @@
// CounterBase interface
void Start();
- INT32 Get();
+ int32_t Get();
void Reset();
void Stop();
double GetPeriod();
@@ -68,7 +68,9 @@
void SetUpdateWhenEmpty(bool enabled);
bool GetStopped();
bool GetDirection();
- UINT32 GetIndex() {return m_index;}
+ void SetSamplesToAverage(int samplesToAverage);
+ int GetSamplesToAverage();
+ uint32_t GetIndex() {return m_index;}
void UpdateTable();
@@ -77,16 +79,16 @@
virtual std::string GetSmartDashboardType();
void InitTable(ITable *subTable);
ITable * GetTable();
-
+protected:
+ DigitalSource *m_upSource; ///< What makes the counter count up.
+ DigitalSource *m_downSource; ///< What makes the counter count down.
+ tCounter *m_counter; ///< The FPGA counter object.
private:
void InitCounter(Mode mode = kTwoPulse);
- DigitalSource *m_upSource; ///< What makes the counter count up.
- DigitalSource *m_downSource; ///< What makes the counter count down.
bool m_allocatedUpSource; ///< Was the upSource allocated locally?
bool m_allocatedDownSource; ///< Was the downSource allocated locally?
- tCounter *m_counter; ///< The FPGA counter object.
- UINT32 m_index; ///< The index of this counter.
+ uint32_t m_index; ///< The index of this counter.
ITable *m_table;
};
diff --git a/aos/externals/WPILib/WPILib/CounterBase.h b/aos/externals/WPILib/WPILib/CounterBase.h
index 69bf026..4354e42 100644
--- a/aos/externals/WPILib/WPILib/CounterBase.h
+++ b/aos/externals/WPILib/WPILib/CounterBase.h
@@ -19,7 +19,7 @@
virtual ~CounterBase() {}
virtual void Start() = 0;
- virtual INT32 Get() = 0;
+ virtual int32_t Get() = 0;
virtual void Reset() = 0;
virtual void Stop() = 0;
virtual double GetPeriod() = 0;
diff --git a/aos/externals/WPILib/WPILib/Dashboard.cpp b/aos/externals/WPILib/WPILib/Dashboard.cpp
index 2235b99..b21cd7c 100644
--- a/aos/externals/WPILib/WPILib/Dashboard.cpp
+++ b/aos/externals/WPILib/WPILib/Dashboard.cpp
@@ -11,7 +11,7 @@
#include "WPIErrors.h"
#include <strLib.h>
-const INT32 Dashboard::kMaxDashboardDataSize;
+const int32_t Dashboard::kMaxDashboardDataSize;
/**
* Dashboard contructor.
@@ -56,9 +56,9 @@
* Pack a signed 8-bit int into the dashboard data structure.
* @param value Data to be packed into the structure.
*/
-void Dashboard::AddI8(INT8 value)
+void Dashboard::AddI8(int8_t value)
{
- if (!ValidateAdd(sizeof(INT8))) return;
+ if (!ValidateAdd(sizeof(int8_t))) return;
memcpy(m_packPtr, (char*)&value, sizeof(value));
m_packPtr += sizeof(value);
AddedElement(kI8);
@@ -68,9 +68,9 @@
* Pack a signed 16-bit int into the dashboard data structure.
* @param value Data to be packed into the structure.
*/
-void Dashboard::AddI16(INT16 value)
+void Dashboard::AddI16(int16_t value)
{
- if (!ValidateAdd(sizeof(INT16))) return;
+ if (!ValidateAdd(sizeof(int16_t))) return;
memcpy(m_packPtr, (char*)&value, sizeof(value));
m_packPtr += sizeof(value);
AddedElement(kI16);
@@ -80,9 +80,9 @@
* Pack a signed 32-bit int into the dashboard data structure.
* @param value Data to be packed into the structure.
*/
-void Dashboard::AddI32(INT32 value)
+void Dashboard::AddI32(int32_t value)
{
- if (!ValidateAdd(sizeof(INT32))) return;
+ if (!ValidateAdd(sizeof(int32_t))) return;
memcpy(m_packPtr, (char*)&value, sizeof(value));
m_packPtr += sizeof(value);
AddedElement(kI32);
@@ -92,9 +92,9 @@
* Pack an unsigned 8-bit int into the dashboard data structure.
* @param value Data to be packed into the structure.
*/
-void Dashboard::AddU8(UINT8 value)
+void Dashboard::AddU8(uint8_t value)
{
- if (!ValidateAdd(sizeof(UINT8))) return;
+ if (!ValidateAdd(sizeof(uint8_t))) return;
memcpy(m_packPtr, (char*)&value, sizeof(value));
m_packPtr += sizeof(value);
AddedElement(kU8);
@@ -104,9 +104,9 @@
* Pack an unsigned 16-bit int into the dashboard data structure.
* @param value Data to be packed into the structure.
*/
-void Dashboard::AddU16(UINT16 value)
+void Dashboard::AddU16(uint16_t value)
{
- if (!ValidateAdd(sizeof(UINT16))) return;
+ if (!ValidateAdd(sizeof(uint16_t))) return;
memcpy(m_packPtr, (char*)&value, sizeof(value));
m_packPtr += sizeof(value);
AddedElement(kU16);
@@ -116,9 +116,9 @@
* Pack an unsigned 32-bit int into the dashboard data structure.
* @param value Data to be packed into the structure.
*/
-void Dashboard::AddU32(UINT32 value)
+void Dashboard::AddU32(uint32_t value)
{
- if (!ValidateAdd(sizeof(UINT32))) return;
+ if (!ValidateAdd(sizeof(uint32_t))) return;
memcpy(m_packPtr, (char*)&value, sizeof(value));
m_packPtr += sizeof(value);
AddedElement(kU32);
@@ -174,7 +174,7 @@
* @param value Data to be packed into the structure.
* @param length The number of bytes in the string to pack.
*/
-void Dashboard::AddString(char* value, INT32 length)
+void Dashboard::AddString(char* value, int32_t length)
{
if (!ValidateAdd(length + sizeof(length))) return;
memcpy(m_packPtr, (char*)&length, sizeof(length));
@@ -195,11 +195,11 @@
*/
void Dashboard::AddArray()
{
- if (!ValidateAdd(sizeof(INT32))) return;
+ if (!ValidateAdd(sizeof(int32_t))) return;
m_complexTypeStack.push(kArray);
m_arrayElementCount.push_back(0);
- m_arraySizePtr.push_back((INT32*)m_packPtr);
- m_packPtr += sizeof(INT32);
+ m_arraySizePtr.push_back((int32_t*)m_packPtr);
+ m_packPtr += sizeof(int32_t);
}
/**
@@ -264,7 +264,7 @@
void Dashboard::Printf(const char *writeFmt, ...)
{
va_list args;
- INT32 size;
+ int32_t size;
// Check if the buffer has already been used for packing.
if (m_packPtr != m_localBuffer)
@@ -295,7 +295,7 @@
* Prepares a packet to go to the dashboard...
* @return The total size of the data packed into the userData field of the status packet.
*/
-INT32 Dashboard::Finalize()
+int32_t Dashboard::Finalize()
{
if (!m_complexTypeStack.empty())
{
@@ -328,7 +328,7 @@
* to the NetworkCommunication task.
* This function is called while holding the m_statusDataSemaphore.
*/
-void Dashboard::GetStatusBuffer(char **userStatusData, INT32* userStatusDataSize)
+void Dashboard::GetStatusBuffer(char **userStatusData, int32_t* userStatusDataSize)
{
// User printed strings
if (m_localPrintBuffer[0] != 0)
@@ -336,7 +336,7 @@
// Sequence number
DriverStation::GetInstance()->IncrementUpdateNumber();
- INT32 printSize;
+ int32_t printSize;
Synchronized syncPrint(m_printSemaphore);
printSize = strlen(m_localPrintBuffer);
m_userStatusDataSize = printSize;
@@ -351,7 +351,7 @@
/**
* Validate that the data being packed will fit in the buffer.
*/
-bool Dashboard::ValidateAdd(INT32 size)
+bool Dashboard::ValidateAdd(int32_t size)
{
if ((m_packPtr - m_localBuffer) + size > kMaxDashboardDataSize)
{
diff --git a/aos/externals/WPILib/WPILib/Dashboard.h b/aos/externals/WPILib/WPILib/Dashboard.h
index 1856660..bcd8f7b 100644
--- a/aos/externals/WPILib/WPILib/Dashboard.h
+++ b/aos/externals/WPILib/WPILib/Dashboard.h
@@ -26,17 +26,17 @@
enum Type {kI8, kI16, kI32, kU8, kU16, kU32, kFloat, kDouble, kBoolean, kString, kOther};
enum ComplexType {kArray, kCluster};
- void AddI8(INT8 value);
- void AddI16(INT16 value);
- void AddI32(INT32 value);
- void AddU8(UINT8 value);
- void AddU16(UINT16 value);
- void AddU32(UINT32 value);
+ void AddI8(int8_t value);
+ void AddI16(int16_t value);
+ void AddI32(int32_t value);
+ void AddU8(uint8_t value);
+ void AddU16(uint16_t value);
+ void AddU32(uint32_t value);
void AddFloat(float value);
void AddDouble(double value);
void AddBoolean(bool value);
void AddString(char* value);
- void AddString(char* value, INT32 length);
+ void AddString(char* value, int32_t length);
void AddArray();
void FinalizeArray();
@@ -45,28 +45,28 @@
void Printf(const char *writeFmt, ...);
- INT32 Finalize();
- void GetStatusBuffer(char** userStatusData, INT32* userStatusDataSize);
+ int32_t Finalize();
+ void GetStatusBuffer(char** userStatusData, int32_t* userStatusDataSize);
void Flush() {}
private:
- static const INT32 kMaxDashboardDataSize = USER_STATUS_DATA_SIZE - sizeof(UINT32) * 3 - sizeof(UINT8); // 13 bytes needed for 3 size parameters and the sequence number
+ static const int32_t kMaxDashboardDataSize = USER_STATUS_DATA_SIZE - sizeof(uint32_t) * 3 - sizeof(uint8_t); // 13 bytes needed for 3 size parameters and the sequence number
static const size_t kLocalPrintBufferSize = kMaxDashboardDataSize * 2;
// Usage Guidelines...
DISALLOW_COPY_AND_ASSIGN(Dashboard);
- bool ValidateAdd(INT32 size);
+ bool ValidateAdd(int32_t size);
void AddedElement(Type type);
bool IsArrayRoot();
char *m_userStatusData;
- INT32 m_userStatusDataSize;
+ int32_t m_userStatusDataSize;
char *m_localBuffer;
char *m_localPrintBuffer;
char *m_packPtr;
std::vector<Type> m_expectedArrayElementType;
- std::vector<INT32> m_arrayElementCount;
- std::vector<INT32*> m_arraySizePtr;
+ std::vector<int32_t> m_arrayElementCount;
+ std::vector<int32_t*> m_arraySizePtr;
std::stack<ComplexType> m_complexTypeStack;
SEM_ID m_printSemaphore;
SEM_ID m_statusDataSemaphore;
diff --git a/aos/externals/WPILib/WPILib/DashboardBase.h b/aos/externals/WPILib/WPILib/DashboardBase.h
index 2bc15d8..18a54d8 100644
--- a/aos/externals/WPILib/WPILib/DashboardBase.h
+++ b/aos/externals/WPILib/WPILib/DashboardBase.h
@@ -12,7 +12,7 @@
class DashboardBase : public ErrorBase {
public:
- virtual void GetStatusBuffer(char** userStatusData, INT32* userStatusDataSize) = 0;
+ virtual void GetStatusBuffer(char** userStatusData, int32_t* userStatusDataSize) = 0;
virtual void Flush() = 0;
virtual ~DashboardBase() {}
protected:
diff --git a/aos/externals/WPILib/WPILib/DigitalInput.cpp b/aos/externals/WPILib/WPILib/DigitalInput.cpp
index 4178ce0..0caaba7 100644
--- a/aos/externals/WPILib/WPILib/DigitalInput.cpp
+++ b/aos/externals/WPILib/WPILib/DigitalInput.cpp
@@ -15,8 +15,9 @@
* Creates a digital input given a slot and channel. Common creation routine
* for all constructors.
*/
-void DigitalInput::InitDigitalInput(UINT8 moduleNumber, UINT32 channel)
+void DigitalInput::InitDigitalInput(uint8_t moduleNumber, uint32_t channel)
{
+ m_table = NULL;
char buf[64];
if (!CheckDigitalModule(moduleNumber))
{
@@ -43,7 +44,7 @@
*
* @param channel The digital channel (1..14).
*/
-DigitalInput::DigitalInput(UINT32 channel)
+DigitalInput::DigitalInput(uint32_t channel)
{
InitDigitalInput(GetDefaultDigitalModule(), channel);
}
@@ -55,7 +56,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The digital channel (1..14).
*/
-DigitalInput::DigitalInput(UINT8 moduleNumber, UINT32 channel)
+DigitalInput::DigitalInput(uint8_t moduleNumber, uint32_t channel)
{
InitDigitalInput(moduleNumber, channel);
}
@@ -73,7 +74,7 @@
* Get the value from a digital input channel.
* Retrieve the value of a single digital input channel from the FPGA.
*/
-UINT32 DigitalInput::Get()
+uint32_t DigitalInput::Get()
{
if (StatusIsFatal()) return 0;
return m_module->GetDIO(m_channel);
@@ -82,7 +83,7 @@
/**
* @return The GPIO channel number that this object represents.
*/
-UINT32 DigitalInput::GetChannel()
+uint32_t DigitalInput::GetChannel()
{
return m_channel;
}
@@ -90,7 +91,7 @@
/**
* @return The value to be written to the channel field of a routing mux.
*/
-UINT32 DigitalInput::GetChannelForRouting()
+uint32_t DigitalInput::GetChannelForRouting()
{
return DigitalModule::RemapDigitalChannel(GetChannel() - 1);
}
@@ -98,7 +99,7 @@
/**
* @return The value to be written to the module field of a routing mux.
*/
-UINT32 DigitalInput::GetModuleForRouting()
+uint32_t DigitalInput::GetModuleForRouting()
{
if (StatusIsFatal()) return 0;
return m_module->GetNumber() - 1;
diff --git a/aos/externals/WPILib/WPILib/DigitalInput.h b/aos/externals/WPILib/WPILib/DigitalInput.h
index 9c87f0d..b9d77f7 100644
--- a/aos/externals/WPILib/WPILib/DigitalInput.h
+++ b/aos/externals/WPILib/WPILib/DigitalInput.h
@@ -21,15 +21,15 @@
*/
class DigitalInput : public DigitalSource, public LiveWindowSendable {
public:
- explicit DigitalInput(UINT32 channel);
- DigitalInput(UINT8 moduleNumber, UINT32 channel);
+ explicit DigitalInput(uint32_t channel);
+ DigitalInput(uint8_t moduleNumber, uint32_t channel);
virtual ~DigitalInput();
- UINT32 Get();
- UINT32 GetChannel();
+ uint32_t Get();
+ uint32_t GetChannel();
// Digital Source Interface
- virtual UINT32 GetChannelForRouting();
- virtual UINT32 GetModuleForRouting();
+ virtual uint32_t GetChannelForRouting();
+ virtual uint32_t GetModuleForRouting();
virtual bool GetAnalogTriggerForRouting();
void UpdateTable();
@@ -40,8 +40,8 @@
ITable * GetTable();
private:
- void InitDigitalInput(UINT8 moduleNumber, UINT32 channel);
- UINT32 m_channel;
+ void InitDigitalInput(uint8_t moduleNumber, uint32_t channel);
+ uint32_t m_channel;
DigitalModule *m_module;
bool m_lastValue;
diff --git a/aos/externals/WPILib/WPILib/DigitalModule.cpp b/aos/externals/WPILib/WPILib/DigitalModule.cpp
index d715c65..61fa6f6 100644
--- a/aos/externals/WPILib/WPILib/DigitalModule.cpp
+++ b/aos/externals/WPILib/WPILib/DigitalModule.cpp
@@ -23,7 +23,7 @@
*
* @param moduleNumber The digital module to get (1 or 2).
*/
-DigitalModule* DigitalModule::GetInstance(UINT8 moduleNumber)
+DigitalModule* DigitalModule::GetInstance(uint8_t moduleNumber)
{
if (CheckDigitalModule(moduleNumber))
{
@@ -48,7 +48,7 @@
*
* @param moduleNumber The digital module to create (1 or 2).
*/
-DigitalModule::DigitalModule(UINT8 moduleNumber)
+DigitalModule::DigitalModule(uint8_t moduleNumber)
: Module(nLoadOut::kModuleType_Digital, moduleNumber)
, m_fpgaDIO (NULL)
{
@@ -60,17 +60,22 @@
// Make sure that the 9403 IONode has had a chance to initialize before continuing.
while(m_fpgaDIO->readLoopTiming(&localStatus) == 0) taskDelay(1);
+
if (m_fpgaDIO->readLoopTiming(&localStatus) != kExpectedLoopTiming)
{
char err[128];
- snprintf(err, sizeof(err), "DIO LoopTiming: %d, expecting: %d\n", m_fpgaDIO->readLoopTiming(&localStatus), kExpectedLoopTiming);
+ snprintf(err, sizeof(err), "DIO LoopTiming: %d, expecting: %lu\n", m_fpgaDIO->readLoopTiming(&localStatus), kExpectedLoopTiming);
wpi_setWPIErrorWithContext(LoopTimingError, err);
}
- m_fpgaDIO->writePWMConfig_Period(PWM::kDefaultPwmPeriod, &localStatus);
- m_fpgaDIO->writePWMConfig_MinHigh(PWM::kDefaultMinPwmHigh, &localStatus);
+
+ //Calculate the length, in ms, of one DIO loop
+ double loopTime = m_fpgaDIO->readLoopTiming(&localStatus)/(kSystemClockTicksPerMicrosecond*1e3);
+
+ m_fpgaDIO->writePWMConfig_Period((uint16_t) (PWM::kDefaultPwmPeriod/loopTime + .5), &localStatus);
+ m_fpgaDIO->writePWMConfig_MinHigh((uint16_t) ((PWM::kDefaultPwmCenter-PWM::kDefaultPwmStepsDown*loopTime)/loopTime + .5), &localStatus);
// Ensure that PWM output values are set to OFF
- for (UINT32 pwm_index = 1; pwm_index <= kPwmChannels; pwm_index++)
+ for (uint32_t pwm_index = 1; pwm_index <= kPwmChannels; pwm_index++)
{
SetPWM(pwm_index, PWM::kPwmDisabled);
SetPWMPeriodScale(pwm_index, 3); // Set all to 4x by default.
@@ -111,7 +116,7 @@
* @param channel The PWM channel to set.
* @param value The PWM value to set.
*/
-void DigitalModule::SetPWM(UINT32 channel, UINT8 value)
+void DigitalModule::SetPWM(uint32_t channel, uint8_t value)
{
CheckPWMChannel(channel);
tRioStatusCode localStatus = NiFpga_Status_Success;
@@ -125,7 +130,7 @@
* @param channel The PWM channel to read from.
* @return The raw PWM value.
*/
-UINT8 DigitalModule::GetPWM(UINT32 channel)
+uint8_t DigitalModule::GetPWM(uint32_t channel)
{
CheckPWMChannel(channel);
tRioStatusCode localStatus = NiFpga_Status_Success;
@@ -139,7 +144,7 @@
* @param channel The PWM channel to configure.
* @param squelchMask The 2-bit mask of outputs to squelch.
*/
-void DigitalModule::SetPWMPeriodScale(UINT32 channel, UINT32 squelchMask)
+void DigitalModule::SetPWMPeriodScale(uint32_t channel, uint32_t squelchMask)
{
CheckPWMChannel(channel);
tRioStatusCode localStatus = NiFpga_Status_Success;
@@ -152,7 +157,7 @@
* Set the state of a relay output to be forward. Relays have two outputs and each is
* independently set to 0v or 12v.
*/
-void DigitalModule::SetRelayForward(UINT32 channel, bool on)
+void DigitalModule::SetRelayForward(uint32_t channel, bool on)
{
SetRelaysForward(1 << (channel - 1), on ? 0xFF : 0x00);
}
@@ -162,7 +167,7 @@
* Set the state of a relay output to be reverse. Relays have two outputs and each is
* independently set to 0v or 12v.
*/
-void DigitalModule::SetRelayReverse(UINT32 channel, bool on)
+void DigitalModule::SetRelayReverse(uint32_t channel, bool on)
{
SetRelaysReverse(1 << (channel - 1), on ? 0xFF : 0x00);
}
@@ -173,11 +178,11 @@
* @param mask which relays to set
* @param values what to set the relays to
*/
-void DigitalModule::SetRelaysForward(UINT8 mask, UINT8 values) {
+void DigitalModule::SetRelaysForward(uint8_t mask, uint8_t values) {
tRioStatusCode localStatus = NiFpga_Status_Success;
{
Synchronized sync(m_relaySemaphore);
- UINT8 current = m_fpgaDIO->readSlowValue_RelayFwd(&localStatus);
+ uint8_t current = m_fpgaDIO->readSlowValue_RelayFwd(&localStatus);
// Clearr all of the bits that we're messing with first.
current &= ~mask;
// Then set only the ones that are supposed to be set.
@@ -193,11 +198,11 @@
* @param mask which relays to set
* @param values what to set the relays to
*/
-void DigitalModule::SetRelaysReverse(UINT8 mask, UINT8 values) {
+void DigitalModule::SetRelaysReverse(uint8_t mask, uint8_t values) {
tRioStatusCode localStatus = NiFpga_Status_Success;
{
Synchronized sync(m_relaySemaphore);
- UINT8 current = m_fpgaDIO->readSlowValue_RelayRev(&localStatus);
+ uint8_t current = m_fpgaDIO->readSlowValue_RelayRev(&localStatus);
// Clearr all of the bits that we're messing with first.
current &= ~mask;
// Then set only the ones that are supposed to be set.
@@ -210,10 +215,10 @@
/**
* Get the current state of the forward relay channel
*/
-bool DigitalModule::GetRelayForward(UINT32 channel)
+bool DigitalModule::GetRelayForward(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT8 forwardRelays = m_fpgaDIO->readSlowValue_RelayFwd(&localStatus);
+ uint8_t forwardRelays = m_fpgaDIO->readSlowValue_RelayFwd(&localStatus);
wpi_setError(localStatus);
return (forwardRelays & (1 << (channel - 1))) != 0;
}
@@ -221,10 +226,10 @@
/**
* Get the current state of all of the forward relay channels on this module.
*/
-UINT8 DigitalModule::GetRelayForward()
+uint8_t DigitalModule::GetRelayForward()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT8 forwardRelays = m_fpgaDIO->readSlowValue_RelayFwd(&localStatus);
+ uint8_t forwardRelays = m_fpgaDIO->readSlowValue_RelayFwd(&localStatus);
wpi_setError(localStatus);
return forwardRelays;
}
@@ -232,10 +237,10 @@
/**
* Get the current state of the reverse relay channel
*/
-bool DigitalModule::GetRelayReverse(UINT32 channel)
+bool DigitalModule::GetRelayReverse(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT8 reverseRelays = m_fpgaDIO->readSlowValue_RelayRev(&localStatus);
+ uint8_t reverseRelays = m_fpgaDIO->readSlowValue_RelayRev(&localStatus);
wpi_setError(localStatus);
return (reverseRelays & (1 << (channel - 1))) != 0;
@@ -244,10 +249,10 @@
/**
* Get the current state of all of the reverse relay channels on this module.
*/
-UINT8 DigitalModule::GetRelayReverse()
+uint8_t DigitalModule::GetRelayReverse()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT8 reverseRelays = m_fpgaDIO->readSlowValue_RelayRev(&localStatus);
+ uint8_t reverseRelays = m_fpgaDIO->readSlowValue_RelayRev(&localStatus);
wpi_setError(localStatus);
return reverseRelays;
}
@@ -262,7 +267,7 @@
* @param input If true open as input; if false open as output
* @return Was successfully allocated
*/
-bool DigitalModule::AllocateDIO(UINT32 channel, bool input)
+bool DigitalModule::AllocateDIO(uint32_t channel, bool input)
{
char buf[64];
snprintf(buf, 64, "DIO %d (Module %d)", channel, m_moduleNumber);
@@ -271,9 +276,9 @@
tRioStatusCode localStatus = NiFpga_Status_Success;
{
Synchronized sync(m_digitalSemaphore);
- UINT32 bitToSet = 1 << (RemapDigitalChannel(channel - 1));
- UINT32 outputEnable = m_fpgaDIO->readOutputEnable(&localStatus);
- UINT32 outputEnableValue;
+ uint32_t bitToSet = 1 << (RemapDigitalChannel(channel - 1));
+ uint32_t outputEnable = m_fpgaDIO->readOutputEnable(&localStatus);
+ uint32_t outputEnableValue;
if (input)
{
outputEnableValue = outputEnable & (~bitToSet); // clear the bit for read
@@ -293,7 +298,7 @@
*
* @param channel The Digital I/O channel to free
*/
-void DigitalModule::FreeDIO(UINT32 channel)
+void DigitalModule::FreeDIO(uint32_t channel)
{
DIOChannels->Free(kDigitalChannels * (m_moduleNumber - 1) + channel - 1,
this);
@@ -306,11 +311,11 @@
* @param mask Which bits to modify.
* @param values What to set all of the bits in mask to.
*/
-void DigitalModule::SetDIOs(UINT16 mask, UINT16 values) {
+void DigitalModule::SetDIOs(uint16_t mask, uint16_t values) {
tRioStatusCode localStatus = NiFpga_Status_Success;
{
Synchronized sync(m_digitalSemaphore);
- UINT16 current = m_fpgaDIO->readDO(&localStatus);
+ uint16_t current = m_fpgaDIO->readDO(&localStatus);
// Clear all of the bits that we're messing with first.
current &= ~mask;
// Then set only the ones that are supposed to be set.
@@ -327,7 +332,7 @@
* @param channel The Digital I/O channel
* @param value The state to set the digital channel (if it is configured as an output)
*/
-void DigitalModule::SetDIO(UINT32 channel, bool value)
+void DigitalModule::SetDIO(uint32_t channel, bool value)
{
SetDIOs(1 << RemapDigitalChannel(channel - 1), value ? 0xFFFF : 0x0000);
}
@@ -339,10 +344,10 @@
* @param channel The digital I/O channel
* @return The state of the specified channel
*/
-bool DigitalModule::GetDIO(UINT32 channel)
+bool DigitalModule::GetDIO(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 currentDIO = m_fpgaDIO->readDI(&localStatus);
+ uint32_t currentDIO = m_fpgaDIO->readDI(&localStatus);
wpi_setError(localStatus);
//Shift 00000001 over channel-1 places.
@@ -356,10 +361,10 @@
* Read the state of all the Digital I/O lines from the FPGA
* These are not remapped to logical order. They are still in hardware order.
*/
-UINT16 DigitalModule::GetDIO()
+uint16_t DigitalModule::GetDIO()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 currentDIO = m_fpgaDIO->readDI(&localStatus);
+ uint32_t currentDIO = m_fpgaDIO->readDI(&localStatus);
wpi_setError(localStatus);
return currentDIO;
}
@@ -371,10 +376,10 @@
* @param channel The digital I/O channel
* @return The direction of the specified channel
*/
-bool DigitalModule::GetDIODirection(UINT32 channel)
+bool DigitalModule::GetDIODirection(uint32_t channel)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 currentOutputEnable = m_fpgaDIO->readOutputEnable(&localStatus);
+ uint32_t currentOutputEnable = m_fpgaDIO->readOutputEnable(&localStatus);
wpi_setError(localStatus);
//Shift 00000001 over channel-1 places.
@@ -389,10 +394,10 @@
* A 1 bit means output and a 0 bit means input.
* These are not remapped to logical order. They are still in hardware order.
*/
-UINT16 DigitalModule::GetDIODirection()
+uint16_t DigitalModule::GetDIODirection()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 currentOutputEnable = m_fpgaDIO->readOutputEnable(&localStatus);
+ uint32_t currentOutputEnable = m_fpgaDIO->readOutputEnable(&localStatus);
wpi_setError(localStatus);
return currentOutputEnable;
}
@@ -404,11 +409,11 @@
* @param channel The Digital Output channel that the pulse should be output on
* @param pulseLength The active length of the pulse (in seconds)
*/
-void DigitalModule::Pulse(UINT32 channel, float pulseLength)
+void DigitalModule::Pulse(uint32_t channel, float pulseLength)
{
- UINT16 mask = 1 << RemapDigitalChannel(channel - 1);
+ uint16_t mask = 1 << RemapDigitalChannel(channel - 1);
tRioStatusCode localStatus = NiFpga_Status_Success;
- m_fpgaDIO->writePulseLength((UINT8)(1.0e9 * pulseLength / (m_fpgaDIO->readLoopTiming(&localStatus) * 25)), &localStatus);
+ m_fpgaDIO->writePulseLength((uint8_t)(1.0e9 * pulseLength / (m_fpgaDIO->readLoopTiming(&localStatus) * 25)), &localStatus);
m_fpgaDIO->writePulse(mask, &localStatus);
wpi_setError(localStatus);
}
@@ -418,11 +423,11 @@
*
* @return A pulse is in progress
*/
-bool DigitalModule::IsPulsing(UINT32 channel)
+bool DigitalModule::IsPulsing(uint32_t channel)
{
- UINT16 mask = 1 << RemapDigitalChannel(channel - 1);
+ uint16_t mask = 1 << RemapDigitalChannel(channel - 1);
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT16 pulseRegister = m_fpgaDIO->readPulse(&localStatus);
+ uint16_t pulseRegister = m_fpgaDIO->readPulse(&localStatus);
wpi_setError(localStatus);
return (pulseRegister & mask) != 0;
}
@@ -435,7 +440,7 @@
bool DigitalModule::IsPulsing()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT16 pulseRegister = m_fpgaDIO->readPulse(&localStatus);
+ uint16_t pulseRegister = m_fpgaDIO->readPulse(&localStatus);
wpi_setError(localStatus);
return pulseRegister != 0;
}
@@ -446,7 +451,7 @@
*
* @return PWM Generator refnum
*/
-UINT32 DigitalModule::AllocateDO_PWM()
+uint32_t DigitalModule::AllocateDO_PWM()
{
char buf[64];
snprintf(buf, 64, "DO_PWM (Module: %d)", m_moduleNumber);
@@ -458,7 +463,7 @@
*
* @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM()
*/
-void DigitalModule::FreeDO_PWM(UINT32 pwmGenerator)
+void DigitalModule::FreeDO_PWM(uint32_t pwmGenerator)
{
if (pwmGenerator == ~0ul) return;
DO_PWMGenerators[(m_moduleNumber - 1)]->Free(pwmGenerator, this);
@@ -476,7 +481,7 @@
// Currently rounding in the log rate domain... heavy weight toward picking a higher freq.
// TODO: Round in the linear rate domain.
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT8 pwmPeriodPower = (UINT8)(log(1.0 / (m_fpgaDIO->readLoopTiming(&localStatus) * 0.25E-6 * rate))/log(2.0) + 0.5);
+ uint8_t pwmPeriodPower = (uint8_t)(log(1.0 / (m_fpgaDIO->readLoopTiming(&localStatus) * 0.25E-6 * rate))/log(2.0) + 0.5);
m_fpgaDIO->writeDO_PWMConfig_PeriodPower(pwmPeriodPower, &localStatus);
wpi_setError(localStatus);
}
@@ -487,7 +492,7 @@
* @param pwmGenerator The generator index reserved by AllocateDO_PWM()
* @param channel The Digital Output channel to output on
*/
-void DigitalModule::SetDO_PWMOutputChannel(UINT32 pwmGenerator, UINT32 channel)
+void DigitalModule::SetDO_PWMOutputChannel(uint32_t pwmGenerator, uint32_t channel)
{
if (pwmGenerator == ~0ul) return;
tRioStatusCode localStatus = NiFpga_Status_Success;
@@ -515,7 +520,7 @@
* @param pwmGenerator The generator index reserved by AllocateDO_PWM()
* @param dutyCycle The percent duty cycle to output [0..1].
*/
-void DigitalModule::SetDO_PWMDutyCycle(UINT32 pwmGenerator, float dutyCycle)
+void DigitalModule::SetDO_PWMDutyCycle(uint32_t pwmGenerator, float dutyCycle)
{
if (pwmGenerator == ~0ul) return;
if (dutyCycle > 1.0) dutyCycle = 1.0;
@@ -525,25 +530,39 @@
tRioStatusCode localStatus = NiFpga_Status_Success;
{
Synchronized sync(m_doPwmSemaphore);
- UINT8 pwmPeriodPower = m_fpgaDIO->readDO_PWMConfig_PeriodPower(&localStatus);
+ uint8_t pwmPeriodPower = m_fpgaDIO->readDO_PWMConfig_PeriodPower(&localStatus);
if (pwmPeriodPower < 4)
{
// The resolution of the duty cycle drops close to the highest frequencies.
rawDutyCycle = rawDutyCycle / pow(2.0, 4 - pwmPeriodPower);
}
- m_fpgaDIO->writeDO_PWMDutyCycle(pwmGenerator, (UINT8)rawDutyCycle, &localStatus);
+ m_fpgaDIO->writeDO_PWMDutyCycle(pwmGenerator, (uint8_t)rawDutyCycle, &localStatus);
}
wpi_setError(localStatus);
}
/**
+ * Get the loop timing of the Digital Module
+ *
+ * @return The loop time
+ */
+uint16_t DigitalModule::GetLoopTiming()
+{
+ tRioStatusCode localStatus = NiFpga_Status_Success;
+ uint16_t timing = m_fpgaDIO->readLoopTiming(&localStatus);
+ wpi_setError(localStatus);
+
+ return timing;
+}
+
+/**
* Return a pointer to an I2C object for this digital module
* The caller is responsible for deleting the pointer.
*
* @param address The address of the device on the I2C bus
* @return A pointer to an I2C object to talk to the device at address
*/
-I2C* DigitalModule::GetI2C(UINT32 address)
+I2C* DigitalModule::GetI2C(uint32_t address)
{
return new I2C(this, address);
}
diff --git a/aos/externals/WPILib/WPILib/DigitalModule.h b/aos/externals/WPILib/WPILib/DigitalModule.h
index 44f617f..86189b9 100644
--- a/aos/externals/WPILib/WPILib/DigitalModule.h
+++ b/aos/externals/WPILib/WPILib/DigitalModule.h
@@ -12,7 +12,7 @@
class I2C;
-const UINT32 kExpectedLoopTiming = 260;
+const uint32_t kExpectedLoopTiming = 260;
class DigitalModule: public Module
{
@@ -20,43 +20,44 @@
friend class Module;
protected:
- explicit DigitalModule(UINT8 moduleNumber);
+ explicit DigitalModule(uint8_t moduleNumber);
virtual ~DigitalModule();
public:
- void SetPWM(UINT32 channel, UINT8 value);
- UINT8 GetPWM(UINT32 channel);
- void SetPWMPeriodScale(UINT32 channel, UINT32 squelchMask);
- void SetRelayForward(UINT32 channel, bool on);
- void SetRelayReverse(UINT32 channel, bool on);
- void SetRelaysForward(UINT8 mask, UINT8 values);
- void SetRelaysReverse(UINT8 mask, UINT8 values);
- bool GetRelayForward(UINT32 channel);
- UINT8 GetRelayForward();
- bool GetRelayReverse(UINT32 channel);
- UINT8 GetRelayReverse();
- bool AllocateDIO(UINT32 channel, bool input);
- void FreeDIO(UINT32 channel);
- void SetDIOs(UINT16 mask, UINT16 values);
- void SetDIO(UINT32 channel, bool value);
- bool GetDIO(UINT32 channel);
- UINT16 GetDIO();
- bool GetDIODirection(UINT32 channel);
- UINT16 GetDIODirection();
- void Pulse(UINT32 channel, float pulseLength);
- bool IsPulsing(UINT32 channel);
+ void SetPWM(uint32_t channel, uint8_t value);
+ uint8_t GetPWM(uint32_t channel);
+ void SetPWMPeriodScale(uint32_t channel, uint32_t squelchMask);
+ void SetRelayForward(uint32_t channel, bool on);
+ void SetRelayReverse(uint32_t channel, bool on);
+ void SetRelaysForward(uint8_t mask, uint8_t values);
+ void SetRelaysReverse(uint8_t mask, uint8_t values);
+ bool GetRelayForward(uint32_t channel);
+ uint8_t GetRelayForward();
+ bool GetRelayReverse(uint32_t channel);
+ uint8_t GetRelayReverse();
+ bool AllocateDIO(uint32_t channel, bool input);
+ void FreeDIO(uint32_t channel);
+ void SetDIOs(uint16_t mask, uint16_t values);
+ void SetDIO(uint32_t channel, bool value);
+ bool GetDIO(uint32_t channel);
+ uint16_t GetDIO();
+ bool GetDIODirection(uint32_t channel);
+ uint16_t GetDIODirection();
+ void Pulse(uint32_t channel, float pulseLength);
+ bool IsPulsing(uint32_t channel);
bool IsPulsing();
- UINT32 AllocateDO_PWM();
- void FreeDO_PWM(UINT32 pwmGenerator);
+ uint32_t AllocateDO_PWM();
+ void FreeDO_PWM(uint32_t pwmGenerator);
void SetDO_PWMRate(float rate);
- void SetDO_PWMDutyCycle(UINT32 pwmGenerator, float dutyCycle);
- void SetDO_PWMOutputChannel(UINT32 pwmGenerator, UINT32 channel);
+ void SetDO_PWMDutyCycle(uint32_t pwmGenerator, float dutyCycle);
+ void SetDO_PWMOutputChannel(uint32_t pwmGenerator, uint32_t channel);
+ uint16_t GetLoopTiming();
- I2C* GetI2C(UINT32 address);
+ I2C* GetI2C(uint32_t address);
- static DigitalModule* GetInstance(UINT8 moduleNumber);
- static UINT8 RemapDigitalChannel(UINT32 channel) { return 15 - channel; }; // TODO: Need channel validation
- static UINT8 UnmapDigitalChannel(UINT32 channel) { return 15 - channel; }; // TODO: Need channel validation
+ static DigitalModule* GetInstance(uint8_t moduleNumber);
+ static uint8_t RemapDigitalChannel(uint32_t channel) { return 15 - channel; }; // TODO: Need channel validation
+ static uint8_t UnmapDigitalChannel(uint32_t channel) { return 15 - channel; }; // TODO: Need channel validation
private:
SEM_ID m_digitalSemaphore;
diff --git a/aos/externals/WPILib/WPILib/DigitalOutput.cpp b/aos/externals/WPILib/WPILib/DigitalOutput.cpp
index 4f45ee7..06b9c48 100644
--- a/aos/externals/WPILib/WPILib/DigitalOutput.cpp
+++ b/aos/externals/WPILib/WPILib/DigitalOutput.cpp
@@ -17,8 +17,9 @@
* Creates a digital output given a slot and channel. Common creation routine
* for all constructors.
*/
-void DigitalOutput::InitDigitalOutput(UINT8 moduleNumber, UINT32 channel)
+void DigitalOutput::InitDigitalOutput(uint8_t moduleNumber, uint32_t channel)
{
+ m_table = NULL;
char buf[64];
if (!CheckDigitalModule(moduleNumber))
{
@@ -46,7 +47,7 @@
*
* @param channel The digital channel (1..14).
*/
-DigitalOutput::DigitalOutput(UINT32 channel)
+DigitalOutput::DigitalOutput(uint32_t channel)
{
InitDigitalOutput(GetDefaultDigitalModule(), channel);
}
@@ -58,7 +59,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The digital channel (1..14).
*/
-DigitalOutput::DigitalOutput(UINT8 moduleNumber, UINT32 channel)
+DigitalOutput::DigitalOutput(uint8_t moduleNumber, uint32_t channel)
{
InitDigitalOutput(moduleNumber, channel);
}
@@ -78,7 +79,7 @@
* Set the value of a digital output.
* Set the value of a digital output to either one (true) or zero (false).
*/
-void DigitalOutput::Set(UINT32 value)
+void DigitalOutput::Set(uint32_t value)
{
if (StatusIsFatal()) return;
m_module->SetDIO(m_channel, value);
@@ -87,7 +88,7 @@
/**
* @return The GPIO channel number that this object represents.
*/
-UINT32 DigitalOutput::GetChannel()
+uint32_t DigitalOutput::GetChannel()
{
return m_channel;
}
@@ -181,7 +182,7 @@
/**
* @return The value to be written to the channel field of a routing mux.
*/
-UINT32 DigitalOutput::GetChannelForRouting()
+uint32_t DigitalOutput::GetChannelForRouting()
{
return DigitalModule::RemapDigitalChannel(GetChannel() - 1);
}
@@ -189,7 +190,7 @@
/**
* @return The value to be written to the module field of a routing mux.
*/
-UINT32 DigitalOutput::GetModuleForRouting()
+uint32_t DigitalOutput::GetModuleForRouting()
{
if (StatusIsFatal()) return 0;
return m_module->GetNumber() - 1;
@@ -214,7 +215,7 @@
void DigitalOutput::RequestInterrupts(tInterruptHandler handler, void *param)
{
if (StatusIsFatal()) return;
- UINT32 index = interruptsResource->Allocate("Sync Interrupt", this);
+ uint32_t index = interruptsResource->Allocate("Sync Interrupt", this);
if (index == ~0ul)
{
return;
@@ -244,7 +245,7 @@
void DigitalOutput::RequestInterrupts()
{
if (StatusIsFatal()) return;
- UINT32 index = interruptsResource->Allocate("Sync Interrupt", this);
+ uint32_t index = interruptsResource->Allocate("Sync Interrupt", this);
if (index == ~0ul)
{
return;
@@ -286,11 +287,15 @@
}
void DigitalOutput::StartLiveWindowMode() {
- m_table->AddTableListener("Value", this, true);
+ if (m_table != NULL) {
+ m_table->AddTableListener("Value", this, true);
+ }
}
void DigitalOutput::StopLiveWindowMode() {
- m_table->RemoveTableListener(this);
+ if (m_table != NULL) {
+ m_table->RemoveTableListener(this);
+ }
}
std::string DigitalOutput::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/DigitalOutput.h b/aos/externals/WPILib/WPILib/DigitalOutput.h
index 36645cf..749027d 100644
--- a/aos/externals/WPILib/WPILib/DigitalOutput.h
+++ b/aos/externals/WPILib/WPILib/DigitalOutput.h
@@ -21,11 +21,11 @@
class DigitalOutput : public DigitalSource, public ITableListener, public LiveWindowSendable
{
public:
- explicit DigitalOutput(UINT32 channel);
- DigitalOutput(UINT8 moduleNumber, UINT32 channel);
+ explicit DigitalOutput(uint32_t channel);
+ DigitalOutput(uint8_t moduleNumber, uint32_t channel);
virtual ~DigitalOutput();
- void Set(UINT32 value);
- UINT32 GetChannel();
+ void Set(uint32_t value);
+ uint32_t GetChannel();
void Pulse(float length);
bool IsPulsing();
void SetPWMRate(float rate);
@@ -34,8 +34,8 @@
void UpdateDutyCycle(float dutyCycle);
// Digital Source Interface
- virtual UINT32 GetChannelForRouting();
- virtual UINT32 GetModuleForRouting();
+ virtual uint32_t GetChannelForRouting();
+ virtual uint32_t GetModuleForRouting();
virtual bool GetAnalogTriggerForRouting();
virtual void RequestInterrupts(tInterruptHandler handler, void *param);
virtual void RequestInterrupts();
@@ -51,10 +51,10 @@
ITable * GetTable();
private:
- void InitDigitalOutput(UINT8 moduleNumber, UINT32 channel);
+ void InitDigitalOutput(uint8_t moduleNumber, uint32_t channel);
- UINT32 m_channel;
- UINT32 m_pwmGenerator;
+ uint32_t m_channel;
+ uint32_t m_pwmGenerator;
DigitalModule *m_module;
ITable *m_table;
diff --git a/aos/externals/WPILib/WPILib/DigitalSource.cpp b/aos/externals/WPILib/WPILib/DigitalSource.cpp
index 862b439..00244e4 100644
--- a/aos/externals/WPILib/WPILib/DigitalSource.cpp
+++ b/aos/externals/WPILib/WPILib/DigitalSource.cpp
@@ -39,7 +39,7 @@
void DigitalSource::RequestInterrupts(tInterruptHandler handler, void *param)
{
if (StatusIsFatal()) return;
- UINT32 index = interruptsResource->Allocate("Async Interrupt", this);
+ uint32_t index = interruptsResource->Allocate("Async Interrupt", this);
if (index == ~0ul)
{
return;
@@ -69,7 +69,7 @@
void DigitalSource::RequestInterrupts()
{
if (StatusIsFatal()) return;
- UINT32 index = interruptsResource->Allocate("Sync Interrupt", this);
+ uint32_t index = interruptsResource->Allocate("Sync Interrupt", this);
if (index == ~0ul)
{
return;
diff --git a/aos/externals/WPILib/WPILib/DigitalSource.h b/aos/externals/WPILib/WPILib/DigitalSource.h
index 637a65e..d5d7e7d 100644
--- a/aos/externals/WPILib/WPILib/DigitalSource.h
+++ b/aos/externals/WPILib/WPILib/DigitalSource.h
@@ -21,8 +21,8 @@
public:
DigitalSource();
virtual ~DigitalSource();
- virtual UINT32 GetChannelForRouting() = 0;
- virtual UINT32 GetModuleForRouting() = 0;
+ virtual uint32_t GetChannelForRouting() = 0;
+ virtual uint32_t GetModuleForRouting() = 0;
virtual bool GetAnalogTriggerForRouting() = 0;
virtual void RequestInterrupts(tInterruptHandler handler, void *param);
virtual void RequestInterrupts();
diff --git a/aos/externals/WPILib/WPILib/DoubleSolenoid.cpp b/aos/externals/WPILib/WPILib/DoubleSolenoid.cpp
index 4b3e473..19ef5b7 100644
--- a/aos/externals/WPILib/WPILib/DoubleSolenoid.cpp
+++ b/aos/externals/WPILib/WPILib/DoubleSolenoid.cpp
@@ -15,6 +15,7 @@
*/
void DoubleSolenoid::InitSolenoid()
{
+ m_table = NULL;
char buf[64];
if (!CheckSolenoidModule(m_moduleNumber))
{
@@ -53,7 +54,7 @@
nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_forwardChannel, m_moduleNumber - 1);
nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_reverseChannel, m_moduleNumber - 1);
- LiveWindow::GetInstance()->AddSensor("DoubleSolenoid", m_moduleNumber, m_forwardChannel, this);
+ LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", m_moduleNumber, m_forwardChannel, this);
}
/**
@@ -62,7 +63,7 @@
* @param forwardChannel The forward channel on the module to control.
* @param reverseChannel The reverse channel on the module to control.
*/
-DoubleSolenoid::DoubleSolenoid(UINT32 forwardChannel, UINT32 reverseChannel)
+DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
: SolenoidBase (GetDefaultSolenoidModule())
, m_forwardChannel (forwardChannel)
, m_reverseChannel (reverseChannel)
@@ -77,7 +78,7 @@
* @param forwardChannel The forward channel on the module to control.
* @param reverseChannel The reverse channel on the module to control.
*/
-DoubleSolenoid::DoubleSolenoid(UINT8 moduleNumber, UINT32 forwardChannel, UINT32 reverseChannel)
+DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel)
: SolenoidBase (moduleNumber)
, m_forwardChannel (forwardChannel)
, m_reverseChannel (reverseChannel)
@@ -104,7 +105,7 @@
void DoubleSolenoid::Set(Value value)
{
if (StatusIsFatal()) return;
- UINT8 rawValue = 0x00;
+ uint8_t rawValue = 0x00;
switch(value)
{
@@ -130,21 +131,19 @@
DoubleSolenoid::Value DoubleSolenoid::Get()
{
if (StatusIsFatal()) return kOff;
- UINT8 value = GetAll();
+ uint8_t value = GetAll();
if (value & m_forwardMask) return kForward;
if (value & m_reverseMask) return kReverse;
return kOff;
}
-
-
-
void DoubleSolenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
Value lvalue = kOff;
- if (strcmp((char*)value.ptr, "Forward") == 0)
+ std::string *val = (std::string *)value.ptr;
+ if (*val == "Forward")
lvalue = kForward;
- else if (strcmp((char*)value.ptr, "Reverse") == 0)
+ else if (*val == "Reverse")
lvalue = kReverse;
Set(lvalue);
}
@@ -157,12 +156,16 @@
void DoubleSolenoid::StartLiveWindowMode() {
Set(kOff);
- m_table->AddTableListener("Value", this, true);
+ if (m_table != NULL) {
+ m_table->AddTableListener("Value", this, true);
+ }
}
void DoubleSolenoid::StopLiveWindowMode() {
Set(kOff);
- m_table->RemoveTableListener(this);
+ if (m_table != NULL) {
+ m_table->RemoveTableListener(this);
+ }
}
std::string DoubleSolenoid::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/DoubleSolenoid.h b/aos/externals/WPILib/WPILib/DoubleSolenoid.h
index a4cd03a..09c8c90 100644
--- a/aos/externals/WPILib/WPILib/DoubleSolenoid.h
+++ b/aos/externals/WPILib/WPILib/DoubleSolenoid.h
@@ -23,8 +23,8 @@
public:
typedef enum {kOff, kForward, kReverse} Value;
- explicit DoubleSolenoid(UINT32 forwardChannel, UINT32 reverseChannel);
- DoubleSolenoid(UINT8 moduleNumber, UINT32 forwardChannel, UINT32 reverseChannel);
+ explicit DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel);
+ DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel);
virtual ~DoubleSolenoid();
virtual void Set(Value value);
virtual Value Get();
@@ -40,10 +40,10 @@
private:
void InitSolenoid();
- UINT32 m_forwardChannel; ///< The forward channel on the module to control.
- UINT32 m_reverseChannel; ///< The reverse channel on the module to control.
- UINT8 m_forwardMask; ///< The mask for the forward channel.
- UINT8 m_reverseMask; ///< The mask for the reverse channel.
+ uint32_t m_forwardChannel; ///< The forward channel on the module to control.
+ uint32_t m_reverseChannel; ///< The reverse channel on the module to control.
+ uint8_t m_forwardMask; ///< The mask for the forward channel.
+ uint8_t m_reverseMask; ///< The mask for the reverse channel.
ITable *m_table;
};
diff --git a/aos/externals/WPILib/WPILib/DriverStation.cpp b/aos/externals/WPILib/WPILib/DriverStation.cpp
index 9c2cb91..dfd92c0 100644
--- a/aos/externals/WPILib/WPILib/DriverStation.cpp
+++ b/aos/externals/WPILib/WPILib/DriverStation.cpp
@@ -15,13 +15,13 @@
#include "WPIErrors.h"
#include <strLib.h>
-const UINT32 DriverStation::kBatteryModuleNumber;
-const UINT32 DriverStation::kBatteryChannel;
-const UINT32 DriverStation::kJoystickPorts;
-const UINT32 DriverStation::kJoystickAxes;
+const uint32_t DriverStation::kBatteryModuleNumber;
+const uint32_t DriverStation::kBatteryChannel;
+const uint32_t DriverStation::kJoystickPorts;
+const uint32_t DriverStation::kJoystickAxes;
DriverStation* DriverStation::m_instance = NULL;
ReentrantSemaphore DriverStation::m_instanceSemaphore;
-UINT8 DriverStation::m_updateNumber = 0;
+uint8_t DriverStation::m_updateNumber = 0;
/**
* DriverStation contructor.
@@ -64,7 +64,7 @@
AddToSingletonList();
- if (!m_task.Start((INT32)this))
+ if (!m_task.Start((int32_t)this))
{
wpi_setWPIError(DriverStationTaskError);
}
@@ -178,9 +178,9 @@
void DriverStation::SetData()
{
char *userStatusDataHigh;
- INT32 userStatusDataHighSize;
+ int32_t userStatusDataHighSize;
char *userStatusDataLow;
- INT32 userStatusDataLowSize;
+ int32_t userStatusDataLowSize;
Synchronized sync(m_statusDataSemaphore);
@@ -220,7 +220,7 @@
* @param axis The analog axis value to read from the joystick.
* @return The value of the axis on the joystick.
*/
-float DriverStation::GetStickAxis(UINT32 stick, UINT32 axis)
+float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis)
{
if (axis < 1 || axis > kJoystickAxes)
{
@@ -228,7 +228,7 @@
return 0.0;
}
- INT8 value;
+ int8_t value;
switch (stick)
{
case 1:
@@ -268,7 +268,7 @@
* @param stick The joystick to read.
* @return The state of the buttons on the joystick.
*/
-short DriverStation::GetStickButtons(UINT32 stick)
+short DriverStation::GetStickButtons(uint32_t stick)
{
if (stick < 1 || stick > 4)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "stick must be between 1 and 4");
@@ -299,13 +299,13 @@
* @param channel The analog input channel on the driver station to read from. Valid range is 1 - 4.
* @return The analog voltage on the input.
*/
-float DriverStation::GetAnalogIn(UINT32 channel)
+float DriverStation::GetAnalogIn(uint32_t channel)
{
if (channel < 1 || channel > 4)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 4");
// TODO: Fix the lack of thread safety here (for reported_mask).
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_Analog);
@@ -332,13 +332,13 @@
* and switches on advanced operator interfaces.
* @param channel The digital input to get. Valid range is 1 - 8.
*/
-bool DriverStation::GetDigitalIn(UINT32 channel)
+bool DriverStation::GetDigitalIn(uint32_t channel)
{
if (channel < 1 || channel > 8)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8");
// TODO: Fix the lack of thread safety here (for reported_mask).
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_DigitalIn);
@@ -357,14 +357,14 @@
* @param channel The digital output to set. Valid range is 1 - 8.
* @param value The state to set the digital output.
*/
-void DriverStation::SetDigitalOut(UINT32 channel, bool value)
+void DriverStation::SetDigitalOut(uint32_t channel, bool value)
{
if (channel < 1 || channel > 8)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8");
// TODO: Fix the lack of thread safety here (for both reported_mask and
// m_digitalOut).
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_DigitalOut);
@@ -372,7 +372,7 @@
}
m_digitalOut &= ~(0x1 << (channel-1));
- m_digitalOut |= ((UINT8)value << (channel-1));
+ m_digitalOut |= ((uint8_t)value << (channel-1));
}
/**
@@ -380,7 +380,7 @@
* @param channel The digital ouput to monitor. Valid range is 1 through 8.
* @return A digital value being output on the Drivers Station.
*/
-bool DriverStation::GetDigitalOut(UINT32 channel)
+bool DriverStation::GetDigitalOut(uint32_t channel)
{
if (channel < 1 || channel > 8)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8");
@@ -480,7 +480,7 @@
* The packet number is the index of this set of data returned by the driver station.
* @return The driver station packet number
*/
-UINT32 DriverStation::GetPacketNumber()
+uint32_t DriverStation::GetPacketNumber()
{
return m_controlData->packetIndex;
}
@@ -504,7 +504,7 @@
* This could return 1, 2, or 3
* @return The location of the driver station
*/
-UINT32 DriverStation::GetLocation()
+uint32_t DriverStation::GetLocation()
{
char position = m_controlData->dsID_Position;
wpi_assert ((position >= '1') && (position <= '3'));
@@ -542,7 +542,7 @@
* Return the team number that the Driver Station is configured for
* @return The team number
*/
-UINT16 DriverStation::GetTeamNumber()
+uint16_t DriverStation::GetTeamNumber()
{
return m_controlData->teamID;
}
diff --git a/aos/externals/WPILib/WPILib/DriverStation.h b/aos/externals/WPILib/WPILib/DriverStation.h
index 1fcf1e8..cc00819 100644
--- a/aos/externals/WPILib/WPILib/DriverStation.h
+++ b/aos/externals/WPILib/WPILib/DriverStation.h
@@ -39,10 +39,10 @@
RWLock::Locker GetDataReadLock();
- static const UINT32 kBatteryModuleNumber = 1;
- static const UINT32 kBatteryChannel = 8;
- static const UINT32 kJoystickPorts = 4;
- static const UINT32 kJoystickAxes = 6;
+ static const uint32_t kBatteryModuleNumber = 1;
+ static const uint32_t kBatteryChannel = 8;
+ static const uint32_t kJoystickPorts = 4;
+ static const uint32_t kJoystickAxes = 6;
/**
* Returns the pointer to all of the data. This pointer will never change, but
@@ -55,13 +55,13 @@
return m_controlData;
}
- float GetStickAxis(UINT32 stick, UINT32 axis);
- short GetStickButtons(UINT32 stick);
+ float GetStickAxis(uint32_t stick, uint32_t axis);
+ short GetStickButtons(uint32_t stick);
- float GetAnalogIn(UINT32 channel);
- bool GetDigitalIn(UINT32 channel);
- void SetDigitalOut(UINT32 channel, bool value);
- bool GetDigitalOut(UINT32 channel);
+ float GetAnalogIn(uint32_t channel);
+ bool GetDigitalIn(uint32_t channel);
+ void SetDigitalOut(uint32_t channel, bool value);
+ bool GetDigitalOut(uint32_t channel);
bool IsEnabled();
bool IsDisabled();
@@ -72,13 +72,13 @@
bool IsNewControlData();
bool IsFMSAttached();
- UINT32 GetPacketNumber();
+ uint32_t GetPacketNumber();
Alliance GetAlliance();
- UINT32 GetLocation();
+ uint32_t GetLocation();
void WaitForData();
double GetMatchTime();
float GetBatteryVoltage();
- UINT16 GetTeamNumber();
+ uint16_t GetTeamNumber();
// Get the default dashboard packers. These instances stay around even after
// a call to SetHigh|LowPriorityDashboardPackerToUse() changes which packer
@@ -142,7 +142,9 @@
private:
static DriverStation *m_instance;
static ReentrantSemaphore m_instanceSemaphore;
- static UINT8 m_updateNumber;
+ static uint8_t m_updateNumber;
+ ///< TODO: Get rid of this and use the semaphore signaling
+ static constexpr float kUpdatePeriod = 0.02;
static void InitTask(DriverStation *ds);
void Run();
@@ -159,7 +161,7 @@
// they can prevent updates to the data while they are doing stuff with it.
RWLock m_dataLock;
- UINT8 m_digitalOut;
+ uint8_t m_digitalOut;
AnalogChannel *m_batteryChannel;
SEM_ID m_statusDataSemaphore;
Task m_task;
diff --git a/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.cpp b/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.cpp
index 5c73453..afd9437 100644
--- a/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.cpp
+++ b/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.cpp
@@ -51,7 +51,7 @@
*/
void DriverStationEnhancedIO::UpdateData()
{
- INT32 retVal;
+ int32_t retVal;
{
status_block_t tempOutputData;
Synchronized sync(m_outputDataSemaphore);
@@ -176,7 +176,7 @@
return 0.0;
}
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_Acceleration);
@@ -193,7 +193,7 @@
* @param channel The channel number to read. [1,8]
* @return The analog input voltage for the channel.
*/
-double DriverStationEnhancedIO::GetAnalogIn(UINT32 channel)
+double DriverStationEnhancedIO::GetAnalogIn(uint32_t channel)
{
// 3.3V is the analog reference voltage
return GetAnalogInRatio(channel) * kAnalogInputReference;
@@ -205,7 +205,7 @@
* @param channel The channel number to read. [1,8]
* @return The analog input percentage for the channel.
*/
-double DriverStationEnhancedIO::GetAnalogInRatio(UINT32 channel)
+double DriverStationEnhancedIO::GetAnalogInRatio(uint32_t channel)
{
if (channel < 1 || channel > 8)
{
@@ -218,7 +218,7 @@
return 0.0;
}
- static UINT16 reported_mask = 0;
+ static uint16_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_AnalogIn);
@@ -238,7 +238,7 @@
* @param channel The analog output channel on the DS IO. [1,2]
* @return The voltage being output on the channel.
*/
-double DriverStationEnhancedIO::GetAnalogOut(UINT32 channel)
+double DriverStationEnhancedIO::GetAnalogOut(uint32_t channel)
{
if (channel < 1 || channel > 2)
{
@@ -268,7 +268,7 @@
* @param channel The analog output channel on the DS IO. [1,2]
* @param value The voltage to output on the channel.
*/
-void DriverStationEnhancedIO::SetAnalogOut(UINT32 channel, double value)
+void DriverStationEnhancedIO::SetAnalogOut(uint32_t channel, double value)
{
if (channel < 1 || channel > 2)
{
@@ -283,7 +283,7 @@
if (value < 0.0) value = 0.0;
if (value > kAnalogOutputReference) value = kAnalogOutputReference;
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_AnalogOut);
@@ -291,7 +291,7 @@
}
Synchronized sync(m_outputDataSemaphore);
- m_outputData.data.dac[channel-1] = (UINT8)(value / kAnalogOutputReference * kAnalogOutputResolution);
+ m_outputData.data.dac[channel-1] = (uint8_t)(value / kAnalogOutputReference * kAnalogOutputResolution);
}
/**
@@ -309,7 +309,7 @@
* @param channel The button channel to read. [1,6]
* @return The state of the selected button.
*/
-bool DriverStationEnhancedIO::GetButton(UINT32 channel)
+bool DriverStationEnhancedIO::GetButton(uint32_t channel)
{
if (channel < 1 || channel > 6)
{
@@ -317,7 +317,7 @@
return false;
}
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_Button);
@@ -332,7 +332,7 @@
*
* @return The state of the 6 button channels in the 6 lsb of the returned byte.
*/
-UINT8 DriverStationEnhancedIO::GetButtons()
+uint8_t DriverStationEnhancedIO::GetButtons()
{
if (!m_inputValid)
{
@@ -350,7 +350,7 @@
* @param channel The LED channel to set. [1,8]
* @param value True to turn the LED on.
*/
-void DriverStationEnhancedIO::SetLED(UINT32 channel, bool value)
+void DriverStationEnhancedIO::SetLED(uint32_t channel, bool value)
{
if (channel < 1 || channel > 8)
{
@@ -363,14 +363,14 @@
return;
}
- static UINT16 reported_mask = 0;
+ static uint16_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_LED);
reported_mask |= (1 >> channel);
}
- UINT8 leds;
+ uint8_t leds;
Synchronized sync(m_outputDataSemaphore);
leds = m_outputData.data.leds;
@@ -385,7 +385,7 @@
*
* @param value The state of each LED. LED1 is lsb and LED8 is msb.
*/
-void DriverStationEnhancedIO::SetLEDs(UINT8 value)
+void DriverStationEnhancedIO::SetLEDs(uint8_t value)
{
if (!m_outputValid)
{
@@ -403,7 +403,7 @@
* @param channel The DIO channel to read. [1,16]
* @return The state of the selected digital line.
*/
-bool DriverStationEnhancedIO::GetDigital(UINT32 channel)
+bool DriverStationEnhancedIO::GetDigital(uint32_t channel)
{
if (channel < 1 || channel > 16)
{
@@ -411,7 +411,7 @@
return false;
}
- static UINT32 reported_mask = 0;
+ static uint32_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_DigitalIn);
@@ -426,7 +426,7 @@
*
* @return The state of all DIO lines. DIO1 is lsb and DIO16 is msb.
*/
-UINT16 DriverStationEnhancedIO::GetDigitals()
+uint16_t DriverStationEnhancedIO::GetDigitals()
{
if (!m_inputValid)
{
@@ -444,7 +444,7 @@
* @param channel The DIO channel to set. [1,16]
* @param value The state to set the selected channel to.
*/
-void DriverStationEnhancedIO::SetDigitalOutput(UINT32 channel, bool value)
+void DriverStationEnhancedIO::SetDigitalOutput(uint32_t channel, bool value)
{
if (channel < 1 || channel > 16)
{
@@ -457,14 +457,14 @@
return;
}
- static UINT32 reported_mask = 0;
+ static uint32_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_DigitalOut);
reported_mask |= (1 >> channel);
}
- UINT16 digital;
+ uint16_t digital;
Synchronized sync(m_outputDataSemaphore);
if (m_outputData.data.digital_oe & (1 << (channel-1)))
@@ -491,7 +491,7 @@
* @param channel The DIO channel config to get. [1,16]
* @return The configured mode for the DIO line.
*/
-DriverStationEnhancedIO::tDigitalConfig DriverStationEnhancedIO::GetDigitalConfig(UINT32 channel)
+DriverStationEnhancedIO::tDigitalConfig DriverStationEnhancedIO::GetDigitalConfig(uint32_t channel)
{
if (channel < 1 || channel > 16)
{
@@ -560,7 +560,7 @@
* @param channel The DIO line to configure. [1,16]
* @param config The mode to put the DIO line in.
*/
-void DriverStationEnhancedIO::SetDigitalConfig(UINT32 channel, tDigitalConfig config)
+void DriverStationEnhancedIO::SetDigitalConfig(uint32_t channel, tDigitalConfig config)
{
if (channel < 1 || channel > 16)
{
@@ -701,7 +701,7 @@
{
Synchronized sync(m_outputDataSemaphore);
// Update the period
- m_outputData.data.pwm_period[channels] = (UINT16)ticks;
+ m_outputData.data.pwm_period[channels] = (uint16_t)ticks;
m_configChanged = true;
}
// Restore the duty cycles
@@ -715,7 +715,7 @@
* @param channel The FixedDO line to get. [1,2]
* @return The state of the FixedDO line.
*/
-bool DriverStationEnhancedIO::GetFixedDigitalOutput(UINT32 channel)
+bool DriverStationEnhancedIO::GetFixedDigitalOutput(uint32_t channel)
{
if (channel < 1 || channel > 2)
{
@@ -746,7 +746,7 @@
* @param channel The FixedDO channel to set.
* @param value The state to set the FixedDO.
*/
-void DriverStationEnhancedIO::SetFixedDigitalOutput(UINT32 channel, bool value)
+void DriverStationEnhancedIO::SetFixedDigitalOutput(uint32_t channel, bool value)
{
if (channel < 1 || channel > 2)
{
@@ -759,14 +759,14 @@
return;
}
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_FixedDigitalOut);
reported_mask |= (1 >> channel);
}
- UINT8 digital;
+ uint8_t digital;
Synchronized sync(m_outputDataSemaphore);
digital = m_outputData.data.fixed_digital_out;
@@ -790,7 +790,7 @@
* @param encoderNumber The quadrature encoder to access. [1,2]
* @return The current position of the quadrature encoder.
*/
-INT16 DriverStationEnhancedIO::GetEncoder(UINT32 encoderNumber)
+int16_t DriverStationEnhancedIO::GetEncoder(uint32_t encoderNumber)
{
if (encoderNumber < 1 || encoderNumber > 2)
{
@@ -803,7 +803,7 @@
return 0;
}
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> encoderNumber)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, encoderNumber, nUsageReporting::kDriverStationEIO_Encoder);
@@ -822,7 +822,7 @@
*
* @param encoderNumber The quadrature encoder to reset. [1,2]
*/
-void DriverStationEnhancedIO::ResetEncoder(UINT32 encoderNumber)
+void DriverStationEnhancedIO::ResetEncoder(uint32_t encoderNumber)
{
if (encoderNumber < 1 || encoderNumber > 2)
{
@@ -848,7 +848,7 @@
* @param encoderNumber The quadrature encoder. [1,2]
* @return Is the index channel of the encoder enabled.
*/
-bool DriverStationEnhancedIO::GetEncoderIndexEnable(UINT32 encoderNumber)
+bool DriverStationEnhancedIO::GetEncoderIndexEnable(uint32_t encoderNumber)
{
if (encoderNumber < 1 || encoderNumber > 2)
{
@@ -879,7 +879,7 @@
* @param encoderNumber The quadrature encoder. [1,2]
* @param enable If true, reset the encoder in an index condition.
*/
-void DriverStationEnhancedIO::SetEncoderIndexEnable(UINT32 encoderNumber, bool enable)
+void DriverStationEnhancedIO::SetEncoderIndexEnable(uint32_t encoderNumber, bool enable)
{
if (encoderNumber < 1 || encoderNumber > 2)
{
@@ -909,7 +909,7 @@
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 1, nUsageReporting::kDriverStationEIO_TouchSlider);
Synchronized sync(m_inputDataSemaphore);
- UINT8 value = m_inputData.data.capsense_slider;
+ uint8_t value = m_inputData.data.capsense_slider;
return value == 255 ? -1.0 : value / 254.0;
}
@@ -919,7 +919,7 @@
* @param channel The DIO line's PWM generator to get the duty-cycle from. [1,4]
* @return The percent duty-cycle being output (if the DIO line is configured for PWM). [0.0,1.0]
*/
-double DriverStationEnhancedIO::GetPWMOutput(UINT32 channel)
+double DriverStationEnhancedIO::GetPWMOutput(uint32_t channel)
{
if (channel < 1 || channel > 4)
{
@@ -945,7 +945,7 @@
* @param channel The DIO line's PWM generator to set. [1,4]
* @param value The percent duty-cycle to output from the PWM generator. [0.0,1.0]
*/
-void DriverStationEnhancedIO::SetPWMOutput(UINT32 channel, double value)
+void DriverStationEnhancedIO::SetPWMOutput(uint32_t channel, double value)
{
if (channel < 1 || channel > 4)
{
@@ -958,7 +958,7 @@
return;
}
- static UINT8 reported_mask = 0;
+ static uint8_t reported_mask = 0;
if (!(reported_mask & (1 >> channel)))
{
nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_PWM);
@@ -968,7 +968,7 @@
if (value > 1.0) value = 1.0;
else if (value < 0.0) value = 0.0;
Synchronized sync(m_outputDataSemaphore);
- m_outputData.data.pwm_compare[channel - 1] = (UINT16)(value * (double)m_outputData.data.pwm_period[(channel - 1) >> 1]);
+ m_outputData.data.pwm_compare[channel - 1] = (uint16_t)(value * (double)m_outputData.data.pwm_period[(channel - 1) >> 1]);
}
/**
@@ -980,7 +980,7 @@
*
* @return The version of the firmware running on the IO board. 0 if the board is not attached or not in Enhanced mode.
*/
-UINT8 DriverStationEnhancedIO::GetFirmwareVersion()
+uint8_t DriverStationEnhancedIO::GetFirmwareVersion()
{
if (!m_inputValid)
{
diff --git a/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.h b/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.h
index fda32b8..ac265dd 100644
--- a/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.h
+++ b/aos/externals/WPILib/WPILib/DriverStationEnhancedIO.h
@@ -35,54 +35,54 @@
// BEGIN: Definitions from the Cypress firmware
typedef struct
{
- UINT16 digital;
- UINT16 digital_oe;
- UINT16 digital_pe;
- UINT16 pwm_compare[4];
- UINT16 pwm_period[2];
- UINT8 dac[2];
- UINT8 leds;
+ uint16_t digital;
+ uint16_t digital_oe;
+ uint16_t digital_pe;
+ uint16_t pwm_compare[4];
+ uint16_t pwm_period[2];
+ uint8_t dac[2];
+ uint8_t leds;
union
{
struct
{
// Bits are inverted from cypress fw because of big-endian!
- UINT8 pwm_enable : 4;
- UINT8 comparator_enable : 2;
- UINT8 quad_index_enable : 2;
+ uint8_t pwm_enable : 4;
+ uint8_t comparator_enable : 2;
+ uint8_t quad_index_enable : 2;
};
- UINT8 enables;
+ uint8_t enables;
};
- UINT8 fixed_digital_out;
+ uint8_t fixed_digital_out;
} output_t; //data to IO (23 bytes)
typedef struct
{
- UINT8 api_version;
- UINT8 fw_version;
- INT16 analog[8];
- UINT16 digital;
- INT16 accel[3];
- INT16 quad[2];
- UINT8 buttons;
- UINT8 capsense_slider;
- UINT8 capsense_proximity;
+ uint8_t api_version;
+ uint8_t fw_version;
+ int16_t analog[8];
+ uint16_t digital;
+ int16_t accel[3];
+ int16_t quad[2];
+ uint8_t buttons;
+ uint8_t capsense_slider;
+ uint8_t capsense_proximity;
} input_t; //data from IO (33 bytes)
// END: Definitions from the Cypress firmware
// Dynamic block definitions
typedef struct
{
- UINT8 size; // Must be 25 (size remaining in the block not counting the size variable)
- UINT8 id; // Must be 18
+ uint8_t size; // Must be 25 (size remaining in the block not counting the size variable)
+ uint8_t id; // Must be 18
output_t data;
- UINT8 flags;
+ uint8_t flags;
} status_block_t;
typedef struct
{
- UINT8 size; // Must be 34
- UINT8 id; // Must be 17
+ uint8_t size; // Must be 34
+ uint8_t id; // Must be 17
input_t data;
} control_block_t;
#pragma pack(pop)
@@ -100,31 +100,31 @@
enum tPWMPeriodChannels {kPWMChannels1and2, kPWMChannels3and4};
double GetAcceleration(tAccelChannel channel);
- double GetAnalogIn(UINT32 channel);
- double GetAnalogInRatio(UINT32 channel);
- double GetAnalogOut(UINT32 channel);
- void SetAnalogOut(UINT32 channel, double value);
- bool GetButton(UINT32 channel);
- UINT8 GetButtons();
- void SetLED(UINT32 channel, bool value);
- void SetLEDs(UINT8 value);
- bool GetDigital(UINT32 channel);
- UINT16 GetDigitals();
- void SetDigitalOutput(UINT32 channel, bool value);
- tDigitalConfig GetDigitalConfig(UINT32 channel);
- void SetDigitalConfig(UINT32 channel, tDigitalConfig config);
+ double GetAnalogIn(uint32_t channel);
+ double GetAnalogInRatio(uint32_t channel);
+ double GetAnalogOut(uint32_t channel);
+ void SetAnalogOut(uint32_t channel, double value);
+ bool GetButton(uint32_t channel);
+ uint8_t GetButtons();
+ void SetLED(uint32_t channel, bool value);
+ void SetLEDs(uint8_t value);
+ bool GetDigital(uint32_t channel);
+ uint16_t GetDigitals();
+ void SetDigitalOutput(uint32_t channel, bool value);
+ tDigitalConfig GetDigitalConfig(uint32_t channel);
+ void SetDigitalConfig(uint32_t channel, tDigitalConfig config);
double GetPWMPeriod(tPWMPeriodChannels channels);
void SetPWMPeriod(tPWMPeriodChannels channels, double period);
- bool GetFixedDigitalOutput(UINT32 channel);
- void SetFixedDigitalOutput(UINT32 channel, bool value);
- INT16 GetEncoder(UINT32 encoderNumber);
- void ResetEncoder(UINT32 encoderNumber);
- bool GetEncoderIndexEnable(UINT32 encoderNumber);
- void SetEncoderIndexEnable(UINT32 encoderNumber, bool enable);
+ bool GetFixedDigitalOutput(uint32_t channel);
+ void SetFixedDigitalOutput(uint32_t channel, bool value);
+ int16_t GetEncoder(uint32_t encoderNumber);
+ void ResetEncoder(uint32_t encoderNumber);
+ bool GetEncoderIndexEnable(uint32_t encoderNumber);
+ void SetEncoderIndexEnable(uint32_t encoderNumber, bool enable);
double GetTouchSlider();
- double GetPWMOutput(UINT32 channel);
- void SetPWMOutput(UINT32 channel, double value);
- UINT8 GetFirmwareVersion();
+ double GetPWMOutput(uint32_t channel);
+ void SetPWMOutput(uint32_t channel, double value);
+ uint8_t GetFirmwareVersion();
private:
DriverStationEnhancedIO();
@@ -144,7 +144,7 @@
bool m_outputValid;
bool m_configChanged;
bool m_requestEnhancedEnable;
- INT16 m_encoderOffsets[2];
+ int16_t m_encoderOffsets[2];
};
#endif
diff --git a/aos/externals/WPILib/WPILib/DriverStationLCD.cpp b/aos/externals/WPILib/WPILib/DriverStationLCD.cpp
index fe4893f..6841a69 100644
--- a/aos/externals/WPILib/WPILib/DriverStationLCD.cpp
+++ b/aos/externals/WPILib/WPILib/DriverStationLCD.cpp
@@ -11,10 +11,10 @@
#include "WPIErrors.h"
#include <strLib.h>
-const UINT32 DriverStationLCD::kSyncTimeout_ms;
-const UINT16 DriverStationLCD::kFullDisplayTextCommand;
-const INT32 DriverStationLCD::kLineLength;
-const INT32 DriverStationLCD::kNumLines;
+const uint32_t DriverStationLCD::kSyncTimeout_ms;
+const uint16_t DriverStationLCD::kFullDisplayTextCommand;
+const int32_t DriverStationLCD::kLineLength;
+const int32_t DriverStationLCD::kNumLines;
DriverStationLCD* DriverStationLCD::m_instance = NULL;
/**
@@ -29,7 +29,7 @@
m_textBuffer = new char[USER_DS_LCD_DATA_SIZE];
memset(m_textBuffer, ' ', USER_DS_LCD_DATA_SIZE);
- *((UINT16 *)m_textBuffer) = kFullDisplayTextCommand;
+ *((uint16_t *)m_textBuffer) = kFullDisplayTextCommand;
m_textBufferSemaphore = semMCreate(SEM_DELETE_SAFE);
@@ -75,7 +75,7 @@
* @param startingColumn The column to start printing to. This is a 1-based number.
* @param writeFmt The printf format string describing how to print.
*/
-void DriverStationLCD::Printf(Line line, INT32 startingColumn, const char *writeFmt, ...)
+void DriverStationLCD::Printf(Line line, int32_t startingColumn, const char *writeFmt, ...)
{
va_list args;
va_start (args, writeFmt);
@@ -83,10 +83,10 @@
va_end (args);
}
-void DriverStationLCD::VPrintf(Line line, INT32 startingColumn, const char *writeFmt, va_list args)
+void DriverStationLCD::VPrintf(Line line, int32_t startingColumn, const char *writeFmt, va_list args)
{
- UINT32 start = startingColumn - 1;
- INT32 maxLength = kLineLength - start;
+ uint32_t start = startingColumn - 1;
+ int32_t maxLength = kLineLength - start;
char lineBuffer[kLineLength + 1];
if (startingColumn < 1 || startingColumn > kLineLength)
@@ -104,10 +104,10 @@
{
Synchronized sync(m_textBufferSemaphore);
// snprintf appends NULL to its output. Therefore we can't write directly to the buffer.
- INT32 length = vsnprintf(lineBuffer, kLineLength + 1, writeFmt, args);
+ int32_t length = vsnprintf(lineBuffer, kLineLength + 1, writeFmt, args);
if (length < 0) length = kLineLength;
- memcpy(m_textBuffer + start + line * kLineLength + sizeof(UINT16), lineBuffer, std::min(maxLength,length));
+ memcpy(m_textBuffer + start + line * kLineLength + sizeof(uint16_t), lineBuffer, std::min(maxLength,length));
}
}
@@ -141,7 +141,7 @@
{
Synchronized sync(m_textBufferSemaphore);
// snprintf appends NULL to its output. Therefore we can't write directly to the buffer.
- INT32 length = std::min(vsnprintf(lineBuffer, kLineLength + 1, writeFmt, args), kLineLength);
+ int32_t length = std::min(vsnprintf(lineBuffer, kLineLength + 1, writeFmt, args), (int)kLineLength);
if (length < 0) length = kLineLength;
// Fill the rest of the buffer
@@ -150,7 +150,7 @@
memset(lineBuffer + length, ' ', kLineLength - length);
}
- memcpy(m_textBuffer + line * kLineLength + sizeof(UINT16), lineBuffer, kLineLength);
+ memcpy(m_textBuffer + line * kLineLength + sizeof(uint16_t), lineBuffer, kLineLength);
}
}
@@ -160,6 +160,6 @@
void DriverStationLCD::Clear()
{
Synchronized sync(m_textBufferSemaphore);
- memset(m_textBuffer + sizeof(UINT16), ' ', kLineLength*kNumLines);
+ memset(m_textBuffer + sizeof(uint16_t), ' ', kLineLength*kNumLines);
}
diff --git a/aos/externals/WPILib/WPILib/DriverStationLCD.h b/aos/externals/WPILib/WPILib/DriverStationLCD.h
index 1a3731f..ebdf6bc 100644
--- a/aos/externals/WPILib/WPILib/DriverStationLCD.h
+++ b/aos/externals/WPILib/WPILib/DriverStationLCD.h
@@ -19,17 +19,17 @@
class DriverStationLCD : public SensorBase
{
public:
- static const UINT32 kSyncTimeout_ms = 20;
- static const UINT16 kFullDisplayTextCommand = 0x9FFF;
- static const INT32 kLineLength = 21;
- static const INT32 kNumLines = 6;
+ static const uint32_t kSyncTimeout_ms = 20;
+ static const uint16_t kFullDisplayTextCommand = 0x9FFF;
+ static const int32_t kLineLength = 21;
+ static const int32_t kNumLines = 6;
enum Line {kMain_Line6=0, kUser_Line1=0, kUser_Line2=1, kUser_Line3=2, kUser_Line4=3, kUser_Line5=4, kUser_Line6=5};
static DriverStationLCD *GetInstance();
void UpdateLCD();
- void Printf(Line line, INT32 startingColumn, const char *writeFmt, ...);
- void VPrintf(Line line, INT32 startingColumn, const char *writeFmt, va_list args);
+ void Printf(Line line, int32_t startingColumn, const char *writeFmt, ...);
+ void VPrintf(Line line, int32_t startingColumn, const char *writeFmt, va_list args);
void PrintfLine(Line line, const char *writeFmt, ...);
void VPrintfLine(Line line, const char *writeFmt, va_list args);
diff --git a/aos/externals/WPILib/WPILib/Eclipse.cproject b/aos/externals/WPILib/WPILib/Eclipse.cproject
new file mode 100644
index 0000000..8447cbb
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Eclipse.cproject
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/WPILib"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/WPILib/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="WPILib" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494" name="Debug" parent="cdt.managedbuild.config.gnu.cross.exe.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.994329655" name="Cross GCC" nonInternalBuilderId="cdt.managedbuild.builder.gnu.cross" resourceTypeBasedDiscovery="true" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
+ <option id="cdt.managedbuild.option.gnu.cross.prefix.1233302794" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" value="powerpc-wrs-vxworks-" valueType="string"/>
+ <option id="cdt.managedbuild.option.gnu.cross.path.344448660" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path" value="/usr/powerpc-wrs-vxworks/bin" valueType="string"/>
+ <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1506551398" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
+ <builder autoBuildTarget="all" buildPath="${workspace_loc:/WPILib/Debug}" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.1737288017" incrementalBuildTarget="all" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
+ <tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.720051271" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1408965103" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.debugging.level.1453206520" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1545251527" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1658342348" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
+ <option id="gnu.cpp.compiler.option.optimization.level.486336400" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.debugging.level.1345636137" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.default" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.warnings.toerrors.1436493674" name="Warnings as errors (-Werror)" superClass="gnu.cpp.compiler.option.warnings.toerrors" value="true" valueType="boolean"/>
+ <option id="gnu.cpp.compiler.option.other.other.921313522" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -mcpu=603 -mstrict-align -mlongcall -DTOOL=GNU -std=gnu++11" valueType="string"/>
+ <option id="gnu.cpp.compiler.option.include.paths.1510285501" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
+ </option>
+ <option id="gnu.cpp.compiler.option.warnings.pedantic.136839208" name="Pedantic (-pedantic)" superClass="gnu.cpp.compiler.option.warnings.pedantic" value="false" valueType="boolean"/>
+ <option id="gnu.cpp.compiler.option.warnings.extrawarn.1677322864" name="Extra warnings (-Wextra)" superClass="gnu.cpp.compiler.option.warnings.extrawarn" value="false" valueType="boolean"/>
+ <option id="gnu.cpp.compiler.option.warnings.pedantic.error.845911741" name="Pedantic warnings as errors (-pedantic-errors)" superClass="gnu.cpp.compiler.option.warnings.pedantic.error" value="false" valueType="boolean"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2053579657" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1358345602" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker">
+ <option defaultValue="true" id="gnu.c.link.option.shared.1740428128" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1430642678" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
+ <option defaultValue="true" id="gnu.cpp.link.option.shared.238861230" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.235722841" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cross.archiver.1709016862" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver">
+ <option id="gnu.both.lib.option.flags.1145203980" name="Archiver flags" superClass="gnu.both.lib.option.flags" value="-crus" valueType="string"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cross.assembler.1675338920" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.428648088" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="WPILib.cdt.managedbuild.target.gnu.cross.exe.869600547" name="Executable" projectType="cdt.managedbuild.target.gnu.cross.exe"/>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/WPILib"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494;cdt.managedbuild.config.gnu.cross.exe.debug.1905580494.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.1658342348;cdt.managedbuild.tool.gnu.cpp.compiler.input.2053579657">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+ <buildOutputProvider>
+ <openAction enabled="true" filePath=""/>
+ <parser enabled="true"/>
+ </buildOutputProvider>
+ <scannerInfoProvider id="specsFile">
+ <runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.cpp"" command="powerpc-wrs-vxworks-g++" useDefault="true"/>
+ <parser enabled="true"/>
+ </scannerInfoProvider>
+ </profile>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494;cdt.managedbuild.config.gnu.cross.exe.debug.1905580494.;cdt.managedbuild.tool.gnu.cross.c.compiler.720051271;cdt.managedbuild.tool.gnu.c.compiler.input.1545251527">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+ <buildOutputProvider>
+ <openAction enabled="true" filePath=""/>
+ <parser enabled="true"/>
+ </buildOutputProvider>
+ <scannerInfoProvider id="specsFile">
+ <runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.c"" command="powerpc-wrs-vxworks-gcc" useDefault="true"/>
+ <parser enabled="true"/>
+ </scannerInfoProvider>
+ </profile>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1905580494">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+</cproject>
diff --git a/aos/externals/WPILib/WPILib/Eclipse.project b/aos/externals/WPILib/WPILib/Eclipse.project
new file mode 100644
index 0000000..2a7f5d1
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Eclipse.project
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>WPILib</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/aos/externals/WPILib/WPILib/Encoder.cpp b/aos/externals/WPILib/WPILib/Encoder.cpp
index cfb96c9..941b8cc 100644
--- a/aos/externals/WPILib/WPILib/Encoder.cpp
+++ b/aos/externals/WPILib/WPILib/Encoder.cpp
@@ -25,11 +25,12 @@
*/
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType)
{
+ m_table = NULL;
m_encodingType = encodingType;
tRioStatusCode localStatus = NiFpga_Status_Success;
if (encodingType == k4X) {
Resource::CreateResourceObject(&quadEncoders, tEncoder::kNumSystems);
- UINT32 index = quadEncoders->Allocate("4X Encoder", this);
+ uint32_t index = quadEncoders->Allocate("4X Encoder", this);
if (index == ~0ul)
{
return;
@@ -83,8 +84,8 @@
* a counter object will be used and the returned value will either exactly match the spec'd count
* or be double (2x) the spec'd count.
*/
-Encoder::Encoder(UINT8 aModuleNumber, UINT32 aChannel,
- UINT8 bModuleNumber, UINT32 bChannel,
+Encoder::Encoder(uint8_t aModuleNumber, uint32_t aChannel,
+ uint8_t bModuleNumber, uint32_t bChannel,
bool reverseDirection, EncodingType encodingType) :
m_encoder(NULL),
m_counter(NULL)
@@ -109,7 +110,7 @@
* a counter object will be used and the returned value will either exactly match the spec'd count
* or be double (2x) the spec'd count.
*/
-Encoder::Encoder(UINT32 aChannel, UINT32 bChannel, bool reverseDirection, EncodingType encodingType) :
+Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, EncodingType encodingType) :
m_encoder(NULL),
m_counter(NULL)
{
@@ -233,10 +234,10 @@
* factor.
* @return Current raw count from the encoder
*/
-INT32 Encoder::GetRaw()
+int32_t Encoder::GetRaw()
{
if (StatusIsFatal()) return 0;
- INT32 value;
+ int32_t value;
if (m_counter)
value = m_counter->Get();
else
@@ -255,10 +256,10 @@
*
* @return Current count from the Encoder adjusted for the 1x, 2x, or 4x scale factor.
*/
-INT32 Encoder::Get()
+int32_t Encoder::Get()
{
if (StatusIsFatal()) return 0;
- return (INT32) (GetRaw() * DecodingScaleFactor());
+ return (int32_t) (GetRaw() * DecodingScaleFactor());
}
/**
@@ -339,7 +340,7 @@
else
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- m_encoder->writeTimerConfig_StallPeriod((UINT32)(maxPeriod * 1.0e6 * DecodingScaleFactor()), &localStatus);
+ m_encoder->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6 * DecodingScaleFactor()), &localStatus);
wpi_setError(localStatus);
}
}
@@ -478,6 +479,57 @@
}
}
+
+/**
+ * Set the Samples to Average which specifies the number of samples of the timer to
+ * average when calculating the period. Perform averaging to account for
+ * mechanical imperfections or as oversampling to increase resolution.
+ * @param samplesToAverage The number of samples to average from 1 to 127.
+ */
+void Encoder::SetSamplesToAverage(int samplesToAverage)
+{
+ tRioStatusCode localStatus = NiFpga_Status_Success;
+ if (samplesToAverage < 1 || samplesToAverage > 127)
+ {
+ wpi_setWPIErrorWithContext(ParameterOutOfRange, "Average counter values must be between 1 and 127");
+ }
+ switch (m_encodingType) {
+ case k4X:
+ m_encoder->writeTimerConfig_AverageSize(samplesToAverage, &localStatus);
+ break;
+ case k1X:
+ case k2X:
+ m_counter->SetSamplesToAverage(samplesToAverage);
+ break;
+ }
+ wpi_setError(localStatus);
+}
+
+/**
+ * Get the Samples to Average which specifies the number of samples of the timer to
+ * average when calculating the period. Perform averaging to account for
+ * mechanical imperfections or as oversampling to increase resolution.
+ * @return SamplesToAverage The number of samples being averaged (from 1 to 127)
+ */
+int Encoder::GetSamplesToAverage()
+{
+ tRioStatusCode localStatus = NiFpga_Status_Success;
+ int result = 1;
+ switch (m_encodingType) {
+ case k4X:
+ result = m_encoder->readTimerConfig_AverageSize(&localStatus);
+ break;
+ case k1X:
+ case k2X:
+ result = m_counter->GetSamplesToAverage();
+ break;
+ }
+ wpi_setError(localStatus);
+ return result;
+}
+
+
+
/**
* Set which parameter of the encoder you are using as a process control variable.
*
diff --git a/aos/externals/WPILib/WPILib/Encoder.h b/aos/externals/WPILib/WPILib/Encoder.h
index 7f9605c..e42ae6a 100644
--- a/aos/externals/WPILib/WPILib/Encoder.h
+++ b/aos/externals/WPILib/WPILib/Encoder.h
@@ -28,18 +28,17 @@
class Encoder: public SensorBase, public CounterBase, public PIDSource, public LiveWindowSendable
{
public:
- typedef enum {kDistance, kRate} PIDSourceParameter;
- Encoder(UINT32 aChannel, UINT32 bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
- Encoder(UINT8 aModuleNumber, UINT32 aChannel, UINT8 bModuleNumber, UINT32 _bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
+ Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
+ Encoder(uint8_t aModuleNumber, uint32_t aChannel, uint8_t bModuleNumber, uint32_t _bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
virtual ~Encoder();
// CounterBase interface
void Start();
- INT32 Get();
- INT32 GetRaw();
+ int32_t Get();
+ int32_t GetRaw();
void Reset();
void Stop();
double GetPeriod();
@@ -51,7 +50,8 @@
void SetMinRate(double minRate);
void SetDistancePerPulse(double distancePerPulse);
void SetReverseDirection(bool reverseDirection);
-
+ void SetSamplesToAverage(int samplesToAverage);
+ int GetSamplesToAverage();
void SetPIDSourceParameter(PIDSourceParameter pidSource);
double PIDGet();
@@ -71,7 +71,7 @@
bool m_allocatedASource; // was the A source allocated locally?
bool m_allocatedBSource; // was the B source allocated locally?
tEncoder* m_encoder;
- UINT8 m_index;
+ uint8_t m_index;
double m_distancePerPulse; // distance of travel for each encoder tick
Counter *m_counter; // Counter object for 1x and 2x encoding
EncodingType m_encodingType; // Encoding type
diff --git a/aos/externals/WPILib/WPILib/Error.cpp b/aos/externals/WPILib/WPILib/Error.cpp
index 9e83de7..11399ca 100644
--- a/aos/externals/WPILib/WPILib/Error.cpp
+++ b/aos/externals/WPILib/WPILib/Error.cpp
@@ -7,11 +7,12 @@
#include "Error.h"
#include <taskLib.h>
+#include <cstdio>
+#include <cstring>
#include "NetworkCommunication/FRCComm.h"
#include "Timer.h"
#include "Utility.h"
-
bool Error::m_stackTraceEnabled = false;
bool Error::m_suspendOnErrorEnabled = false;
@@ -74,7 +75,7 @@
std::string Error::GetFunction() const
{ return m_function; }
-UINT32 Error::GetLineNumber() const
+uint32_t Error::GetLineNumber() const
{ return m_lineNumber; }
const ErrorBase* Error::GetOriginatingObject() const
@@ -84,7 +85,7 @@
{ return m_timestamp; }
void Error::Set(Code code, const char* contextMessage, const char* filename,
- const char* function, UINT32 lineNumber,
+ const char* function, uint32_t lineNumber,
const ErrorBase* originatingObject) {
Synchronized sync(m_semaphore);
m_code = code;
@@ -111,11 +112,11 @@
{
snprintf(error, sizeof(error),
"%s: status = %d (0x%08X) %s ...in %s() in %s at line %d\n",
- m_code < 0 ? "ERROR" : "WARNING", (INT32)m_code,
- (UINT32)m_code, m_message.c_str(),
+ m_code < 0 ? "ERROR" : "WARNING", (int32_t)m_code,
+ (uint32_t)m_code, m_message.c_str(),
m_function.c_str(), m_filename.c_str(), m_lineNumber);
snprintf(error_with_code, sizeof(error_with_code),
- "<Code>%d %s", (INT32)m_code, error);
+ "<Code>%ld %s", (int32_t)m_code, error);
} else {
snprintf(error, sizeof(error),
"%s: %s ...in %s() in %s at line %d\n",
diff --git a/aos/externals/WPILib/WPILib/Error.h b/aos/externals/WPILib/WPILib/Error.h
index 9636262..6ded992 100644
--- a/aos/externals/WPILib/WPILib/Error.h
+++ b/aos/externals/WPILib/WPILib/Error.h
@@ -34,7 +34,7 @@
void Clone(const Error &error);
void Clear();
void Set(Code code, const char* contextMessage, const char* filename,
- const char *function, UINT32 lineNumber, const ErrorBase* originatingObject);
+ const char *function, uint32_t lineNumber, const ErrorBase* originatingObject);
bool IsClear() const;
Code GetCode() const;
@@ -43,7 +43,7 @@
std::string GetMessage() const;
std::string GetFilename() const;
std::string GetFunction() const;
- UINT32 GetLineNumber() const;
+ uint32_t GetLineNumber() const;
const ErrorBase* GetOriginatingObject() const;
double GetTime() const;
@@ -64,7 +64,7 @@
std::string m_message;
std::string m_filename;
std::string m_function;
- UINT32 m_lineNumber;
+ uint32_t m_lineNumber;
const ErrorBase* m_originatingObject;
double m_timestamp;
// Used for protecting all modifications to instance data.
diff --git a/aos/externals/WPILib/WPILib/ErrorBase.cpp b/aos/externals/WPILib/WPILib/ErrorBase.cpp
index 5f766c7..8f717b9 100644
--- a/aos/externals/WPILib/WPILib/ErrorBase.cpp
+++ b/aos/externals/WPILib/WPILib/ErrorBase.cpp
@@ -13,6 +13,7 @@
#include <errnoLib.h>
#include <symLib.h>
#include <sysSymTbl.h>
+#include <cstdio>
Error ErrorBase::_globalError;
@@ -54,7 +55,7 @@
* @param lineNumber Line number of the error source
*/
void ErrorBase::SetErrnoError(const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const
+ const char* filename, const char* function, uint32_t lineNumber) const
{
char err[256];
int errNo = errnoGet();
@@ -91,7 +92,7 @@
* @param function Function of the error source
* @param lineNumber Line number of the error source
*/
-void ErrorBase::SetImaqError(int success, const char *contextMessage, const char* filename, const char* function, UINT32 lineNumber) const
+void ErrorBase::SetImaqError(int success, const char *contextMessage, const char* filename, const char* function, uint32_t lineNumber) const
{
// If there was an error
if (success <= 0) {
@@ -116,7 +117,7 @@
* @param lineNumber Line number of the error source
*/
void ErrorBase::SetError(Error::Code code, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const
+ const char* filename, const char* function, uint32_t lineNumber) const
{
// If there was an error
if (code != 0) {
@@ -137,7 +138,7 @@
* @param lineNumber Line number of the error source
*/
void ErrorBase::SetWPIError(const char *errorMessage, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const
+ const char* filename, const char* function, uint32_t lineNumber) const
{
char err[256];
snprintf(err, sizeof(err), "%s: %s", errorMessage, contextMessage);
@@ -175,7 +176,7 @@
* @param lineNumber Line number of the error source
*/
void ErrorBase::SetGlobalError(Error::Code code, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber)
+ const char* filename, const char* function, uint32_t lineNumber)
{
if (code != 0) {
// Set the current error information for this object.
@@ -193,7 +194,7 @@
* @param lineNumber Line number of the error source
*/
void ErrorBase::SetGlobalWPIError(const char *errorMessage, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber)
+ const char* filename, const char* function, uint32_t lineNumber)
{
char err[256];
snprintf(err, sizeof(err), "%s: %s", errorMessage, contextMessage);
diff --git a/aos/externals/WPILib/WPILib/ErrorBase.h b/aos/externals/WPILib/WPILib/ErrorBase.h
index 9d032cb..7ccac2d 100644
--- a/aos/externals/WPILib/WPILib/ErrorBase.h
+++ b/aos/externals/WPILib/WPILib/ErrorBase.h
@@ -66,20 +66,20 @@
Error& GetError() const;
void SetErrnoError(const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const;
+ const char* filename, const char* function, uint32_t lineNumber) const;
void SetImaqError(int success, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const;
+ const char* filename, const char* function, uint32_t lineNumber) const;
void SetError(Error::Code code, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const;
+ const char* filename, const char* function, uint32_t lineNumber) const;
void SetWPIError(const char *errorMessage, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber) const;
+ const char* filename, const char* function, uint32_t lineNumber) const;
void CloneError(const ErrorBase *rhs) const;
void ClearError() const;
bool StatusIsFatal() const;
static void SetGlobalError(Error::Code code, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber);
+ const char* filename, const char* function, uint32_t lineNumber);
static void SetGlobalWPIError(const char *errorMessage, const char *contextMessage,
- const char* filename, const char* function, UINT32 lineNumber);
+ const char* filename, const char* function, uint32_t lineNumber);
static const Error& GetGlobalError();
protected:
diff --git a/aos/externals/WPILib/WPILib/GearTooth.cpp b/aos/externals/WPILib/WPILib/GearTooth.cpp
index 077385d..118b9f6 100644
--- a/aos/externals/WPILib/WPILib/GearTooth.cpp
+++ b/aos/externals/WPILib/WPILib/GearTooth.cpp
@@ -7,7 +7,7 @@
#include "GearTooth.h"
#include "LiveWindow/LiveWindow.h"
-const double GearTooth::kGearToothThreshold;
+constexpr double GearTooth::kGearToothThreshold;
/**
* Common code called by the constructors.
@@ -28,7 +28,7 @@
* @param channel The GPIO channel on the digital module that the sensor is connected to.
* @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
*/
-GearTooth::GearTooth(UINT32 channel, bool directionSensitive)
+GearTooth::GearTooth(uint32_t channel, bool directionSensitive)
: Counter(channel)
{
EnableDirectionSensing(directionSensitive);
@@ -41,7 +41,7 @@
* @param channel The GPIO channel on the digital module that the sensor is connected to.
* @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
*/
-GearTooth::GearTooth(UINT8 moduleNumber, UINT32 channel, bool directionSensitive)
+GearTooth::GearTooth(uint8_t moduleNumber, uint32_t channel, bool directionSensitive)
: Counter(moduleNumber, channel)
{
EnableDirectionSensing(directionSensitive);
diff --git a/aos/externals/WPILib/WPILib/GearTooth.h b/aos/externals/WPILib/WPILib/GearTooth.h
index 509f1ba..c2d6f49 100644
--- a/aos/externals/WPILib/WPILib/GearTooth.h
+++ b/aos/externals/WPILib/WPILib/GearTooth.h
@@ -19,9 +19,9 @@
{
public:
/// 55 uSec for threshold
- static const double kGearToothThreshold = 55e-6;
- GearTooth(UINT32 channel, bool directionSensitive = false);
- GearTooth(UINT8 moduleNumber, UINT32 channel, bool directionSensitive = false);
+ static constexpr double kGearToothThreshold = 55e-6;
+ GearTooth(uint32_t channel, bool directionSensitive = false);
+ GearTooth(uint8_t moduleNumber, uint32_t channel, bool directionSensitive = false);
GearTooth(DigitalSource *source, bool directionSensitive = false);
GearTooth(DigitalSource &source, bool directionSensitive = false);
virtual ~GearTooth();
diff --git a/aos/externals/WPILib/WPILib/GenericHID.h b/aos/externals/WPILib/WPILib/GenericHID.h
index 6442d6d..0841d12 100644
--- a/aos/externals/WPILib/WPILib/GenericHID.h
+++ b/aos/externals/WPILib/WPILib/GenericHID.h
@@ -26,12 +26,12 @@
virtual float GetZ() = 0;
virtual float GetTwist() = 0;
virtual float GetThrottle() = 0;
- virtual float GetRawAxis(UINT32 axis) = 0;
+ virtual float GetRawAxis(uint32_t axis) = 0;
virtual bool GetTrigger(JoystickHand hand = kRightHand) = 0;
virtual bool GetTop(JoystickHand hand = kRightHand) = 0;
virtual bool GetBumper(JoystickHand hand = kRightHand) = 0;
- virtual bool GetRawButton(UINT32 button) = 0;
+ virtual bool GetRawButton(uint32_t button) = 0;
};
#endif
diff --git a/aos/externals/WPILib/WPILib/Global.cpp b/aos/externals/WPILib/WPILib/Global.cpp
index 0d48129..23c29ec 100644
--- a/aos/externals/WPILib/WPILib/Global.cpp
+++ b/aos/externals/WPILib/WPILib/Global.cpp
@@ -36,10 +36,10 @@
* For now, expect this to be competition year.
* @return FPGA Version number.
*/
-UINT16 Global::GetFPGAVersion()
+uint16_t Global::GetFPGAVersion()
{
tRioStatusCode status = NiFpga_Status_Success;
- UINT16 version = global_->readVersion(&status);
+ uint16_t version = global_->readVersion(&status);
wpi_setError(status);
return version;
}
@@ -52,10 +52,10 @@
* The 12 least significant bits are the Build Number.
* @return FPGA Revision number.
*/
-UINT32 Global::GetFPGARevision()
+uint32_t Global::GetFPGARevision()
{
tRioStatusCode status = NiFpga_Status_Success;
- UINT32 revision = global_->readRevision(&status);
+ uint32_t revision = global_->readRevision(&status);
wpi_setError(status);
return revision;
}
@@ -65,10 +65,10 @@
*
* @return The current time in microseconds according to the FPGA (since FPGA reset).
*/
-UINT32 Global::GetFPGATime()
+uint32_t Global::GetFPGATime()
{
tRioStatusCode status = NiFpga_Status_Success;
- UINT32 time = global_->readLocalTime(&status);
+ uint32_t time = global_->readLocalTime(&status);
wpi_setError(status);
return time;
}
@@ -76,17 +76,17 @@
// RT hardware access functions exported from ni_emb.out
extern "C"
{
- INT32 UserSwitchInput(INT32 nSwitch);
- INT32 LedInput(INT32 led);
- INT32 LedOutput(INT32 led, INT32 value);
+ int32_t UserSwitchInput(int32_t nSwitch);
+ int32_t LedInput(int32_t led);
+ int32_t LedOutput(int32_t led, int32_t value);
}
/**
* Read the value of the USER1 DIP switch on the cRIO.
*/
-INT32 Global::GetRIOUserSwitch()
+int32_t Global::GetRIOUserSwitch()
{
- INT32 switchValue = UserSwitchInput(0);
+ int32_t switchValue = UserSwitchInput(0);
wpi_assert(switchValue >= 0);
return switchValue > 0;
}
@@ -94,7 +94,7 @@
/**
* Set the state of the USER1 status LED on the cRIO.
*/
-void Global::SetRIOUserLED(UINT32 state)
+void Global::SetRIOUserLED(uint32_t state)
{
LedOutput(0, state > 0);
}
@@ -103,7 +103,7 @@
* Get the current state of the USER1 status LED on the cRIO.
* @return The curent state of the USER1 LED.
*/
-INT32 Global::GetRIOUserLED()
+int32_t Global::GetRIOUserLED()
{
return LedInput(0);
}
@@ -112,10 +112,10 @@
* Toggle the state of the USER1 status LED on the cRIO.
* @return The new state of the USER1 LED.
*/
-INT32 Global::ToggleRIOUserLED()
+int32_t Global::ToggleRIOUserLED()
{
Synchronized sync(led_toggle_lock_);
- INT32 ledState = !GetRIOUserLED();
+ int32_t ledState = !GetRIOUserLED();
SetRIOUserLED(ledState);
return ledState;
}
@@ -123,7 +123,7 @@
/**
* Set the state of the FPGA status LED on the cRIO.
*/
-void Global::SetRIO_FPGA_LED(UINT32 state)
+void Global::SetRIO_FPGA_LED(uint32_t state)
{
tRioStatusCode status = NiFpga_Status_Success;
global_->writeFPGA_LED(state, &status);
@@ -134,7 +134,7 @@
* Get the current state of the FPGA status LED on the cRIO.
* @return The curent state of the FPGA LED.
*/
-INT32 Global::GetRIO_FPGA_LED()
+int32_t Global::GetRIO_FPGA_LED()
{
tRioStatusCode status = NiFpga_Status_Success;
bool ledValue = global_->readFPGA_LED(&status);
@@ -146,10 +146,10 @@
* Toggle the state of the FPGA status LED on the cRIO.
* @return The new state of the FPGA LED.
*/
-INT32 Global::ToggleRIO_FPGA_LED()
+int32_t Global::ToggleRIO_FPGA_LED()
{
Synchronized sync(led_toggle_lock_);
- INT32 ledState = !GetRIO_FPGA_LED();
+ int32_t ledState = !GetRIO_FPGA_LED();
SetRIO_FPGA_LED(ledState);
return ledState;
}
diff --git a/aos/externals/WPILib/WPILib/Global.h b/aos/externals/WPILib/WPILib/Global.h
index 4857e09..869de50 100644
--- a/aos/externals/WPILib/WPILib/Global.h
+++ b/aos/externals/WPILib/WPILib/Global.h
@@ -17,16 +17,16 @@
public:
static Global *GetInstance();
- UINT16 GetFPGAVersion();
- UINT32 GetFPGARevision();
- UINT32 GetFPGATime();
- INT32 GetRIOUserSwitch();
- void SetRIOUserLED(UINT32 state);
- INT32 GetRIOUserLED();
- INT32 ToggleRIOUserLED();
- void SetRIO_FPGA_LED(UINT32 state);
- INT32 GetRIO_FPGA_LED();
- INT32 ToggleRIO_FPGA_LED();
+ uint16_t GetFPGAVersion();
+ uint32_t GetFPGARevision();
+ uint32_t GetFPGATime();
+ int32_t GetRIOUserSwitch();
+ void SetRIOUserLED(uint32_t state);
+ int32_t GetRIOUserLED();
+ int32_t ToggleRIOUserLED();
+ void SetRIO_FPGA_LED(uint32_t state);
+ int32_t GetRIO_FPGA_LED();
+ int32_t ToggleRIO_FPGA_LED();
private:
Global();
diff --git a/aos/externals/WPILib/WPILib/Gyro.cpp b/aos/externals/WPILib/WPILib/Gyro.cpp
index 34034ff..af69cf3 100644
--- a/aos/externals/WPILib/WPILib/Gyro.cpp
+++ b/aos/externals/WPILib/WPILib/Gyro.cpp
@@ -12,11 +12,11 @@
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
-const UINT32 Gyro::kOversampleBits;
-const UINT32 Gyro::kAverageBits;
-const float Gyro::kSamplesPerSecond;
-const float Gyro::kCalibrationSampleTime;
-const float Gyro::kDefaultVoltsPerDegreePerSecond;
+const uint32_t Gyro::kOversampleBits;
+const uint32_t Gyro::kAverageBits;
+constexpr float Gyro::kSamplesPerSecond;
+constexpr float Gyro::kCalibrationSampleTime;
+constexpr float Gyro::kDefaultVoltsPerDegreePerSecond;
/**
* Initialize the gyro.
@@ -28,6 +28,7 @@
*/
void Gyro::InitGyro()
{
+ m_table = NULL;
if (!m_analog->IsAccumulatorChannel())
{
wpi_setWPIErrorWithContext(ParameterOutOfRange,
@@ -51,17 +52,19 @@
m_analog->InitAccumulator();
Wait(kCalibrationSampleTime);
- INT64 value;
- UINT32 count;
+ int64_t value;
+ uint32_t count;
m_analog->GetAccumulatorOutput(&value, &count);
- UINT32 center = (UINT32)((float)value / (float)count + .5);
+ m_center = (uint32_t)((float)value / (float)count + .5);
- m_offset = ((float)value / (float)count) - (float)center;
+ m_offset = ((float)value / (float)count) - (float)m_center;
- m_analog->SetAccumulatorCenter(center);
+ m_analog->SetAccumulatorCenter(m_center);
m_analog->SetAccumulatorDeadband(0); ///< TODO: compute / parameterize this
m_analog->ResetAccumulator();
+
+ SetPIDSourceParameter(kAngle);
nUsageReporting::report(nUsageReporting::kResourceType_Gyro, m_analog->GetChannel(), m_analog->GetModuleNumber() - 1);
LiveWindow::GetInstance()->AddSensor("Gyro", m_analog->GetModuleNumber(), m_analog->GetChannel(), this);
@@ -73,7 +76,7 @@
* @param moduleNumber The analog module the gyro is connected to (1).
* @param channel The analog channel the gyro is connected to (1 or 2).
*/
-Gyro::Gyro(UINT8 moduleNumber, UINT32 channel)
+Gyro::Gyro(uint8_t moduleNumber, uint32_t channel)
{
m_analog = new AnalogChannel(moduleNumber, channel);
m_channelAllocated = true;
@@ -87,7 +90,7 @@
*
* @param channel The analog channel the gyro is connected to.
*/
-Gyro::Gyro(UINT32 channel)
+Gyro::Gyro(uint32_t channel)
{
m_analog = new AnalogChannel(channel);
m_channelAllocated = true;
@@ -153,11 +156,11 @@
*/
float Gyro::GetAngle( void )
{
- INT64 rawValue;
- UINT32 count;
+ int64_t rawValue;
+ uint32_t count;
m_analog->GetAccumulatorOutput(&rawValue, &count);
- INT64 value = rawValue - (INT64)((float)count * m_offset);
+ int64_t value = rawValue - (int64_t)((float)count * m_offset);
double scaledValue = value * 1e-9 * (double)m_analog->GetLSBWeight() * (double)(1 << m_analog->GetAverageBits()) /
(m_analog->GetModule()->GetSampleRate() * m_voltsPerDegreePerSecond);
@@ -167,6 +170,20 @@
/**
+ * Return the rate of rotation of the gyro
+ *
+ * The rate is based on the most recent reading of the gyro analog value
+ *
+ * @return the current rate in degrees per second
+ */
+double Gyro::GetRate( void )
+{
+ return (m_analog->GetAverageValue() - ((double)m_center + m_offset)) * 1e-9 * m_analog->GetLSBWeight()
+ / ((1 << m_analog->GetOversampleBits()) * m_voltsPerDegreePerSecond);
+}
+
+
+/**
* Set the gyro type based on the sensitivity.
* This takes the number of volts/degree/second sensitivity of the gyro and uses it in subsequent
* calculations to allow the code to work with multiple gyros.
@@ -178,6 +195,13 @@
m_voltsPerDegreePerSecond = voltsPerDegreePerSecond;
}
+void Gyro::SetPIDSourceParameter(PIDSourceParameter pidSource)
+{
+ if(pidSource == 0 || pidSource > 2)
+ wpi_setWPIErrorWithContext(ParameterOutOfRange, "Gyro pidSource");
+ m_pidSource = pidSource;
+}
+
/**
* Get the angle in degrees for the PIDSource base object.
*
@@ -185,7 +209,14 @@
*/
double Gyro::PIDGet()
{
- return GetAngle();
+ switch(m_pidSource){
+ case kRate:
+ return GetRate();
+ case kAngle:
+ return GetAngle();
+ default:
+ return 0;
+ }
}
void Gyro::UpdateTable() {
diff --git a/aos/externals/WPILib/WPILib/Gyro.h b/aos/externals/WPILib/WPILib/Gyro.h
index 5673703..fd5be72 100644
--- a/aos/externals/WPILib/WPILib/Gyro.h
+++ b/aos/externals/WPILib/WPILib/Gyro.h
@@ -27,19 +27,21 @@
class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable
{
public:
- static const UINT32 kOversampleBits = 10;
- static const UINT32 kAverageBits = 0;
- static const float kSamplesPerSecond = 50.0;
- static const float kCalibrationSampleTime = 5.0;
- static const float kDefaultVoltsPerDegreePerSecond = 0.007;
+ static const uint32_t kOversampleBits = 10;
+ static const uint32_t kAverageBits = 0;
+ static constexpr float kSamplesPerSecond = 50.0;
+ static constexpr float kCalibrationSampleTime = 5.0;
+ static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007;
- Gyro(UINT8 moduleNumber, UINT32 channel);
- explicit Gyro(UINT32 channel);
+ Gyro(uint8_t moduleNumber, uint32_t channel);
+ explicit Gyro(uint32_t channel);
explicit Gyro(AnalogChannel *channel);
explicit Gyro(AnalogChannel &channel);
virtual ~Gyro();
virtual float GetAngle();
+ virtual double GetRate();
void SetSensitivity(float voltsPerDegreePerSecond);
+ void SetPIDSourceParameter(PIDSourceParameter pidSource);
virtual void Reset();
// PIDSource interface
@@ -59,6 +61,8 @@
float m_voltsPerDegreePerSecond;
float m_offset;
bool m_channelAllocated;
+ uint32_t m_center;
+ PIDSourceParameter m_pidSource;
ITable *m_table;
};
diff --git a/aos/externals/WPILib/WPILib/HiTechnicColorSensor.cpp b/aos/externals/WPILib/WPILib/HiTechnicColorSensor.cpp
index d2756ca..39850dc 100644
--- a/aos/externals/WPILib/WPILib/HiTechnicColorSensor.cpp
+++ b/aos/externals/WPILib/WPILib/HiTechnicColorSensor.cpp
@@ -8,30 +8,32 @@
#include "DigitalModule.h"
#include "I2C.h"
#include "NetworkCommunication/UsageReporting.h"
+#include "networktables2/type/NumberArray.h"
#include "WPIErrors.h"
-const UINT8 HiTechnicColorSensor::kAddress;
-const UINT8 HiTechnicColorSensor::kManufacturerBaseRegister;
-const UINT8 HiTechnicColorSensor::kManufacturerSize;
-const UINT8 HiTechnicColorSensor::kSensorTypeBaseRegister;
-const UINT8 HiTechnicColorSensor::kSensorTypeSize;
-const UINT8 HiTechnicColorSensor::kModeRegister;
-const UINT8 HiTechnicColorSensor::kColorRegister;
-const UINT8 HiTechnicColorSensor::kRedRegister;
-const UINT8 HiTechnicColorSensor::kGreenRegister;
-const UINT8 HiTechnicColorSensor::kBlueRegister;
-const UINT8 HiTechnicColorSensor::kRawRedRegister;
-const UINT8 HiTechnicColorSensor::kRawGreenRegister;
-const UINT8 HiTechnicColorSensor::kRawBlueRegister;
+const uint8_t HiTechnicColorSensor::kAddress;
+const uint8_t HiTechnicColorSensor::kManufacturerBaseRegister;
+const uint8_t HiTechnicColorSensor::kManufacturerSize;
+const uint8_t HiTechnicColorSensor::kSensorTypeBaseRegister;
+const uint8_t HiTechnicColorSensor::kSensorTypeSize;
+const uint8_t HiTechnicColorSensor::kModeRegister;
+const uint8_t HiTechnicColorSensor::kColorRegister;
+const uint8_t HiTechnicColorSensor::kRedRegister;
+const uint8_t HiTechnicColorSensor::kGreenRegister;
+const uint8_t HiTechnicColorSensor::kBlueRegister;
+const uint8_t HiTechnicColorSensor::kRawRedRegister;
+const uint8_t HiTechnicColorSensor::kRawGreenRegister;
+const uint8_t HiTechnicColorSensor::kRawBlueRegister;
/**
* Constructor.
*
* @param moduleNumber The digital module that the sensor is plugged into (1 or 2).
*/
-HiTechnicColorSensor::HiTechnicColorSensor(UINT8 moduleNumber)
+HiTechnicColorSensor::HiTechnicColorSensor(uint8_t moduleNumber)
: m_i2c (NULL)
{
+ m_table = NULL;
DigitalModule *module = DigitalModule::GetInstance(moduleNumber);
m_mode = kActive;
@@ -40,8 +42,8 @@
m_i2c = module->GetI2C(kAddress);
// Verify Sensor
- const UINT8 kExpectedManufacturer[] = "HiTechnc";
- const UINT8 kExpectedSensorType[] = "ColorPD ";
+ const uint8_t kExpectedManufacturer[] = "HiTechnc";
+ const uint8_t kExpectedSensorType[] = "ColorPD ";
if ( ! m_i2c->VerifySensor(kManufacturerBaseRegister, kManufacturerSize, kExpectedManufacturer) )
{
wpi_setWPIError(CompassManufacturerError);
@@ -74,9 +76,9 @@
*
* @return The estimated color.
*/
-UINT8 HiTechnicColorSensor::GetColor()
+uint8_t HiTechnicColorSensor::GetColor()
{
- UINT8 color = 0;
+ uint8_t color = 0;
if(m_mode != kActive)
{
@@ -100,9 +102,9 @@
*
* @return The Red sensor value.
*/
-UINT8 HiTechnicColorSensor::GetRed()
+uint8_t HiTechnicColorSensor::GetRed()
{
- UINT8 red = 0;
+ uint8_t red = 0;
if(m_mode != kActive)
{
@@ -126,9 +128,9 @@
*
* @return The Green sensor value.
*/
-UINT8 HiTechnicColorSensor::GetGreen()
+uint8_t HiTechnicColorSensor::GetGreen()
{
- UINT8 green = 0;
+ uint8_t green = 0;
if(m_mode != kActive)
{
@@ -152,9 +154,9 @@
*
* @return The Blue sensor value.
*/
-UINT8 HiTechnicColorSensor::GetBlue()
+uint8_t HiTechnicColorSensor::GetBlue()
{
- UINT8 blue = 0;
+ uint8_t blue = 0;
if(m_mode != kActive)
{
@@ -181,7 +183,7 @@
*/
HiTechnicColorSensor::RGB HiTechnicColorSensor::GetRGB()
{
- UINT8 colors[3] = {0,0,0};
+ uint8_t colors[3] = {0,0,0};
RGB result;
if(m_mode != kActive)
@@ -190,7 +192,7 @@
}
if(m_i2c)
{
- m_i2c->Read(kRawRedRegister, sizeof(colors), (UINT8*)&colors);
+ m_i2c->Read(kRawRedRegister, sizeof(colors), (uint8_t*)&colors);
}
result.red = colors[0];
@@ -211,9 +213,9 @@
*
* @return The Raw Red sensor value.
*/
-UINT16 HiTechnicColorSensor::GetRawRed()
+uint16_t HiTechnicColorSensor::GetRawRed()
{
- UINT16 rawRed = 0;
+ uint16_t rawRed = 0;
if(m_mode == kActive)
{
@@ -221,7 +223,7 @@
}
if (m_i2c)
{
- m_i2c->Read(kRawRedRegister, sizeof(rawRed), (UINT8 *)&rawRed);
+ m_i2c->Read(kRawRedRegister, sizeof(rawRed), (uint8_t *)&rawRed);
}
return rawRed;
}
@@ -237,9 +239,9 @@
*
* @return The Raw Green sensor value.
*/
-UINT16 HiTechnicColorSensor::GetRawGreen()
+uint16_t HiTechnicColorSensor::GetRawGreen()
{
- UINT16 rawGreen = 0;
+ uint16_t rawGreen = 0;
if(m_mode == kActive)
{
@@ -247,7 +249,7 @@
}
if (m_i2c)
{
- m_i2c->Read(kRawGreenRegister, sizeof(rawGreen), (UINT8 *)&rawGreen);
+ m_i2c->Read(kRawGreenRegister, sizeof(rawGreen), (uint8_t *)&rawGreen);
}
return rawGreen;
}
@@ -263,9 +265,9 @@
*
* @return The Raw Blue sensor value.
*/
-UINT16 HiTechnicColorSensor::GetRawBlue()
+uint16_t HiTechnicColorSensor::GetRawBlue()
{
- UINT16 rawBlue = 0;
+ uint16_t rawBlue = 0;
if(m_mode == kActive)
{
@@ -273,7 +275,7 @@
}
if (m_i2c)
{
- m_i2c->Read(kRawBlueRegister, sizeof(rawBlue), (UINT8 *)&rawBlue);
+ m_i2c->Read(kRawBlueRegister, sizeof(rawBlue), (uint8_t *)&rawBlue);
}
return rawBlue;
}
@@ -294,7 +296,7 @@
*/
HiTechnicColorSensor::RGB HiTechnicColorSensor::GetRawRGB()
{
- UINT8 colors[6] = {0,0,0,0,0,0};
+ uint8_t colors[6] = {0,0,0,0,0,0};
RGB result;
if(m_mode != kActive)
@@ -303,7 +305,7 @@
}
if(m_i2c)
{
- m_i2c->Read(kRedRegister, sizeof(colors), (UINT8*)&colors);
+ m_i2c->Read(kRedRegister, sizeof(colors), (uint8_t*)&colors);
}
result.red = (colors[0]<<8) + colors[1];
@@ -326,7 +328,7 @@
{
if(m_i2c)
{
- m_i2c->Write(kModeRegister, (UINT8)mode);
+ m_i2c->Write(kModeRegister, (uint8_t)mode);
}
}
@@ -352,6 +354,12 @@
void HiTechnicColorSensor::UpdateTable() {
if (m_table != NULL) {
m_table->PutNumber("Value", GetColor());
+ NumberArray* rgb = new NumberArray();
+ rgb->add(GetRed());
+ rgb->add(GetGreen());
+ rgb->add(GetBlue());
+ m_table->PutValue("RGB", *rgb);
+ delete rgb;
}
}
diff --git a/aos/externals/WPILib/WPILib/HiTechnicColorSensor.h b/aos/externals/WPILib/WPILib/HiTechnicColorSensor.h
index 86f36d0..e61fcb7 100644
--- a/aos/externals/WPILib/WPILib/HiTechnicColorSensor.h
+++ b/aos/externals/WPILib/WPILib/HiTechnicColorSensor.h
@@ -28,20 +28,20 @@
public:
enum tColorMode {kActive = 0, kPassive = 1, kRaw = 3};
typedef struct{
- UINT16 red;
- UINT16 blue;
- UINT16 green;
+ uint16_t red;
+ uint16_t blue;
+ uint16_t green;
}RGB;
- explicit HiTechnicColorSensor(UINT8 moduleNumber);
+ explicit HiTechnicColorSensor(uint8_t moduleNumber);
virtual ~HiTechnicColorSensor();
- UINT8 GetColor();
- UINT8 GetRed();
- UINT8 GetGreen();
- UINT8 GetBlue();
+ uint8_t GetColor();
+ uint8_t GetRed();
+ uint8_t GetGreen();
+ uint8_t GetBlue();
RGB GetRGB();
- UINT16 GetRawRed();
- UINT16 GetRawGreen();
- UINT16 GetRawBlue();
+ uint16_t GetRawRed();
+ uint16_t GetRawGreen();
+ uint16_t GetRawBlue();
RGB GetRawRGB();
void SetMode(tColorMode mode);
@@ -55,19 +55,19 @@
virtual void StopLiveWindowMode();
private:
- static const UINT8 kAddress = 0x02;
- static const UINT8 kManufacturerBaseRegister = 0x08;
- static const UINT8 kManufacturerSize = 0x08;
- static const UINT8 kSensorTypeBaseRegister = 0x10;
- static const UINT8 kSensorTypeSize = 0x08;
- static const UINT8 kModeRegister = 0x41;
- static const UINT8 kColorRegister = 0x42;
- static const UINT8 kRedRegister = 0x43;
- static const UINT8 kGreenRegister = 0x44;
- static const UINT8 kBlueRegister = 0x45;
- static const UINT8 kRawRedRegister = 0x43;
- static const UINT8 kRawGreenRegister = 0x45;
- static const UINT8 kRawBlueRegister = 0x47;
+ static const uint8_t kAddress = 0x02;
+ static const uint8_t kManufacturerBaseRegister = 0x08;
+ static const uint8_t kManufacturerSize = 0x08;
+ static const uint8_t kSensorTypeBaseRegister = 0x10;
+ static const uint8_t kSensorTypeSize = 0x08;
+ static const uint8_t kModeRegister = 0x41;
+ static const uint8_t kColorRegister = 0x42;
+ static const uint8_t kRedRegister = 0x43;
+ static const uint8_t kGreenRegister = 0x44;
+ static const uint8_t kBlueRegister = 0x45;
+ static const uint8_t kRawRedRegister = 0x43;
+ static const uint8_t kRawGreenRegister = 0x45;
+ static const uint8_t kRawBlueRegister = 0x47;
int m_mode;
I2C* m_i2c;
diff --git a/aos/externals/WPILib/WPILib/HiTechnicCompass.cpp b/aos/externals/WPILib/WPILib/HiTechnicCompass.cpp
index e72637d..2a98aa9 100644
--- a/aos/externals/WPILib/WPILib/HiTechnicCompass.cpp
+++ b/aos/externals/WPILib/WPILib/HiTechnicCompass.cpp
@@ -11,29 +11,30 @@
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
-const UINT8 HiTechnicCompass::kAddress;
-const UINT8 HiTechnicCompass::kManufacturerBaseRegister;
-const UINT8 HiTechnicCompass::kManufacturerSize;
-const UINT8 HiTechnicCompass::kSensorTypeBaseRegister;
-const UINT8 HiTechnicCompass::kSensorTypeSize;
-const UINT8 HiTechnicCompass::kHeadingRegister;
+const uint8_t HiTechnicCompass::kAddress;
+const uint8_t HiTechnicCompass::kManufacturerBaseRegister;
+const uint8_t HiTechnicCompass::kManufacturerSize;
+const uint8_t HiTechnicCompass::kSensorTypeBaseRegister;
+const uint8_t HiTechnicCompass::kSensorTypeSize;
+const uint8_t HiTechnicCompass::kHeadingRegister;
/**
* Constructor.
*
* @param moduleNumber The digital module that the sensor is plugged into (1 or 2).
*/
-HiTechnicCompass::HiTechnicCompass(UINT8 moduleNumber)
+HiTechnicCompass::HiTechnicCompass(uint8_t moduleNumber)
: m_i2c (NULL)
{
+ m_table = NULL;
DigitalModule *module = DigitalModule::GetInstance(moduleNumber);
if (module)
{
m_i2c = module->GetI2C(kAddress);
// Verify Sensor
- const UINT8 kExpectedManufacturer[] = "HiTechnc";
- const UINT8 kExpectedSensorType[] = "Compass ";
+ const uint8_t kExpectedManufacturer[] = "HiTechnc";
+ const uint8_t kExpectedSensorType[] = "Compass ";
if ( ! m_i2c->VerifySensor(kManufacturerBaseRegister, kManufacturerSize, kExpectedManufacturer) )
{
wpi_setWPIError(CompassManufacturerError);
@@ -67,10 +68,10 @@
*/
float HiTechnicCompass::GetAngle()
{
- UINT16 heading = 0;
+ uint16_t heading = 0;
if (m_i2c)
{
- m_i2c->Read(kHeadingRegister, sizeof(heading), (UINT8 *)&heading);
+ m_i2c->Read(kHeadingRegister, sizeof(heading), (uint8_t *)&heading);
// Sensor is little endian... swap bytes
heading = (heading >> 8) | (heading << 8);
diff --git a/aos/externals/WPILib/WPILib/HiTechnicCompass.h b/aos/externals/WPILib/WPILib/HiTechnicCompass.h
index 442d5b4..de7de61 100644
--- a/aos/externals/WPILib/WPILib/HiTechnicCompass.h
+++ b/aos/externals/WPILib/WPILib/HiTechnicCompass.h
@@ -27,7 +27,7 @@
class HiTechnicCompass : public SensorBase, public LiveWindowSendable
{
public:
- explicit HiTechnicCompass(UINT8 moduleNumber);
+ explicit HiTechnicCompass(uint8_t moduleNumber);
virtual ~HiTechnicCompass();
float GetAngle();
@@ -39,12 +39,12 @@
ITable * GetTable();
private:
- static const UINT8 kAddress = 0x02;
- static const UINT8 kManufacturerBaseRegister = 0x08;
- static const UINT8 kManufacturerSize = 0x08;
- static const UINT8 kSensorTypeBaseRegister = 0x10;
- static const UINT8 kSensorTypeSize = 0x08;
- static const UINT8 kHeadingRegister = 0x44;
+ static const uint8_t kAddress = 0x02;
+ static const uint8_t kManufacturerBaseRegister = 0x08;
+ static const uint8_t kManufacturerSize = 0x08;
+ static const uint8_t kSensorTypeBaseRegister = 0x10;
+ static const uint8_t kSensorTypeSize = 0x08;
+ static const uint8_t kHeadingRegister = 0x44;
I2C* m_i2c;
diff --git a/aos/externals/WPILib/WPILib/I2C.cpp b/aos/externals/WPILib/WPILib/I2C.cpp
index e0dfe63..a4b1b85 100644
--- a/aos/externals/WPILib/WPILib/I2C.cpp
+++ b/aos/externals/WPILib/WPILib/I2C.cpp
@@ -12,7 +12,7 @@
#include <taskLib.h>
SEM_ID I2C::m_semaphore = NULL;
-UINT32 I2C::m_objCount = 0;
+uint32_t I2C::m_objCount = 0;
/**
* Constructor.
@@ -20,10 +20,10 @@
* @param module The Digital Module to which the device is conneted.
* @param deviceAddress The address of the device on the I2C bus.
*/
-I2C::I2C(DigitalModule *module, UINT8 deviceAddress)
+I2C::I2C(DigitalModule *module, uint8_t deviceAddress)
: m_module (module)
, m_deviceAddress (deviceAddress)
- , m_compatibilityMode (false)
+ , m_compatibilityMode (true)
{
if (m_semaphore == NULL)
{
@@ -58,7 +58,7 @@
* @param receiveSize Number of byted to read from the device. [0..7]
* @return Transfer Aborted... false for success, true for aborted.
*/
-bool I2C::Transaction(UINT8 *dataToSend, UINT8 sendSize, UINT8 *dataReceived, UINT8 receiveSize)
+bool I2C::Transaction(uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize)
{
if (sendSize > 6)
{
@@ -71,16 +71,16 @@
return true;
}
- UINT32 data=0;
- UINT32 dataHigh=0;
- UINT32 i;
+ uint32_t data=0;
+ uint32_t dataHigh=0;
+ uint32_t i;
for(i=0; i<sendSize && i<sizeof(data); i++)
{
- data |= (UINT32)dataToSend[i] << (8*i);
+ data |= (uint32_t)dataToSend[i] << (8*i);
}
for(; i<sendSize; i++)
{
- dataHigh |= (UINT32)dataToSend[i] << (8*(i-sizeof(data)));
+ dataHigh |= (uint32_t)dataToSend[i] << (8*(i-sizeof(data)));
}
bool aborted = true;
@@ -93,7 +93,7 @@
if (sendSize > 0) m_module->m_fpgaDIO->writeI2CDataToSend(data, &localStatus);
if (sendSize > sizeof(data)) m_module->m_fpgaDIO->writeI2CConfig_DataToSendHigh(dataHigh, &localStatus);
m_module->m_fpgaDIO->writeI2CConfig_BitwiseHandshake(m_compatibilityMode, &localStatus);
- UINT8 transaction = m_module->m_fpgaDIO->readI2CStatus_Transaction(&localStatus);
+ uint8_t transaction = m_module->m_fpgaDIO->readI2CStatus_Transaction(&localStatus);
m_module->m_fpgaDIO->strobeI2CStart(&localStatus);
while(transaction == m_module->m_fpgaDIO->readI2CStatus_Transaction(&localStatus)) taskDelay(1);
while(!m_module->m_fpgaDIO->readI2CStatus_Done(&localStatus)) taskDelay(1);
@@ -137,9 +137,9 @@
* @param data The byte to write to the register on the device.
* @return Transfer Aborted... false for success, true for aborted.
*/
-bool I2C::Write(UINT8 registerAddress, UINT8 data)
+bool I2C::Write(uint8_t registerAddress, uint8_t data)
{
- UINT8 buffer[2];
+ uint8_t buffer[2];
buffer[0] = registerAddress;
buffer[1] = data;
return Transaction(buffer, sizeof(buffer), NULL, 0);
@@ -158,7 +158,7 @@
* @param buffer A pointer to the array of bytes to store the data read from the device.
* @return Transfer Aborted... false for success, true for aborted.
*/
-bool I2C::Read(UINT8 registerAddress, UINT8 count, UINT8 *buffer)
+bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t *buffer)
{
if (count < 1 || count > 7)
{
@@ -182,7 +182,7 @@
* @param registerAddress The register to write on all devices on the bus.
* @param data The value to write to the devices.
*/
-void I2C::Broadcast(UINT8 registerAddress, UINT8 data)
+void I2C::Broadcast(uint8_t registerAddress, uint8_t data)
{
}
@@ -191,7 +191,7 @@
*
* Enables bitwise clock skewing detection. This will reduce the I2C interface speed,
* but will allow you to communicate with devices that skew the clock at abnormal times.
- *
+ * Compatability mode is enabled by default.
* @param enable Enable compatibility mode for this sensor or not.
*/
void I2C::SetCompatibilityMode(bool enable)
@@ -216,17 +216,17 @@
* @param count The size of the field to be verified.
* @param expected A buffer containing the values expected from the device.
*/
-bool I2C::VerifySensor(UINT8 registerAddress, UINT8 count, const UINT8 *expected)
+bool I2C::VerifySensor(uint8_t registerAddress, uint8_t count, const uint8_t *expected)
{
// TODO: Make use of all 7 read bytes
- UINT8 deviceData[4];
- for (UINT8 i=0, curRegisterAddress = registerAddress; i < count; i+=4, curRegisterAddress+=4)
+ uint8_t deviceData[4];
+ for (uint8_t i=0, curRegisterAddress = registerAddress; i < count; i+=4, curRegisterAddress+=4)
{
- UINT8 toRead = count - i < 4 ? count - i : 4;
+ uint8_t toRead = count - i < 4 ? count - i : 4;
// Read the chunk of data. Return false if the sensor does not respond.
if (Read(curRegisterAddress, toRead, deviceData)) return false;
- for (UINT8 j=0; j<toRead; j++)
+ for (uint8_t j=0; j<toRead; j++)
{
if(deviceData[j] != expected[i + j]) return false;
}
diff --git a/aos/externals/WPILib/WPILib/I2C.h b/aos/externals/WPILib/WPILib/I2C.h
index d60c6bc..f200737 100644
--- a/aos/externals/WPILib/WPILib/I2C.h
+++ b/aos/externals/WPILib/WPILib/I2C.h
@@ -24,22 +24,22 @@
friend class DigitalModule;
public:
virtual ~I2C();
- bool Transaction(UINT8 *dataToSend, UINT8 sendSize, UINT8 *dataReceived, UINT8 receiveSize);
+ bool Transaction(uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize);
bool AddressOnly();
- bool Write(UINT8 registerAddress, UINT8 data);
- bool Read(UINT8 registerAddress, UINT8 count, UINT8 *data);
- void Broadcast(UINT8 registerAddress, UINT8 data);
+ bool Write(uint8_t registerAddress, uint8_t data);
+ bool Read(uint8_t registerAddress, uint8_t count, uint8_t *data);
+ void Broadcast(uint8_t registerAddress, uint8_t data);
void SetCompatibilityMode(bool enable);
- bool VerifySensor(UINT8 registerAddress, UINT8 count, const UINT8 *expected);
+ bool VerifySensor(uint8_t registerAddress, uint8_t count, const uint8_t *expected);
private:
static SEM_ID m_semaphore;
- static UINT32 m_objCount;
+ static uint32_t m_objCount;
- I2C(DigitalModule *module, UINT8 deviceAddress);
+ I2C(DigitalModule *module, uint8_t deviceAddress);
DigitalModule *m_module;
- UINT8 m_deviceAddress;
+ uint8_t m_deviceAddress;
bool m_compatibilityMode;
};
diff --git a/aos/externals/WPILib/WPILib/Interfaces/Potentiometer.h b/aos/externals/WPILib/WPILib/Interfaces/Potentiometer.h
new file mode 100644
index 0000000..bda5049
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Interfaces/Potentiometer.h
@@ -0,0 +1,11 @@
+#ifndef _POTENTIOMETER_H
+#define _POTENTIOMETER_H
+
+#include "PIDSource.h"
+
+class Potentiometer : public PIDSource {
+public:
+ virtual double Get() = 0;
+};
+
+#endif
diff --git a/aos/externals/WPILib/WPILib/InterruptableSensorBase.cpp b/aos/externals/WPILib/WPILib/InterruptableSensorBase.cpp
index 4a72b07..ad9aa4b 100644
--- a/aos/externals/WPILib/WPILib/InterruptableSensorBase.cpp
+++ b/aos/externals/WPILib/WPILib/InterruptableSensorBase.cpp
@@ -53,7 +53,7 @@
wpi_assert(m_manager != NULL);
wpi_assert(m_interrupt != NULL);
tRioStatusCode localStatus = NiFpga_Status_Success;
- m_manager->watch((INT32)(timeout * 1e3), &localStatus);
+ m_manager->watch((int32_t)(timeout * 1e3), &localStatus);
wpi_setError(localStatus);
}
@@ -92,7 +92,7 @@
{
wpi_assert(m_interrupt != NULL);
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 timestamp = m_interrupt->readTimeStamp(&localStatus);
+ uint32_t timestamp = m_interrupt->readTimeStamp(&localStatus);
wpi_setError(localStatus);
return timestamp * 1e-6;
}
diff --git a/aos/externals/WPILib/WPILib/InterruptableSensorBase.h b/aos/externals/WPILib/WPILib/InterruptableSensorBase.h
index 2743399..96a5309 100644
--- a/aos/externals/WPILib/WPILib/InterruptableSensorBase.h
+++ b/aos/externals/WPILib/WPILib/InterruptableSensorBase.h
@@ -25,7 +25,7 @@
protected:
tInterrupt *m_interrupt;
tInterruptManager *m_manager;
- UINT32 m_interruptIndex;
+ uint32_t m_interruptIndex;
void AllocateInterrupts(bool watcher);
};
diff --git a/aos/externals/WPILib/WPILib/IterativeRobot.cpp b/aos/externals/WPILib/WPILib/IterativeRobot.cpp
index 579ea2b..c3220cf 100644
--- a/aos/externals/WPILib/WPILib/IterativeRobot.cpp
+++ b/aos/externals/WPILib/WPILib/IterativeRobot.cpp
@@ -13,7 +13,7 @@
#include "LiveWindow/LiveWindow.h"
#include "networktables/NetworkTable.h"
-const double IterativeRobot::kDefaultPeriod;
+constexpr double IterativeRobot::kDefaultPeriod;
/**
* Constructor for RobotIterativeBase
diff --git a/aos/externals/WPILib/WPILib/IterativeRobot.h b/aos/externals/WPILib/WPILib/IterativeRobot.h
index db877cb..e3e86d4 100644
--- a/aos/externals/WPILib/WPILib/IterativeRobot.h
+++ b/aos/externals/WPILib/WPILib/IterativeRobot.h
@@ -45,7 +45,7 @@
* Setting the period to 0.0 will cause the periodic functions to follow
* the Driver Station packet rate of about 50Hz.
*/
- static const double kDefaultPeriod = 0.0;
+ static constexpr double kDefaultPeriod = 0.0;
virtual void StartCompetition();
diff --git a/aos/externals/WPILib/WPILib/Jaguar.cpp b/aos/externals/WPILib/WPILib/Jaguar.cpp
index b31065d..b5f1187 100644
--- a/aos/externals/WPILib/WPILib/Jaguar.cpp
+++ b/aos/externals/WPILib/WPILib/Jaguar.cpp
@@ -23,9 +23,8 @@
* Neutral ranges from 1.4482078ms to 1.5517922ms
* Proportional forward ranges from 1.5517922ms to 2.3027789ms
* Full forward ranges from 2.3027789ms to 2.328675ms
- * TODO: compute the appropriate values based on digital loop timing
*/
- SetBounds(251, 135, 128, 120, 4);
+ SetBounds(2.31, 1.55, 1.507, 1.454, .697);
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetRaw(m_centerPwm);
@@ -38,7 +37,7 @@
*
* @param channel The PWM channel on the digital module that the Jaguar is attached to.
*/
-Jaguar::Jaguar(UINT32 channel) : SafePWM(channel)
+Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
{
InitJaguar();
}
@@ -49,7 +48,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The PWM channel on the digital module that the Jaguar is attached to.
*/
-Jaguar::Jaguar(UINT8 moduleNumber, UINT32 channel) : SafePWM(moduleNumber, channel)
+Jaguar::Jaguar(uint8_t moduleNumber, uint32_t channel) : SafePWM(moduleNumber, channel)
{
InitJaguar();
}
@@ -67,7 +66,7 @@
* @param speed The speed value between -1.0 and 1.0 to set.
* @param syncGroup Unused interface.
*/
-void Jaguar::Set(float speed, UINT8 syncGroup)
+void Jaguar::Set(float speed, uint8_t syncGroup)
{
SetSpeed(speed);
}
diff --git a/aos/externals/WPILib/WPILib/Jaguar.h b/aos/externals/WPILib/WPILib/Jaguar.h
index b1e96ff..2b0a405 100644
--- a/aos/externals/WPILib/WPILib/Jaguar.h
+++ b/aos/externals/WPILib/WPILib/Jaguar.h
@@ -17,10 +17,10 @@
class Jaguar : public SafePWM, public SpeedController
{
public:
- explicit Jaguar(UINT32 channel);
- Jaguar(UINT8 moduleNumber, UINT32 channel);
+ explicit Jaguar(uint32_t channel);
+ Jaguar(uint8_t moduleNumber, uint32_t channel);
virtual ~Jaguar();
- virtual void Set(float value, UINT8 syncGroup=0);
+ virtual void Set(float value, uint8_t syncGroup=0);
virtual float Get();
virtual void Disable();
diff --git a/aos/externals/WPILib/WPILib/Joystick.cpp b/aos/externals/WPILib/WPILib/Joystick.cpp
index c2c2d51..645a1e5 100644
--- a/aos/externals/WPILib/WPILib/Joystick.cpp
+++ b/aos/externals/WPILib/WPILib/Joystick.cpp
@@ -10,13 +10,13 @@
#include "WPIErrors.h"
#include <math.h>
-const UINT32 Joystick::kDefaultXAxis;
-const UINT32 Joystick::kDefaultYAxis;
-const UINT32 Joystick::kDefaultZAxis;
-const UINT32 Joystick::kDefaultTwistAxis;
-const UINT32 Joystick::kDefaultThrottleAxis;
-const UINT32 Joystick::kDefaultTriggerButton;
-const UINT32 Joystick::kDefaultTopButton;
+const uint32_t Joystick::kDefaultXAxis;
+const uint32_t Joystick::kDefaultYAxis;
+const uint32_t Joystick::kDefaultZAxis;
+const uint32_t Joystick::kDefaultTwistAxis;
+const uint32_t Joystick::kDefaultThrottleAxis;
+const uint32_t Joystick::kDefaultTriggerButton;
+const uint32_t Joystick::kDefaultTopButton;
static Joystick *joysticks[DriverStation::kJoystickPorts];
static bool joySticksInitialized = false;
@@ -26,7 +26,7 @@
*
* @param port The port on the driver station that the joystick is plugged into.
*/
-Joystick::Joystick(UINT32 port)
+Joystick::Joystick(uint32_t port)
: m_ds (NULL)
, m_port (port)
, m_axes (NULL)
@@ -56,7 +56,7 @@
* @param numAxisTypes The number of axis types in the enum.
* @param numButtonTypes The number of button types in the enum.
*/
-Joystick::Joystick(UINT32 port, UINT32 numAxisTypes, UINT32 numButtonTypes)
+Joystick::Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes)
: m_ds (NULL)
, m_port (port)
, m_axes (NULL)
@@ -65,7 +65,7 @@
InitJoystick(numAxisTypes, numButtonTypes);
}
-void Joystick::InitJoystick(UINT32 numAxisTypes, UINT32 numButtonTypes)
+void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes)
{
if ( !joySticksInitialized )
{
@@ -76,11 +76,11 @@
joysticks[m_port - 1] = this;
m_ds = DriverStation::GetInstance();
- m_axes = new UINT32[numAxisTypes];
- m_buttons = new UINT32[numButtonTypes];
+ m_axes = new uint32_t[numAxisTypes];
+ m_buttons = new uint32_t[numButtonTypes];
}
-Joystick * Joystick::GetStickForPort(UINT32 port)
+Joystick * Joystick::GetStickForPort(uint32_t port)
{
Joystick *stick = joysticks[port - 1];
if (stick == NULL)
@@ -148,7 +148,7 @@
* @param axis The axis to read [1-6].
* @return The value of the axis.
*/
-float Joystick::GetRawAxis(UINT32 axis)
+float Joystick::GetRawAxis(uint32_t axis)
{
return m_ds->GetStickAxis(m_port, axis);
}
@@ -222,7 +222,7 @@
* @param button The button number to be read.
* @return The state of the button.
**/
-bool Joystick::GetRawButton(UINT32 button)
+bool Joystick::GetRawButton(uint32_t button)
{
return ((0x1 << (button-1)) & m_ds->GetStickButtons(m_port)) != 0;
}
@@ -252,7 +252,7 @@
* @param axis The axis to look up the channel for.
* @return The channel fr the axis.
*/
-UINT32 Joystick::GetAxisChannel(AxisType axis)
+uint32_t Joystick::GetAxisChannel(AxisType axis)
{
return m_axes[axis];
}
@@ -263,7 +263,7 @@
* @param axis The axis to set the channel for.
* @param channel The channel to set the axis to.
*/
-void Joystick::SetAxisChannel(AxisType axis, UINT32 channel)
+void Joystick::SetAxisChannel(AxisType axis, uint32_t channel)
{
m_axes[axis] = channel;
}
diff --git a/aos/externals/WPILib/WPILib/Joystick.h b/aos/externals/WPILib/WPILib/Joystick.h
index f600d24..e21e070 100644
--- a/aos/externals/WPILib/WPILib/Joystick.h
+++ b/aos/externals/WPILib/WPILib/Joystick.h
@@ -21,28 +21,28 @@
class Joystick : public GenericHID, public ErrorBase
{
public:
- static const UINT32 kDefaultXAxis = 1;
- static const UINT32 kDefaultYAxis = 2;
- static const UINT32 kDefaultZAxis = 3;
- static const UINT32 kDefaultTwistAxis = 4;
- static const UINT32 kDefaultThrottleAxis = 3;
+ static const uint32_t kDefaultXAxis = 1;
+ static const uint32_t kDefaultYAxis = 2;
+ static const uint32_t kDefaultZAxis = 3;
+ static const uint32_t kDefaultTwistAxis = 4;
+ static const uint32_t kDefaultThrottleAxis = 3;
typedef enum
{
kXAxis, kYAxis, kZAxis, kTwistAxis, kThrottleAxis, kNumAxisTypes
} AxisType;
- static const UINT32 kDefaultTriggerButton = 1;
- static const UINT32 kDefaultTopButton = 2;
+ static const uint32_t kDefaultTriggerButton = 1;
+ static const uint32_t kDefaultTopButton = 2;
typedef enum
{
kTriggerButton, kTopButton, kNumButtonTypes
} ButtonType;
- explicit Joystick(UINT32 port);
- Joystick(UINT32 port, UINT32 numAxisTypes, UINT32 numButtonTypes);
+ explicit Joystick(uint32_t port);
+ Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
virtual ~Joystick();
- UINT32 GetAxisChannel(AxisType axis);
- void SetAxisChannel(AxisType axis, UINT32 channel);
+ uint32_t GetAxisChannel(AxisType axis);
+ void SetAxisChannel(AxisType axis, uint32_t channel);
virtual float GetX(JoystickHand hand = kRightHand);
virtual float GetY(JoystickHand hand = kRightHand);
@@ -50,14 +50,14 @@
virtual float GetTwist();
virtual float GetThrottle();
virtual float GetAxis(AxisType axis);
- float GetRawAxis(UINT32 axis);
+ float GetRawAxis(uint32_t axis);
virtual bool GetTrigger(JoystickHand hand = kRightHand);
virtual bool GetTop(JoystickHand hand = kRightHand);
virtual bool GetBumper(JoystickHand hand = kRightHand);
virtual bool GetButton(ButtonType button);
- bool GetRawButton(UINT32 button);
- static Joystick* GetStickForPort(UINT32 port);
+ bool GetRawButton(uint32_t button);
+ static Joystick* GetStickForPort(uint32_t port);
virtual float GetMagnitude();
virtual float GetDirectionRadians();
@@ -65,12 +65,12 @@
private:
DISALLOW_COPY_AND_ASSIGN(Joystick);
- void InitJoystick(UINT32 numAxisTypes, UINT32 numButtonTypes);
+ void InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes);
DriverStation *m_ds;
- UINT32 m_port;
- UINT32 *m_axes;
- UINT32 *m_buttons;
+ uint32_t m_port;
+ uint32_t *m_axes;
+ uint32_t *m_buttons;
};
#endif
diff --git a/aos/externals/WPILib/WPILib/Kinect.cpp b/aos/externals/WPILib/WPILib/Kinect.cpp
index 838d782..91a0027 100644
--- a/aos/externals/WPILib/WPILib/Kinect.cpp
+++ b/aos/externals/WPILib/WPILib/Kinect.cpp
@@ -12,6 +12,7 @@
#include "Skeleton.h"
#include "Synchronized.h"
#include "WPIErrors.h"
+#include <cstring>
#define kHeaderBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Header
#define kSkeletonExtraBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Extra1
@@ -116,7 +117,7 @@
* @param skeletonIndex the skeleton to read from
* @return the quality value as defined in the Kinect SDK
*/
-UINT32 Kinect::GetQuality(int skeletonIndex)
+uint32_t Kinect::GetQuality(int skeletonIndex)
{
if (skeletonIndex <= 0 || skeletonIndex > kNumSkeletons)
{
@@ -151,7 +152,7 @@
void Kinect::UpdateData()
{
Synchronized sync(m_dataLock);
- UINT32 packetNumber = DriverStation::GetInstance()->GetPacketNumber();
+ uint32_t packetNumber = DriverStation::GetInstance()->GetPacketNumber();
if (m_recentPacketNumber != packetNumber)
{
m_recentPacketNumber = packetNumber;
diff --git a/aos/externals/WPILib/WPILib/Kinect.h b/aos/externals/WPILib/WPILib/Kinect.h
index cf8a4e0..988fccd 100644
--- a/aos/externals/WPILib/WPILib/Kinect.h
+++ b/aos/externals/WPILib/WPILib/Kinect.h
@@ -39,7 +39,7 @@
Point4 GetGravityNormal();
Skeleton GetSkeleton(int skeletonIndex = 1);
Point4 GetPosition(int skeletonIndex = 1);
- UINT32 GetQuality(int skeletonIndex = 1);
+ uint32_t GetQuality(int skeletonIndex = 1);
SkeletonTrackingState GetTrackingState(int skeletonIndex = 1);
static Kinect *GetInstance();
@@ -51,13 +51,13 @@
DISALLOW_COPY_AND_ASSIGN(Kinect);
- UINT32 m_recentPacketNumber;
+ uint32_t m_recentPacketNumber;
SEM_ID m_dataLock;
int m_numberOfPlayers;
Point4 m_floorClipPlane;
Point4 m_gravityNormal;
Point4 m_position[kNumSkeletons];
- UINT32 m_quality[kNumSkeletons];
+ uint32_t m_quality[kNumSkeletons];
SkeletonTrackingState m_trackingState[kNumSkeletons];
Skeleton m_skeletons[kNumSkeletons];
diff --git a/aos/externals/WPILib/WPILib/KinectStick.cpp b/aos/externals/WPILib/WPILib/KinectStick.cpp
index 86fb6a4..f6e3021 100644
--- a/aos/externals/WPILib/WPILib/KinectStick.cpp
+++ b/aos/externals/WPILib/WPILib/KinectStick.cpp
@@ -13,7 +13,7 @@
#include "Utility.h"
#include "WPIErrors.h"
-UINT32 KinectStick::_recentPacketNumber = 0;
+uint32_t KinectStick::_recentPacketNumber = 0;
KinectStick::KinectStickData KinectStick::_sticks;
#define kJoystickBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Joystick
@@ -100,7 +100,7 @@
* @param axis The axis to read [1-6].
* @return The value of the axis
*/
-float KinectStick::GetRawAxis(UINT32 axis)
+float KinectStick::GetRawAxis(uint32_t axis)
{
if (StatusIsFatal()) return 0.0;
@@ -152,7 +152,7 @@
* @param button The button number to be read.
* @return The state of the button.
*/
-bool KinectStick::GetRawButton(UINT32 button)
+bool KinectStick::GetRawButton(uint32_t button)
{
if (StatusIsFatal()) return false;
@@ -165,7 +165,7 @@
*/
void KinectStick::GetData()
{
- UINT32 packetNumber = DriverStation::GetInstance()->GetPacketNumber();
+ uint32_t packetNumber = DriverStation::GetInstance()->GetPacketNumber();
if (_recentPacketNumber != packetNumber)
{
_recentPacketNumber = packetNumber;
@@ -181,7 +181,7 @@
* Convert an 8 bit joystick value to a floating point (-1,1) value
* @param value The 8 bit raw joystick value returned from the driver station
*/
-float KinectStick::ConvertRawToFloat(INT8 value)
+float KinectStick::ConvertRawToFloat(int8_t value)
{
float result;
diff --git a/aos/externals/WPILib/WPILib/KinectStick.h b/aos/externals/WPILib/WPILib/KinectStick.h
index ffa27ce..e605b5a 100644
--- a/aos/externals/WPILib/WPILib/KinectStick.h
+++ b/aos/externals/WPILib/WPILib/KinectStick.h
@@ -26,23 +26,23 @@
virtual float GetZ();
virtual float GetTwist();
virtual float GetThrottle();
- virtual float GetRawAxis(UINT32 axis);
+ virtual float GetRawAxis(uint32_t axis);
virtual bool GetTrigger(JoystickHand hand = kRightHand);
virtual bool GetTop(JoystickHand hand = kRightHand);
virtual bool GetBumper(JoystickHand hand = kRightHand);
- virtual bool GetRawButton(UINT32 button);
+ virtual bool GetRawButton(uint32_t button);
private:
void GetData();
- float ConvertRawToFloat(INT8 charValue);
+ float ConvertRawToFloat(int8_t charValue);
typedef union
{
struct
{
- UINT8 size;
- UINT8 id;
+ uint8_t size;
+ uint8_t id;
struct
{
unsigned char axis[6];
@@ -53,7 +53,7 @@
} KinectStickData;
int m_id;
- static UINT32 _recentPacketNumber;
+ static uint32_t _recentPacketNumber;
static KinectStickData _sticks;
};
diff --git a/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.cpp b/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.cpp
index 956b651..a2ecbc6 100644
--- a/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.cpp
+++ b/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.cpp
@@ -85,7 +85,7 @@
* @param name The name of this component.
* @param component A LiveWindowSendable component that represents a sensor.
*/
-void LiveWindow::AddSensor(char *subsystem, char *name,
+void LiveWindow::AddSensor(const char *subsystem, const char *name,
LiveWindowSendable *component)
{
#if 0
@@ -101,7 +101,7 @@
* @param name The name of this component.
* @param component A LiveWindowSendable component that represents a actuator.
*/
-void LiveWindow::AddActuator(char *subsystem, char *name,
+void LiveWindow::AddActuator(const char *subsystem, const char *name,
LiveWindowSendable *component)
{
#if 0
diff --git a/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.h b/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.h
index b3e620e..2b103f7 100644
--- a/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.h
+++ b/aos/externals/WPILib/WPILib/LiveWindow/LiveWindow.h
@@ -42,8 +42,8 @@
public:
static LiveWindow * GetInstance();
void Run();
- void AddSensor(char *subsystem, char *name, LiveWindowSendable *component);
- void AddActuator(char *subsystem, char *name, LiveWindowSendable *component);
+ void AddSensor(const char *subsystem, const char *name, LiveWindowSendable *component);
+ void AddActuator(const char *subsystem, const char *name, LiveWindowSendable *component);
void AddSensor(std::string type, int module, int channel, LiveWindowSendable *component);
void AddActuator(std::string type, int module, int channel, LiveWindowSendable *component);
diff --git a/aos/externals/WPILib/WPILib/LiveWindow/LiveWindowStatusListener.cpp b/aos/externals/WPILib/WPILib/LiveWindow/LiveWindowStatusListener.cpp
index deb8cc0..5a80f90 100644
--- a/aos/externals/WPILib/WPILib/LiveWindow/LiveWindowStatusListener.cpp
+++ b/aos/externals/WPILib/WPILib/LiveWindow/LiveWindowStatusListener.cpp
@@ -1,7 +1,7 @@
#include "LiveWindow/LiveWindowStatusListener.h"
#include "Commands/Scheduler.h"
-void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
+void LiveWindowStatusListener::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
}
diff --git a/aos/externals/WPILib/WPILib/Makefile b/aos/externals/WPILib/WPILib/Makefile
new file mode 100644
index 0000000..598ecf3
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/Makefile
@@ -0,0 +1,34 @@
+# force powerpc compilers
+CXX=powerpc-wrs-vxworks-g++
+AR=powerpc-wrs-vxworks-ar
+
+CPPFILES := $(shell find -name '*.cpp' | sort | sed 's/\.\///g')
+OBJS = $(CPPFILES:.cpp=.o)
+
+WPILib.a: $(OBJS)
+ @echo " [AR] WPILib.a"
+ @$(AR) crus WPILib.a $(OBJS)
+
+%.o: %.cpp
+ @echo " [G++] "$?
+ @mkdir -p `dirname Debug/$@`
+ @$(CXX) -o $@ -c $? -g -I. -mcpu=603 -mstrict-align -mlongcall -Wall -DTOOL=GNU -D'SVN_REV="3623+1"' -std=c++11
+
+clean-objects:
+ @$(foreach obf, $(shell find -name '*.o' | sort | sed 's/\.\///g'), echo " [RM] "$(obf);rm -rf $(obf);)
+
+clean-wpilib:
+ @echo " [RM] WPILib.a"
+ @rm -rf WPILib.a
+
+clean: clean-objects clean-wpilib
+
+install:
+ mkdir -p $(DESTDIR)$(PREFIX)/lib
+ cp WPILib.a $(DESTDIR)$(PREFIX)/lib/libWPILib.a
+ $(foreach hdir,$(shell find -name '*.h' | sed 's/\.\///g' | xargs -L 1 dirname | sort | uniq),mkdir -p $(DESTDIR)$(PREFIX)/include/WPILib/$(hdir);)
+ $(foreach header, $(shell find -name '*.h' | sed 's/\.\///g'), cp $(header) $(DESTDIR)$(PREFIX)/include/WPILib/$(header);)
+
+rebuild: clean all
+
+all: WPILib.a
diff --git a/aos/externals/WPILib/WPILib/Module.cpp b/aos/externals/WPILib/WPILib/Module.cpp
index 2d01ea5..727fda3 100644
--- a/aos/externals/WPILib/WPILib/Module.cpp
+++ b/aos/externals/WPILib/WPILib/Module.cpp
@@ -20,7 +20,7 @@
* @param type The type of module represented.
* @param number The module index within the module type.
*/
-Module::Module(nLoadOut::tModuleType type, UINT8 number)
+Module::Module(nLoadOut::tModuleType type, uint8_t number)
: m_moduleType (type)
, m_moduleNumber (number)
{
@@ -42,7 +42,7 @@
* @param type The type of module represented.
* @param number The module index within the module type.
*/
-Module* Module::GetModule(nLoadOut::tModuleType type, UINT8 number)
+Module* Module::GetModule(nLoadOut::tModuleType type, uint8_t number)
{
Synchronized sync(m_semaphore);
if (m_modules[ToIndex(type, number)] == NULL)
@@ -74,7 +74,7 @@
* @param number The module index within the module type.
* @return The index into m_modules.
*/
-UINT8 Module::ToIndex(nLoadOut::tModuleType type, UINT8 number)
+uint8_t Module::ToIndex(nLoadOut::tModuleType type, uint8_t number)
{
if (number == 0 || number > kMaxModuleNumber) {
char buf[64];
diff --git a/aos/externals/WPILib/WPILib/Module.h b/aos/externals/WPILib/WPILib/Module.h
index 45b10ff..390d77a 100644
--- a/aos/externals/WPILib/WPILib/Module.h
+++ b/aos/externals/WPILib/WPILib/Module.h
@@ -17,18 +17,18 @@
{
public:
nLoadOut::tModuleType GetType() {return m_moduleType;}
- UINT8 GetNumber() {return m_moduleNumber;}
- static Module *GetModule(nLoadOut::tModuleType type, UINT8 number);
+ uint8_t GetNumber() {return m_moduleNumber;}
+ static Module *GetModule(nLoadOut::tModuleType type, uint8_t number);
protected:
- Module(nLoadOut::tModuleType type, UINT8 number);
+ Module(nLoadOut::tModuleType type, uint8_t number);
virtual ~Module();
nLoadOut::tModuleType m_moduleType; ///< The type of module represented.
- UINT8 m_moduleNumber; ///< The module index within the module type.
+ uint8_t m_moduleNumber; ///< The module index within the module type.
private:
- static UINT8 ToIndex(nLoadOut::tModuleType type, UINT8 number);
+ static uint8_t ToIndex(nLoadOut::tModuleType type, uint8_t number);
static Module* m_modules[kMaxModules];
static ReentrantSemaphore m_semaphore;
};
diff --git a/aos/externals/WPILib/WPILib/MotorSafetyHelper.cpp b/aos/externals/WPILib/WPILib/MotorSafetyHelper.cpp
index 1055de8..23e49d5 100644
--- a/aos/externals/WPILib/WPILib/MotorSafetyHelper.cpp
+++ b/aos/externals/WPILib/WPILib/MotorSafetyHelper.cpp
@@ -104,8 +104,8 @@
*/
void MotorSafetyHelper::Check()
{
- if (!m_enabled) return;
- if (DriverStation::GetInstance()->IsDisabled()) return;
+ DriverStation *ds = DriverStation::GetInstance();
+ if (!m_enabled || ds->IsDisabled() || ds->IsTest()) return;
Synchronized sync(m_syncMutex);
if (m_stopTime < Timer::GetFPGATimestamp())
diff --git a/aos/externals/WPILib/WPILib/NetworkCommunication/AICalibration.h b/aos/externals/WPILib/WPILib/NetworkCommunication/AICalibration.h
index 676e7ea..8b94b65 100644
--- a/aos/externals/WPILib/WPILib/NetworkCommunication/AICalibration.h
+++ b/aos/externals/WPILib/WPILib/NetworkCommunication/AICalibration.h
@@ -9,8 +9,8 @@
{
#endif
- UINT32 FRC_NetworkCommunication_nAICalibration_getLSBWeight(const UINT32 aiSystemIndex, const UINT32 channel, INT32 *status);
- INT32 FRC_NetworkCommunication_nAICalibration_getOffset(const UINT32 aiSystemIndex, const UINT32 channel, INT32 *status);
+ uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status);
+ int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status);
#ifdef __cplusplus
}
diff --git a/aos/externals/WPILib/WPILib/NetworkCommunication/FRCComm.h b/aos/externals/WPILib/WPILib/NetworkCommunication/FRCComm.h
index 16d4b0e..80f91a9 100644
--- a/aos/externals/WPILib/WPILib/NetworkCommunication/FRCComm.h
+++ b/aos/externals/WPILib/WPILib/NetworkCommunication/FRCComm.h
@@ -29,102 +29,102 @@
#define USER_DS_LCD_DATA_SIZE 128
struct FRCCommonControlData{
- UINT16 packetIndex;
+ uint16_t packetIndex;
union {
- UINT8 control;
+ uint8_t control;
#ifdef SIMULATION
struct {
- UINT8 checkVersions :1;
- UINT8 test :1;
- UINT8 resync : 1;
- UINT8 fmsAttached:1;
- UINT8 autonomous : 1;
- UINT8 enabled : 1;
- UINT8 notEStop : 1;
- UINT8 reset : 1;
+ uint8_t checkVersions :1;
+ uint8_t test :1;
+ uint8_t resync : 1;
+ uint8_t fmsAttached:1;
+ uint8_t autonomous : 1;
+ uint8_t enabled : 1;
+ uint8_t notEStop : 1;
+ uint8_t reset : 1;
};
#else
struct {
- UINT8 reset : 1;
- UINT8 notEStop : 1;
- UINT8 enabled : 1;
- UINT8 autonomous : 1;
- UINT8 fmsAttached:1;
- UINT8 resync : 1;
- UINT8 test :1;
- UINT8 checkVersions :1;
+ uint8_t reset : 1;
+ uint8_t notEStop : 1;
+ uint8_t enabled : 1;
+ uint8_t autonomous : 1;
+ uint8_t fmsAttached:1;
+ uint8_t resync : 1;
+ uint8_t test :1;
+ uint8_t checkVersions :1;
};
#endif
};
- UINT8 dsDigitalIn;
- UINT16 teamID;
+ uint8_t dsDigitalIn;
+ uint16_t teamID;
char dsID_Alliance;
char dsID_Position;
union {
- INT8 stick0Axes[6];
+ int8_t stick0Axes[6];
struct {
- INT8 stick0Axis1;
- INT8 stick0Axis2;
- INT8 stick0Axis3;
- INT8 stick0Axis4;
- INT8 stick0Axis5;
- INT8 stick0Axis6;
+ int8_t stick0Axis1;
+ int8_t stick0Axis2;
+ int8_t stick0Axis3;
+ int8_t stick0Axis4;
+ int8_t stick0Axis5;
+ int8_t stick0Axis6;
};
};
- UINT16 stick0Buttons; // Left-most 4 bits are unused
+ uint16_t stick0Buttons; // Left-most 4 bits are unused
union {
- INT8 stick1Axes[6];
+ int8_t stick1Axes[6];
struct {
- INT8 stick1Axis1;
- INT8 stick1Axis2;
- INT8 stick1Axis3;
- INT8 stick1Axis4;
- INT8 stick1Axis5;
- INT8 stick1Axis6;
+ int8_t stick1Axis1;
+ int8_t stick1Axis2;
+ int8_t stick1Axis3;
+ int8_t stick1Axis4;
+ int8_t stick1Axis5;
+ int8_t stick1Axis6;
};
};
- UINT16 stick1Buttons; // Left-most 4 bits are unused
+ uint16_t stick1Buttons; // Left-most 4 bits are unused
union {
- INT8 stick2Axes[6];
+ int8_t stick2Axes[6];
struct {
- INT8 stick2Axis1;
- INT8 stick2Axis2;
- INT8 stick2Axis3;
- INT8 stick2Axis4;
- INT8 stick2Axis5;
- INT8 stick2Axis6;
+ int8_t stick2Axis1;
+ int8_t stick2Axis2;
+ int8_t stick2Axis3;
+ int8_t stick2Axis4;
+ int8_t stick2Axis5;
+ int8_t stick2Axis6;
};
};
- UINT16 stick2Buttons; // Left-most 4 bits are unused
+ uint16_t stick2Buttons; // Left-most 4 bits are unused
union {
- INT8 stick3Axes[6];
+ int8_t stick3Axes[6];
struct {
- INT8 stick3Axis1;
- INT8 stick3Axis2;
- INT8 stick3Axis3;
- INT8 stick3Axis4;
- INT8 stick3Axis5;
- INT8 stick3Axis6;
+ int8_t stick3Axis1;
+ int8_t stick3Axis2;
+ int8_t stick3Axis3;
+ int8_t stick3Axis4;
+ int8_t stick3Axis5;
+ int8_t stick3Axis6;
};
};
- UINT16 stick3Buttons; // Left-most 4 bits are unused
+ uint16_t stick3Buttons; // Left-most 4 bits are unused
//Analog inputs are 10 bit right-justified
- UINT16 analog1;
- UINT16 analog2;
- UINT16 analog3;
- UINT16 analog4;
+ uint16_t analog1;
+ uint16_t analog2;
+ uint16_t analog3;
+ uint16_t analog4;
- UINT64 cRIOChecksum;
- UINT32 FPGAChecksum0;
- UINT32 FPGAChecksum1;
- UINT32 FPGAChecksum2;
- UINT32 FPGAChecksum3;
+ uint64_t cRIOChecksum;
+ uint32_t FPGAChecksum0;
+ uint32_t FPGAChecksum1;
+ uint32_t FPGAChecksum2;
+ uint32_t FPGAChecksum3;
char versionData[8];
};
@@ -141,16 +141,16 @@
extern "C" {
#ifndef SIMULATION
- void EXPORT_FUNC getFPGAHardwareVersion(UINT16 *fpgaVersion, UINT32 *fpgaRevision);
+ void EXPORT_FUNC getFPGAHardwareVersion(uint16_t *fpgaVersion, uint32_t *fpgaRevision);
#endif
int EXPORT_FUNC getCommonControlData(FRCCommonControlData *data, int wait_ms);
int EXPORT_FUNC getRecentCommonControlData(FRCCommonControlData *commonData, int wait_ms);
- int EXPORT_FUNC getRecentStatusData(UINT8 *batteryInt, UINT8 *batteryDec, UINT8 *dsDigitalOut, int wait_ms);
- int EXPORT_FUNC getDynamicControlData(UINT8 type, char *dynamicData, INT32 maxLength, int wait_ms);
- int EXPORT_FUNC setStatusData(float battery, UINT8 dsDigitalOut, UINT8 updateNumber,
+ int EXPORT_FUNC getRecentStatusData(uint8_t *batteryInt, uint8_t *batteryDec, uint8_t *dsDigitalOut, int wait_ms);
+ int EXPORT_FUNC getDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms);
+ int EXPORT_FUNC setStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber,
const char *userDataHigh, int userDataHighLength,
const char *userDataLow, int userDataLowLength, int wait_ms);
- int EXPORT_FUNC setStatusDataFloatAsInt(int battery, UINT8 dsDigitalOut, UINT8 updateNumber,
+ int EXPORT_FUNC setStatusDataFloatAsInt(int battery, uint8_t dsDigitalOut, uint8_t updateNumber,
const char *userDataHigh, int userDataHighLength,
const char *userDataLow, int userDataLowLength, int wait_ms);
int EXPORT_FUNC setErrorData(const char *errors, int errorsLength, int wait_ms);
@@ -163,10 +163,10 @@
void EXPORT_FUNC signalResyncActionDone(void);
#endif
- // this UINT32 is really a LVRefNum
- void EXPORT_FUNC setNewDataOccurRef(UINT32 refnum);
+ // this uint32_t is really a LVRefNum
+ void EXPORT_FUNC setNewDataOccurRef(uint32_t refnum);
#ifndef SIMULATION
- void EXPORT_FUNC setResyncOccurRef(UINT32 refnum);
+ void EXPORT_FUNC setResyncOccurRef(uint32_t refnum);
#endif
void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version);
diff --git a/aos/externals/WPILib/WPILib/NetworkCommunication/LoadOut.h b/aos/externals/WPILib/WPILib/NetworkCommunication/LoadOut.h
index 7ebe105..f28249e 100644
--- a/aos/externals/WPILib/WPILib/NetworkCommunication/LoadOut.h
+++ b/aos/externals/WPILib/WPILib/NetworkCommunication/LoadOut.h
@@ -11,7 +11,7 @@
kModuleType_Digital = 0x02,
kModuleType_Solenoid = 0x03,
} tModuleType;
- bool getModulePresence(tModuleType moduleType, UINT8 moduleNumber);
+ bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber);
typedef enum {
kTargetClass_Unknown = 0x00,
kTargetClass_FRC1 = 0x10,
@@ -29,8 +29,8 @@
extern "C" {
#endif
- UINT32 FRC_NetworkCommunication_nLoadOut_getModulePresence(UINT32 moduleType, UINT8 moduleNumber);
- UINT32 FRC_NetworkCommunication_nLoadOut_getTargetClass();
+ uint32_t FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber);
+ uint32_t FRC_NetworkCommunication_nLoadOut_getTargetClass();
#ifdef __cplusplus
}
diff --git a/aos/externals/WPILib/WPILib/NetworkCommunication/UsageReporting.h b/aos/externals/WPILib/WPILib/NetworkCommunication/UsageReporting.h
index 5fbd455..6d499b2 100644
--- a/aos/externals/WPILib/WPILib/NetworkCommunication/UsageReporting.h
+++ b/aos/externals/WPILib/WPILib/NetworkCommunication/UsageReporting.h
@@ -119,14 +119,14 @@
* @param context an optional additional context number for some cases (such as module number). Set to 0 to omit.
* @param feature a string to be included describing features in use on a specific resource. Setting the same resource more than once allows you to change the feature string.
*/
- UINT32 EXPORT_FUNC report(tResourceType resource, UINT8 instanceNumber, UINT8 context = 0, const char *feature = NULL);
+ uint32_t EXPORT_FUNC report(tResourceType resource, uint8_t instanceNumber, uint8_t context = 0, const char *feature = NULL);
}
#ifdef __cplusplus
extern "C" {
#endif
- UINT32 EXPORT_FUNC FRC_NetworkCommunication_nUsageReporting_report(UINT8 resource, UINT8 instanceNumber, UINT8 context, const char *feature);
+ uint32_t EXPORT_FUNC FRC_NetworkCommunication_nUsageReporting_report(uint8_t resource, uint8_t instanceNumber, uint8_t context, const char *feature);
#ifdef __cplusplus
}
diff --git a/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.cpp b/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.cpp
index e7e474b..1e92caf 100644
--- a/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.cpp
+++ b/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.cpp
@@ -18,8 +18,8 @@
const double NetworkRobot::kDisableTime = 0.15;
-NetworkRobot::NetworkRobot(UINT16 receive_port, const char *sender_address,
- UINT16 send_port, const char *receiver_address)
+NetworkRobot::NetworkRobot(uint16_t receive_port, const char *sender_address,
+ uint16_t send_port, const char *receiver_address)
: receive_port_(receive_port), sender_address_(sender_address),
send_port_(send_port), receiver_address_(receiver_address),
receive_socket_(-1), send_socket_(-1),
@@ -415,8 +415,8 @@
}
void NetworkRobot::CopyStickValues(int number,
- const INT8 (&axes)[6],
- UINT16 buttons) {
+ const int8_t (&axes)[6],
+ uint16_t buttons) {
for (int i = 0; i < 6; ++i) {
joystick_values_.joysticks[number].axes[i] = axes[i];
}
diff --git a/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.h b/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.h
index 47c0f49..7b1e05b 100644
--- a/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.h
+++ b/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobot.h
@@ -39,8 +39,8 @@
// Does not take ownership of *sender_address or *receiver_address.
// A NULL for either address means to not do anything with that part (sending
// or receiving).
- NetworkRobot(UINT16 receive_port, const char *sender_address,
- UINT16 send_port, const char *receiver_address);
+ NetworkRobot(uint16_t receive_port, const char *sender_address,
+ uint16_t send_port, const char *receiver_address);
virtual ~NetworkRobot();
// Called when a valid packet has been received into motors_.
@@ -95,11 +95,11 @@
// receiver_address_.
void CreateSendSocket();
- const UINT16 receive_port_;
+ const uint16_t receive_port_;
const char *const sender_address_;
struct in_addr expected_sender_address_;
- const UINT16 send_port_;
+ const uint16_t send_port_;
const char *const receiver_address_;
int receive_socket_;
@@ -115,7 +115,7 @@
// Helper function to copy all of the data for a single joystick into
// joystick_values_.
// axes and buttons get copied into joystick_values_.joysticks[number].
- void CopyStickValues(int number, const INT8 (&axes)[6], UINT16 buttons);
+ void CopyStickValues(int number, const int8_t (&axes)[6], uint16_t buttons);
// Using Timer::GetPPCTimestamp() values.
double last_received_timestamp_;
@@ -132,7 +132,7 @@
// A bitmask of all of the digital outputs that we have currently allocated.
// In hardware order.
- UINT16 allocated_digital_outputs_[2];
+ uint16_t allocated_digital_outputs_[2];
DISALLOW_COPY_AND_ASSIGN(NetworkRobot);
};
diff --git a/aos/externals/WPILib/WPILib/Notifier.cpp b/aos/externals/WPILib/WPILib/Notifier.cpp
index edbe487..ebb42c7 100644
--- a/aos/externals/WPILib/WPILib/Notifier.cpp
+++ b/aos/externals/WPILib/WPILib/Notifier.cpp
@@ -9,7 +9,7 @@
#include "Utility.h"
#include "WPIErrors.h"
-const UINT32 Notifier::kTimerInterruptNumber;
+const uint32_t Notifier::kTimerInterruptNumber;
Notifier *Notifier::timerQueueHead = NULL;
ReentrantSemaphore Notifier::queueSemaphore;
tAlarm *Notifier::talarm = NULL;
@@ -94,7 +94,7 @@
{
tRioStatusCode localStatus = NiFpga_Status_Success;
// write the first item in the queue into the trigger time
- talarm->writeTriggerTime((UINT32)(timerQueueHead->m_expirationTime * 1e6), &localStatus);
+ talarm->writeTriggerTime((uint32_t)(timerQueueHead->m_expirationTime * 1e6), &localStatus);
// Enable the alarm. The hardware disables itself after each alarm.
talarm->writeEnable(true, &localStatus);
wpi_setStaticError(timerQueueHead, localStatus);
diff --git a/aos/externals/WPILib/WPILib/Notifier.h b/aos/externals/WPILib/WPILib/Notifier.h
index a36b872..e9904a1 100644
--- a/aos/externals/WPILib/WPILib/Notifier.h
+++ b/aos/externals/WPILib/WPILib/Notifier.h
@@ -28,7 +28,7 @@
static tInterruptManager *manager;
static int refcount;
- static const UINT32 kTimerInterruptNumber = 28;
+ static const uint32_t kTimerInterruptNumber = 28;
static void ProcessQueue(uint32_t mask, void *params); // process the timer queue on a timer event
static void UpdateAlarm(); // update the FPGA alarm since the queue has changed
void InsertInQueue(bool reschedule); // insert this Notifier in the timer queue
diff --git a/aos/externals/WPILib/WPILib/OSAL/Synchronized.cpp b/aos/externals/WPILib/WPILib/OSAL/Synchronized.cpp
new file mode 100644
index 0000000..53aa960
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/OSAL/Synchronized.cpp
@@ -0,0 +1,42 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#include "OSAL/Synchronized.h"
+
+/**
+ * Synchronized class deals with critical regions.
+ * Declare a Synchronized object at the beginning of a block. That will take the semaphore.
+ * When the code exits from the block it will call the destructor which will give the semaphore.
+ * This ensures that no matter how the block is exited, the semaphore will always be released.
+ * Use the CRITICAL_REGION(SEM_ID) and END_REGION macros to make the code look cleaner (see header file)
+ * @param semaphore The semaphore controlling this critical region.
+ */
+NTSynchronized::NTSynchronized(SEM_ID semaphore)
+{
+ usingSem = false;
+ m_semaphore = semaphore;
+ semTake(m_semaphore, WAIT_FOREVER);
+}
+
+NTSynchronized::NTSynchronized(NTReentrantSemaphore& sem)
+{
+ usingSem = true;
+ m_sem = &sem;
+ m_sem->take();
+}
+
+/**
+ * Syncronized destructor.
+ * This destructor frees the semaphore ensuring that the resource is freed for the block
+ * containing the Synchronized object.
+ */
+NTSynchronized::~NTSynchronized()
+{
+ if(usingSem)
+ m_sem->give();
+ else
+ semGive(m_semaphore);
+}
diff --git a/aos/externals/WPILib/WPILib/OSAL/Synchronized.h b/aos/externals/WPILib/WPILib/OSAL/Synchronized.h
new file mode 100644
index 0000000..bcf4634
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/OSAL/Synchronized.h
@@ -0,0 +1,98 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef NT_SYNCHRONIZED_H
+#define NT_SYNCHRONIZED_H
+
+#define NT_CRITICAL_REGION(s) { NTSynchronized _sync(s);
+#define NT_END_REGION }
+
+#if (defined __vxworks || defined WIN32)
+
+#ifdef __vxworks
+#include <vxWorks.h>
+#endif
+#include <semLib.h>
+
+class NTReentrantSemaphore
+{
+public:
+ explicit NTReentrantSemaphore(){
+ m_semaphore = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
+ };
+ ~NTReentrantSemaphore(){
+ semDelete(m_semaphore);
+ };
+ void take(){
+ semTake(m_semaphore, WAIT_FOREVER);
+ };
+ void give(){
+ semGive(m_semaphore);
+ };
+private:
+ SEM_ID m_semaphore;
+};
+
+#else
+
+#include <pthread.h>
+
+class NTReentrantSemaphore
+{
+public:
+ explicit NTReentrantSemaphore(){
+ pthread_mutexattr_init(&mta);
+ pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&m_semaphore, &mta);
+ };
+ ~NTReentrantSemaphore(){
+ pthread_mutex_unlock(&m_semaphore);
+ pthread_mutex_destroy(&m_semaphore);
+ };
+ void take(){
+ pthread_mutex_lock(&m_semaphore);
+ };
+ void give(){
+ pthread_mutex_unlock(&m_semaphore);
+ };
+private:
+ pthread_mutexattr_t mta;
+ pthread_mutex_t m_semaphore;
+};
+#endif // __vxworks
+
+/**
+ * Provide easy support for critical regions.
+ * A critical region is an area of code that is always executed under mutual exclusion. Only
+ * one task can be executing this code at any time. The idea is that code that manipulates data
+ * that is shared between two or more tasks has to be prevented from executing at the same time
+ * otherwise a race condition is possible when both tasks try to update the data. Typically
+ * semaphores are used to ensure only single task access to the data.
+ * Synchronized objects are a simple wrapper around semaphores to help ensure that semaphores
+ * are always signaled (semGive) after a wait (semTake).
+ */
+class NTSynchronized
+{
+public:
+ explicit NTSynchronized(NTReentrantSemaphore&);
+ //TODO remove vxworks SEM_ID support
+#if (defined __vxworks || defined WIN32)
+ explicit NTSynchronized(SEM_ID);
+#endif
+ virtual ~NTSynchronized();
+private:
+#if (defined __vxworks || defined WIN32)
+ bool usingSem;
+ NTReentrantSemaphore* m_sem;
+ SEM_ID m_semaphore;
+#else
+ NTReentrantSemaphore& m_semaphore;
+#endif
+};
+
+
+
+#endif
diff --git a/aos/externals/WPILib/WPILib/OSAL/Task.cpp b/aos/externals/WPILib/WPILib/OSAL/Task.cpp
new file mode 100644
index 0000000..59596d1
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/OSAL/Task.cpp
@@ -0,0 +1,216 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#include "OSAL/Task.h"
+
+#include "NetworkCommunication/UsageReporting.h"
+#include "WPIErrors.h"
+#include <errnoLib.h>
+#include <string.h>
+#include <taskLib.h>
+#include <usrLib.h>
+
+const UINT32 NTTask::kDefaultPriority;
+const INT32 NTTask::kInvalidTaskID;
+
+/**
+ * Create but don't launch a task.
+ * @param name The name of the task. "FRC_" will be prepended to the task name.
+ * @param function The address of the function to run as the new task.
+ * @param priority The VxWorks priority for the task.
+ * @param stackSize The size of the stack for the task
+ */
+NTTask::NTTask(const char* name, FUNCPTR function, INT32 priority, UINT32 stackSize)
+{
+ m_taskID = kInvalidTaskID;
+ m_function = function;
+ m_priority = priority;
+ m_stackSize = stackSize;
+ m_taskName = new char[strlen(name) + 5];
+ strcpy(m_taskName, "FRC_");
+ strcpy(m_taskName+4, name);
+
+ static INT32 instances = 0;
+ instances++;
+ //nUsageReporting::report(nUsageReporting::kResourceType_Task, instances, 0, m_taskName);
+}
+
+NTTask::~NTTask()
+{
+ if (m_taskID != kInvalidTaskID) Stop();
+ delete [] m_taskName;
+ m_taskName = NULL;
+}
+
+/**
+ * Starts this task.
+ * If it is already running or unable to start, it fails and returns false.
+ */
+bool NTTask::Start(UINT32 arg0, UINT32 arg1, UINT32 arg2, UINT32 arg3, UINT32 arg4,
+ UINT32 arg5, UINT32 arg6, UINT32 arg7, UINT32 arg8, UINT32 arg9)
+{
+ m_taskID = taskSpawn(m_taskName,
+ m_priority,
+ VX_FP_TASK, // options
+ m_stackSize, // stack size
+ m_function, // function to start
+ arg0, arg1, arg2, arg3, arg4, // parameter 1 - pointer to this class
+ arg5, arg6, arg7, arg8, arg9);// additional unused parameters
+ bool ok = HandleError(m_taskID);
+ if (!ok) m_taskID = kInvalidTaskID;
+ return ok;
+}
+
+/**
+ * Restarts a running task.
+ * If the task isn't started, it starts it.
+ * @return false if the task is running and we are unable to kill the previous instance
+ */
+bool NTTask::Restart()
+{
+ return HandleError(taskRestart(m_taskID));
+}
+
+/**
+ * Kills the running task.
+ * @returns true on success false if the task doesn't exist or we are unable to kill it.
+ */
+bool NTTask::Stop()
+{
+ bool ok = true;
+ if (Verify())
+ {
+ ok = HandleError(taskDelete(m_taskID));
+ }
+ m_taskID = kInvalidTaskID;
+ return ok;
+}
+
+/**
+ * Returns true if the task is ready to execute (i.e. not suspended, delayed, or blocked).
+ * @return true if ready, false if not ready.
+ */
+bool NTTask::IsReady()
+{
+ return taskIsReady(m_taskID);
+}
+
+/**
+ * Returns true if the task was explicitly suspended by calling Suspend()
+ * @return true if suspended, false if not suspended.
+ */
+bool NTTask::IsSuspended()
+{
+ return taskIsSuspended(m_taskID);
+}
+
+/**
+ * Pauses a running task.
+ * Returns true on success, false if unable to pause or the task isn't running.
+ */
+bool NTTask::Suspend()
+{
+ return HandleError(taskSuspend(m_taskID));
+}
+
+/**
+ * Resumes a paused task.
+ * Returns true on success, false if unable to resume or if the task isn't running/paused.
+ */
+bool NTTask::Resume()
+{
+ return HandleError(taskResume(m_taskID));
+}
+
+/**
+ * Verifies a task still exists.
+ * @returns true on success.
+ */
+bool NTTask::Verify()
+{
+ return taskIdVerify(m_taskID) == OK;
+}
+
+/**
+ * Gets the priority of a task.
+ * @returns task priority or 0 if an error occured
+ */
+INT32 NTTask::GetPriority()
+{
+ if (HandleError(taskPriorityGet(m_taskID, &m_priority)))
+ return m_priority;
+ else
+ return 0;
+}
+
+/**
+ * This routine changes a task's priority to a specified priority.
+ * Priorities range from 0, the highest priority, to 255, the lowest priority.
+ * Default task priority is 100.
+ * @param priority The priority the task should run at.
+ * @returns true on success.
+ */
+bool NTTask::SetPriority(INT32 priority)
+{
+ m_priority = priority;
+ return HandleError(taskPrioritySet(m_taskID, m_priority));
+}
+
+/**
+ * Returns the name of the task.
+ * @returns Pointer to the name of the task or NULL if not allocated
+ */
+const char* NTTask::GetName()
+{
+ return m_taskName;
+}
+
+/**
+ * Get the ID of a task
+ * @returns Task ID of this task. Task::kInvalidTaskID (-1) if the task has not been started or has already exited.
+ */
+INT32 NTTask::GetID()
+{
+ if (Verify())
+ return m_taskID;
+ return kInvalidTaskID;
+}
+
+/**
+ * Handles errors generated by task related code.
+ */
+bool NTTask::HandleError(STATUS results)
+{
+ if (results != ERROR) return true;
+ switch(errnoGet())
+ {
+ case S_objLib_OBJ_ID_ERROR:
+ wpi_setWPIErrorWithContext(TaskIDError, m_taskName);
+ break;
+
+ case S_objLib_OBJ_DELETED:
+ wpi_setWPIErrorWithContext(TaskDeletedError, m_taskName);
+ break;
+
+ case S_taskLib_ILLEGAL_OPTIONS:
+ wpi_setWPIErrorWithContext(TaskOptionsError, m_taskName);
+ break;
+
+ case S_memLib_NOT_ENOUGH_MEMORY:
+ wpi_setWPIErrorWithContext(TaskMemoryError, m_taskName);
+ break;
+
+ case S_taskLib_ILLEGAL_PRIORITY:
+ wpi_setWPIErrorWithContext(TaskPriorityError, m_taskName);
+ break;
+
+ default:
+ printErrno(errnoGet());
+ wpi_setWPIErrorWithContext(TaskError, m_taskName);
+ }
+ return false;
+}
+
diff --git a/aos/externals/WPILib/WPILib/OSAL/Task.h b/aos/externals/WPILib/WPILib/OSAL/Task.h
new file mode 100644
index 0000000..67de9d6
--- /dev/null
+++ b/aos/externals/WPILib/WPILib/OSAL/Task.h
@@ -0,0 +1,76 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef __NTTASK_H__
+#define __NTTASK_H__
+
+#if (defined __vxworks || defined WIN32)
+
+#include "ErrorBase.h"
+#ifdef __vxworks
+#include <vxWorks.h>
+#endif
+
+/**
+ * WPI task is a wrapper for the native Task object.
+ * All WPILib tasks are managed by a static task manager for simplified cleanup.
+ **/
+class NTTask : public ErrorBase
+{
+public:
+ static const UINT32 kDefaultPriority = 101;
+ static const INT32 kInvalidTaskID = -1;
+
+ NTTask(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
+ virtual ~NTTask();
+
+ #ifdef WIN32
+ bool Start(void * arg0);
+ #else
+ bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0,
+ UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0, UINT32 arg9 = 0);
+ #endif
+
+ bool Restart();
+ bool Stop();
+
+ bool IsReady();
+ bool IsSuspended();
+
+ bool Suspend();
+ bool Resume();
+
+ bool Verify();
+
+ INT32 GetPriority();
+ bool SetPriority(INT32 priority);
+ const char* GetName();
+ INT32 GetID();
+
+ #ifdef WIN32
+ FUNCPTR m_function;
+ void * m_Arg;
+ #endif
+private:
+ char* m_taskName;
+
+ #ifdef WIN32
+ bool StartInternal();
+ HANDLE m_Handle;
+ DWORD m_ID;
+ #else
+ FUNCPTR m_function;
+ INT32 m_taskID;
+ #endif
+
+ UINT32 m_stackSize;
+ INT32 m_priority;
+ bool HandleError(STATUS results);
+ DISALLOW_COPY_AND_ASSIGN(NTTask);
+};
+
+#endif // __vxworks
+#endif // __TASK_H__
diff --git a/aos/externals/WPILib/WPILib/PIDController.cpp b/aos/externals/WPILib/WPILib/PIDController.cpp
index b9a7ed4..0bdefb2 100644
--- a/aos/externals/WPILib/WPILib/PIDController.cpp
+++ b/aos/externals/WPILib/WPILib/PIDController.cpp
@@ -94,7 +94,7 @@
m_controlLoop->StartPeriodic(m_period);
- static INT32 instances = 0;
+ static int32_t instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_PIDController, instances);
diff --git a/aos/externals/WPILib/WPILib/PIDController.h b/aos/externals/WPILib/WPILib/PIDController.h
index 0549c03..2cf5bf4 100644
--- a/aos/externals/WPILib/WPILib/PIDController.h
+++ b/aos/externals/WPILib/WPILib/PIDController.h
@@ -92,7 +92,6 @@
PIDSource *source, PIDOutput *output,
float period = 0.05);
static void CallCalculate(void *controller);
- void Calculate();
virtual ITable* GetTable();
virtual std::string GetSmartDashboardType();
@@ -102,6 +101,7 @@
virtual void StopLiveWindowMode();
protected:
ITable* m_table;
+ void Calculate();
DISALLOW_COPY_AND_ASSIGN(PIDController);
};
diff --git a/aos/externals/WPILib/WPILib/PIDSource.h b/aos/externals/WPILib/WPILib/PIDSource.h
index 4f2a209..a2ed1c2 100644
--- a/aos/externals/WPILib/WPILib/PIDSource.h
+++ b/aos/externals/WPILib/WPILib/PIDSource.h
@@ -13,8 +13,9 @@
* returns a standard value that will be used in the PID code.
*/
class PIDSource
-{
+{
public:
+ typedef enum {kDistance, kRate, kAngle} PIDSourceParameter;
virtual double PIDGet() = 0;
};
diff --git a/aos/externals/WPILib/WPILib/PPC603gnu/Makefile b/aos/externals/WPILib/WPILib/PPC603gnu/Makefile
index b5a18a3..3b82d89 100644
--- a/aos/externals/WPILib/WPILib/PPC603gnu/Makefile
+++ b/aos/externals/WPILib/WPILib/PPC603gnu/Makefile
@@ -157,6 +157,10 @@
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/CancelButtonScheduler.o : $(PRJ_ROOT_DIR)/Buttons/CancelButtonScheduler.cpp $(FORCE_FILE_BUILD)
+ $(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+
+
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/DigitalIOButton.o : $(PRJ_ROOT_DIR)/Buttons/DigitalIOButton.cpp $(FORCE_FILE_BUILD)
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
@@ -185,6 +189,10 @@
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ToggleButtonScheduler.o : $(PRJ_ROOT_DIR)/Buttons/ToggleButtonScheduler.cpp $(FORCE_FILE_BUILD)
+ $(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+
+
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/Trigger.o : $(PRJ_ROOT_DIR)/Buttons/Trigger.cpp $(FORCE_FILE_BUILD)
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
@@ -305,6 +313,10 @@
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicColorSensor.o : $(PRJ_ROOT_DIR)/HiTechnicColorSensor.cpp $(FORCE_FILE_BUILD)
+ $(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+
+
WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicCompass.o : $(PRJ_ROOT_DIR)/HiTechnicCompass.cpp $(FORCE_FILE_BUILD)
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
@@ -357,6 +369,14 @@
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+WPILib/$(MODE_DIR)/Objects/WPILib/OSAL/Synchronized.o : $(PRJ_ROOT_DIR)/OSAL/Synchronized.cpp $(FORCE_FILE_BUILD)
+ $(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+
+
+WPILib/$(MODE_DIR)/Objects/WPILib/OSAL/Task.o : $(PRJ_ROOT_DIR)/OSAL/Task.cpp $(FORCE_FILE_BUILD)
+ $(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
+
+
WPILib/$(MODE_DIR)/Objects/WPILib/PIDController.o : $(PRJ_ROOT_DIR)/PIDController.cpp $(FORCE_FILE_BUILD)
$(TRACE_FLAG)if [ ! -d "`dirname "$@"`" ]; then mkdir -p "`dirname "$@"`"; fi; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<"
@@ -731,6 +751,7 @@
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/AnalogIOButton.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/Button.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ButtonScheduler.o \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/CancelButtonScheduler.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/DigitalIOButton.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/HeldButtonScheduler.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/InternalButton.o \
@@ -738,6 +759,7 @@
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/NetworkButton.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/PressedButtonScheduler.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ReleasedButtonScheduler.o \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ToggleButtonScheduler.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/Trigger.o \
WPILib/$(MODE_DIR)/Objects/WPILib/CANJaguar.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Command.o \
@@ -768,6 +790,7 @@
WPILib/$(MODE_DIR)/Objects/WPILib/ErrorBase.o \
WPILib/$(MODE_DIR)/Objects/WPILib/GearTooth.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Gyro.o \
+ WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicColorSensor.o \
WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicCompass.o \
WPILib/$(MODE_DIR)/Objects/WPILib/I2C.o \
WPILib/$(MODE_DIR)/Objects/WPILib/InterruptableSensorBase.o \
@@ -781,6 +804,8 @@
WPILib/$(MODE_DIR)/Objects/WPILib/Module.o \
WPILib/$(MODE_DIR)/Objects/WPILib/MotorSafetyHelper.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Notifier.o \
+ WPILib/$(MODE_DIR)/Objects/WPILib/OSAL/Synchronized.o \
+ WPILib/$(MODE_DIR)/Objects/WPILib/OSAL/Task.o \
WPILib/$(MODE_DIR)/Objects/WPILib/PIDController.o \
WPILib/$(MODE_DIR)/Objects/WPILib/PWM.o \
WPILib/$(MODE_DIR)/Objects/WPILib/Preferences.o \
@@ -987,57 +1012,59 @@
DEP_FILES := WPILib/$(MODE_DIR)/Objects/WPILib/ADXL345_I2C.d WPILib/$(MODE_DIR)/Objects/WPILib/ADXL345_SPI.d WPILib/$(MODE_DIR)/Objects/WPILib/Accelerometer.d \
WPILib/$(MODE_DIR)/Objects/WPILib/AnalogChannel.d WPILib/$(MODE_DIR)/Objects/WPILib/AnalogModule.d WPILib/$(MODE_DIR)/Objects/WPILib/AnalogTrigger.d \
WPILib/$(MODE_DIR)/Objects/WPILib/AnalogTriggerOutput.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/AnalogIOButton.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/Button.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/DigitalIOButton.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/HeldButtonScheduler.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/InternalButton.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/JoystickButton.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/NetworkButton.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/PressedButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ReleasedButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/Trigger.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/CANJaguar.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Command.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/CommandGroup.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Commands/CommandGroupEntry.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/PIDCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/PIDSubsystem.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Commands/PrintCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Scheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/StartCommand.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Subsystem.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/WaitCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/WaitForChildren.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Commands/WaitUntilCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Compressor.d WPILib/$(MODE_DIR)/Objects/WPILib/Counter.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Dashboard.d WPILib/$(MODE_DIR)/Objects/WPILib/DigitalInput.d WPILib/$(MODE_DIR)/Objects/WPILib/DigitalModule.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/DigitalOutput.d WPILib/$(MODE_DIR)/Objects/WPILib/DigitalSource.d WPILib/$(MODE_DIR)/Objects/WPILib/DoubleSolenoid.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/DriverStation.d WPILib/$(MODE_DIR)/Objects/WPILib/DriverStationEnhancedIO.d WPILib/$(MODE_DIR)/Objects/WPILib/DriverStationLCD.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Encoder.d WPILib/$(MODE_DIR)/Objects/WPILib/Error.d WPILib/$(MODE_DIR)/Objects/WPILib/ErrorBase.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/GearTooth.d WPILib/$(MODE_DIR)/Objects/WPILib/Gyro.d WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicCompass.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/CancelButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/DigitalIOButton.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/HeldButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/InternalButton.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/JoystickButton.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/NetworkButton.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/PressedButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ReleasedButtonScheduler.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/ToggleButtonScheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Buttons/Trigger.d WPILib/$(MODE_DIR)/Objects/WPILib/CANJaguar.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Command.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/CommandGroup.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/CommandGroupEntry.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Commands/PIDCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/PIDSubsystem.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/PrintCommand.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Scheduler.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/StartCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/Subsystem.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Commands/WaitCommand.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/WaitForChildren.d WPILib/$(MODE_DIR)/Objects/WPILib/Commands/WaitUntilCommand.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Compressor.d WPILib/$(MODE_DIR)/Objects/WPILib/Counter.d WPILib/$(MODE_DIR)/Objects/WPILib/Dashboard.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/DigitalInput.d WPILib/$(MODE_DIR)/Objects/WPILib/DigitalModule.d WPILib/$(MODE_DIR)/Objects/WPILib/DigitalOutput.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/DigitalSource.d WPILib/$(MODE_DIR)/Objects/WPILib/DoubleSolenoid.d WPILib/$(MODE_DIR)/Objects/WPILib/DriverStation.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/DriverStationEnhancedIO.d WPILib/$(MODE_DIR)/Objects/WPILib/DriverStationLCD.d WPILib/$(MODE_DIR)/Objects/WPILib/Encoder.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Error.d WPILib/$(MODE_DIR)/Objects/WPILib/ErrorBase.d WPILib/$(MODE_DIR)/Objects/WPILib/GearTooth.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Gyro.d WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicColorSensor.d WPILib/$(MODE_DIR)/Objects/WPILib/HiTechnicCompass.d \
WPILib/$(MODE_DIR)/Objects/WPILib/I2C.d WPILib/$(MODE_DIR)/Objects/WPILib/InterruptableSensorBase.d WPILib/$(MODE_DIR)/Objects/WPILib/IterativeRobot.d \
WPILib/$(MODE_DIR)/Objects/WPILib/Jaguar.d WPILib/$(MODE_DIR)/Objects/WPILib/Joystick.d WPILib/$(MODE_DIR)/Objects/WPILib/Kinect.d \
WPILib/$(MODE_DIR)/Objects/WPILib/KinectStick.d WPILib/$(MODE_DIR)/Objects/WPILib/LiveWindow/LiveWindow.d WPILib/$(MODE_DIR)/Objects/WPILib/LiveWindow/LiveWindowStatusListener.d \
WPILib/$(MODE_DIR)/Objects/WPILib/Module.d WPILib/$(MODE_DIR)/Objects/WPILib/MotorSafetyHelper.d WPILib/$(MODE_DIR)/Objects/WPILib/Notifier.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/PIDController.d WPILib/$(MODE_DIR)/Objects/WPILib/PWM.d WPILib/$(MODE_DIR)/Objects/WPILib/Preferences.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Relay.d WPILib/$(MODE_DIR)/Objects/WPILib/Resource.d WPILib/$(MODE_DIR)/Objects/WPILib/RobotBase.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/RobotDrive.d WPILib/$(MODE_DIR)/Objects/WPILib/SPI.d WPILib/$(MODE_DIR)/Objects/WPILib/SafePWM.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/SensorBase.d WPILib/$(MODE_DIR)/Objects/WPILib/SerialPort.d WPILib/$(MODE_DIR)/Objects/WPILib/Servo.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/SimpleRobot.d WPILib/$(MODE_DIR)/Objects/WPILib/SmartDashboard/SendableChooser.d WPILib/$(MODE_DIR)/Objects/WPILib/SmartDashboard/SmartDashboard.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Solenoid.d WPILib/$(MODE_DIR)/Objects/WPILib/SolenoidBase.d WPILib/$(MODE_DIR)/Objects/WPILib/Synchronized.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Talon.d WPILib/$(MODE_DIR)/Objects/WPILib/Task.d WPILib/$(MODE_DIR)/Objects/WPILib/Timer.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Ultrasonic.d WPILib/$(MODE_DIR)/Objects/WPILib/Utility.d WPILib/$(MODE_DIR)/Objects/WPILib/Victor.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Vision/AxisCamera.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/AxisCameraParams.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/BinaryImage.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Vision/ColorImage.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/EnumCameraParameter.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/HSLImage.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Vision/ImageBase.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/IntCameraParameter.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/MonoImage.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Vision/PCVideoServer.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/RGBImage.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/Threshold.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/AxisCamera.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/BaeUtilities.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/FrcError.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/TrackAPI.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/VisionAPI.d WPILib/$(MODE_DIR)/Objects/WPILib/Watchdog.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTable.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableConnectionListenerAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableKeyListenerAdapter.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableListenerAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableMode.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableProvider.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableSubListenerAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/AbstractNetworkTableEntryStore.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/NetworkTableEntry.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/NetworkTableNode.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/OutgoingEntryReciever.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/TableKeyExistsWithDifferentTypeException.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/TransactionDirtier.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/WriteManager.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/ClientConnectionAdapter.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/ClientConnectionState.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/ClientNetworkTableEntryStore.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/NetworkTableClient.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/BadMessageException.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/ConnectionMonitorThread.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/DataIOStream.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/NetworkTableConnection.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/NetworkTableServer.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerConnectionAdapter.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerConnectionList.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerConnectionState.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerIncomingStreamMonitor.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerNetworkTableEntryStore.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/FDIOStream.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/SocketServerStreamProvider.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/SocketStreamFactory.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/SocketStreams.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/thread/DefaultThreadManger.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ArrayData.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ArrayEntryType.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/BooleanArray.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ComplexData.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ComplexEntryType.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/DefaultEntryTypes.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/NetworkTableEntryType.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/NetworkTableEntryTypeManager.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/NumberArray.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/StringArray.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/EOFException.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/IOException.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/IllegalStateException.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/StringCache.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/System.d \
- WPILib/$(MODE_DIR)/Objects/WPILib/tables/TableKeyNotDefinedException.d JavaCameraLib/$(MODE_DIR)/Objects/PCVideoServer.d JavaCameraLib/$(MODE_DIR)/Objects/AxisCamera.d \
- JavaCameraLib/$(MODE_DIR)/Objects/AxisCameraParams.d JavaCameraLib/$(MODE_DIR)/Objects/EnumCameraParameter.d JavaCameraLib/$(MODE_DIR)/Objects/IntCameraParameter.d \
- JavaCameraLib/$(MODE_DIR)/Objects/Error.d JavaCameraLib/$(MODE_DIR)/Objects/ErrorBase.d JavaCameraLib/$(MODE_DIR)/Objects/Task.d \
- JavaCameraLib/$(MODE_DIR)/Objects/Timer.d JavaCameraLib/$(MODE_DIR)/Objects/Synchronized.d JavaCameraLib/$(MODE_DIR)/Objects/Utility.d
+ WPILib/$(MODE_DIR)/Objects/WPILib/OSAL/Synchronized.d WPILib/$(MODE_DIR)/Objects/WPILib/OSAL/Task.d WPILib/$(MODE_DIR)/Objects/WPILib/PIDController.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/PWM.d WPILib/$(MODE_DIR)/Objects/WPILib/Preferences.d WPILib/$(MODE_DIR)/Objects/WPILib/Relay.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Resource.d WPILib/$(MODE_DIR)/Objects/WPILib/RobotBase.d WPILib/$(MODE_DIR)/Objects/WPILib/RobotDrive.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/SPI.d WPILib/$(MODE_DIR)/Objects/WPILib/SafePWM.d WPILib/$(MODE_DIR)/Objects/WPILib/SensorBase.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/SerialPort.d WPILib/$(MODE_DIR)/Objects/WPILib/Servo.d WPILib/$(MODE_DIR)/Objects/WPILib/SimpleRobot.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/SmartDashboard/SendableChooser.d WPILib/$(MODE_DIR)/Objects/WPILib/SmartDashboard/SmartDashboard.d WPILib/$(MODE_DIR)/Objects/WPILib/Solenoid.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/SolenoidBase.d WPILib/$(MODE_DIR)/Objects/WPILib/Synchronized.d WPILib/$(MODE_DIR)/Objects/WPILib/Talon.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Task.d WPILib/$(MODE_DIR)/Objects/WPILib/Timer.d WPILib/$(MODE_DIR)/Objects/WPILib/Ultrasonic.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Utility.d WPILib/$(MODE_DIR)/Objects/WPILib/Victor.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/AxisCamera.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Vision/AxisCameraParams.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/BinaryImage.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/ColorImage.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Vision/EnumCameraParameter.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/HSLImage.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/ImageBase.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Vision/IntCameraParameter.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/MonoImage.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/PCVideoServer.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Vision/RGBImage.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision/Threshold.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/AxisCamera.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/BaeUtilities.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/FrcError.d WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/TrackAPI.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/Vision2009/VisionAPI.d WPILib/$(MODE_DIR)/Objects/WPILib/Watchdog.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTable.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableConnectionListenerAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableKeyListenerAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableListenerAdapter.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableMode.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableProvider.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables/NetworkTableSubListenerAdapter.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/AbstractNetworkTableEntryStore.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/NetworkTableEntry.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/NetworkTableNode.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/OutgoingEntryReciever.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/TableKeyExistsWithDifferentTypeException.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/TransactionDirtier.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/WriteManager.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/ClientConnectionAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/ClientConnectionState.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/ClientNetworkTableEntryStore.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/client/NetworkTableClient.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/BadMessageException.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/ConnectionMonitorThread.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/DataIOStream.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/connection/NetworkTableConnection.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/NetworkTableServer.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerConnectionAdapter.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerConnectionList.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerConnectionState.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerIncomingStreamMonitor.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/server/ServerNetworkTableEntryStore.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/FDIOStream.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/SocketServerStreamProvider.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/SocketStreamFactory.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/stream/SocketStreams.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/thread/DefaultThreadManger.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ArrayData.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ArrayEntryType.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/BooleanArray.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ComplexData.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/ComplexEntryType.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/DefaultEntryTypes.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/NetworkTableEntryType.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/NetworkTableEntryTypeManager.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/NumberArray.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/type/StringArray.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/EOFException.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/IOException.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/IllegalStateException.d \
+ WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/StringCache.d WPILib/$(MODE_DIR)/Objects/WPILib/networktables2/util/System.d WPILib/$(MODE_DIR)/Objects/WPILib/tables/TableKeyNotDefinedException.d \
+ JavaCameraLib/$(MODE_DIR)/Objects/PCVideoServer.d JavaCameraLib/$(MODE_DIR)/Objects/AxisCamera.d JavaCameraLib/$(MODE_DIR)/Objects/AxisCameraParams.d \
+ JavaCameraLib/$(MODE_DIR)/Objects/EnumCameraParameter.d JavaCameraLib/$(MODE_DIR)/Objects/IntCameraParameter.d JavaCameraLib/$(MODE_DIR)/Objects/Error.d \
+ JavaCameraLib/$(MODE_DIR)/Objects/ErrorBase.d JavaCameraLib/$(MODE_DIR)/Objects/Task.d JavaCameraLib/$(MODE_DIR)/Objects/Timer.d \
+ JavaCameraLib/$(MODE_DIR)/Objects/Synchronized.d JavaCameraLib/$(MODE_DIR)/Objects/Utility.d
-include $(DEP_FILES)
diff --git a/aos/externals/WPILib/WPILib/PWM.cpp b/aos/externals/WPILib/WPILib/PWM.cpp
index 7ae5370..a95489b 100644
--- a/aos/externals/WPILib/WPILib/PWM.cpp
+++ b/aos/externals/WPILib/WPILib/PWM.cpp
@@ -12,9 +12,10 @@
#include "Utility.h"
#include "WPIErrors.h"
-const UINT32 PWM::kDefaultPwmPeriod;
-const UINT32 PWM::kDefaultMinPwmHigh;
-const INT32 PWM::kPwmDisabled;
+constexpr float PWM::kDefaultPwmPeriod;
+constexpr float PWM::kDefaultPwmCenter;
+const int32_t PWM::kDefaultPwmStepsDown;
+const int32_t PWM::kPwmDisabled;
static Resource *allocated = NULL;
/**
@@ -24,8 +25,9 @@
* instances. Checks module and channel value ranges and allocates the appropriate channel.
* The allocation is only done to help users ensure that they don't double assign channels.
*/
-void PWM::InitPWM(UINT8 moduleNumber, UINT32 channel)
+void PWM::InitPWM(uint8_t moduleNumber, uint32_t channel)
{
+ m_table = NULL;
char buf[64];
Resource::CreateResourceObject(&allocated, tDIO::kNumSystems * kPwmChannels);
if (!CheckPWMModule(moduleNumber))
@@ -62,7 +64,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The PWM channel on the digital module (1..10).
*/
-PWM::PWM(UINT8 moduleNumber, UINT32 channel)
+PWM::PWM(uint8_t moduleNumber, uint32_t channel)
: m_module(NULL)
{
InitPWM(moduleNumber, channel);
@@ -76,7 +78,7 @@
*
* @param channel The PWM channel on the digital module.
*/
-PWM::PWM(UINT32 channel)
+PWM::PWM(uint32_t channel)
: m_module(NULL)
{
InitPWM(GetDefaultDigitalModule(), channel);
@@ -119,7 +121,7 @@
* @param deadbandMin The low end of the deadband range
* @param min The minimum pwm value
*/
-void PWM::SetBounds(INT32 max, INT32 deadbandMax, INT32 center, INT32 deadbandMin, INT32 min)
+void PWM::SetBounds(int32_t max, int32_t deadbandMax, int32_t center, int32_t deadbandMin, int32_t min)
{
if (StatusIsFatal()) return;
m_maxPwm = max;
@@ -129,7 +131,31 @@
m_minPwm = min;
}
-UINT32 PWM::GetModuleNumber()
+
+/**
+ * Set the bounds on the PWM pulse widths.
+ * This sets the bounds on the PWM values for a particular type of controller. The values
+ * determine the upper and lower speeds as well as the deadband bracket.
+ * @param max The max PWM pulse width in ms
+ * @param deadbandMax The high end of the deadband range pulse width in ms
+ * @param center The center (off) pulse width in ms
+ * @param deadbandMin The low end of the deadband pulse width in ms
+ * @param min The minimum pulse width in ms
+ */
+void PWM::SetBounds(double max, double deadbandMax, double center, double deadbandMin, double min)
+{
+ if (StatusIsFatal()) return;
+
+ double loopTime = m_module->GetLoopTiming()/(kSystemClockTicksPerMicrosecond*1e3);
+
+ m_maxPwm = (int32_t)((max-kDefaultPwmCenter)/loopTime+kDefaultPwmStepsDown-1);
+ m_deadbandMaxPwm = (int32_t)((deadbandMax-kDefaultPwmCenter)/loopTime+kDefaultPwmStepsDown-1);
+ m_centerPwm = (int32_t)((center-kDefaultPwmCenter)/loopTime+kDefaultPwmStepsDown-1);
+ m_deadbandMinPwm = (int32_t)((deadbandMin-kDefaultPwmCenter)/loopTime+kDefaultPwmStepsDown-1);
+ m_minPwm = (int32_t)((min-kDefaultPwmCenter)/loopTime+kDefaultPwmStepsDown-1);
+}
+
+uint32_t PWM::GetModuleNumber()
{
return m_module->GetNumber();
}
@@ -156,15 +182,15 @@
pos = 1.0;
}
- INT32 rawValue;
+ int32_t rawValue;
// note, need to perform the multiplication below as floating point before converting to int
- rawValue = (INT32)( (pos * (float) GetFullRangeScaleFactor()) + GetMinNegativePwm());
+ rawValue = (int32_t)( (pos * (float) GetFullRangeScaleFactor()) + GetMinNegativePwm());
wpi_assert((rawValue >= GetMinNegativePwm()) && (rawValue <= GetMaxPositivePwm()));
wpi_assert(rawValue != kPwmDisabled);
// send the computed pwm value to the FPGA
- SetRaw((UINT8)rawValue);
+ SetRaw((uint8_t)rawValue);
}
/**
@@ -180,7 +206,7 @@
float PWM::GetPosition()
{
if (StatusIsFatal()) return 0.0;
- INT32 value = GetRaw();
+ int32_t value = GetRaw();
if (value < GetMinNegativePwm())
{
return 0.0;
@@ -222,19 +248,19 @@
}
// calculate the desired output pwm value by scaling the speed appropriately
- INT32 rawValue;
+ int32_t rawValue;
if (speed == 0.0)
{
rawValue = GetCenterPwm();
}
else if (speed > 0.0)
{
- rawValue = (INT32)(speed * ((float)GetPositiveScaleFactor()) +
+ rawValue = (int32_t)(speed * ((float)GetPositiveScaleFactor()) +
((float) GetMinPositivePwm()) + 0.5);
}
else
{
- rawValue = (INT32)(speed * ((float)GetNegativeScaleFactor()) +
+ rawValue = (int32_t)(speed * ((float)GetNegativeScaleFactor()) +
((float) GetMaxNegativePwm()) + 0.5);
}
@@ -243,7 +269,7 @@
wpi_assert(rawValue != kPwmDisabled);
// send the computed pwm value to the FPGA
- SetRaw((UINT8)rawValue);
+ SetRaw((uint8_t)rawValue);
}
/**
@@ -261,8 +287,12 @@
float PWM::GetSpeed()
{
if (StatusIsFatal()) return 0.0;
- INT32 value = GetRaw();
- if (value > GetMaxPositivePwm())
+ int32_t value = GetRaw();
+ if (value == PWM::kPwmDisabled)
+ {
+ return 0.0;
+ }
+ else if (value > GetMaxPositivePwm())
{
return 1.0;
}
@@ -291,7 +321,7 @@
*
* @param value Raw PWM value. Range 0 - 255.
*/
-void PWM::SetRaw(UINT8 value)
+void PWM::SetRaw(uint8_t value)
{
if (StatusIsFatal()) return;
m_module->SetPWM(m_channel, value);
@@ -304,7 +334,7 @@
*
* @return Raw PWM control value. Range: 0 - 255.
*/
-UINT8 PWM::GetRaw()
+uint8_t PWM::GetRaw()
{
if (StatusIsFatal()) return 0;
return m_module->GetPWM(m_channel);
@@ -346,12 +376,17 @@
}
void PWM::StartLiveWindowMode() {
- m_table->AddTableListener("Value", this, true);
+ SetSpeed(0);
+ if (m_table != NULL) {
+ m_table->AddTableListener("Value", this, true);
+ }
}
void PWM::StopLiveWindowMode() {
SetSpeed(0);
- m_table->RemoveTableListener(this);
+ if (m_table != NULL) {
+ m_table->RemoveTableListener(this);
+ }
}
std::string PWM::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/PWM.h b/aos/externals/WPILib/WPILib/PWM.h
index f279016..d497ed2 100644
--- a/aos/externals/WPILib/WPILib/PWM.h
+++ b/aos/externals/WPILib/WPILib/PWM.h
@@ -35,48 +35,45 @@
public:
typedef enum {kPeriodMultiplier_1X = 1, kPeriodMultiplier_2X = 2, kPeriodMultiplier_4X = 4} PeriodMultiplier;
- explicit PWM(UINT32 channel);
- PWM(UINT8 moduleNumber, UINT32 channel);
+ explicit PWM(uint32_t channel);
+ PWM(uint8_t moduleNumber, uint32_t channel);
virtual ~PWM();
- virtual void SetRaw(UINT8 value);
- virtual UINT8 GetRaw();
+ virtual void SetRaw(uint8_t value);
+ virtual uint8_t GetRaw();
void SetPeriodMultiplier(PeriodMultiplier mult);
void EnableDeadbandElimination(bool eliminateDeadband);
- void SetBounds(INT32 max, INT32 deadbandMax, INT32 center, INT32 deadbandMin, INT32 min);
- UINT32 GetChannel() {return m_channel;}
- UINT32 GetModuleNumber();
+ void SetBounds(int32_t max, int32_t deadbandMax, int32_t center, int32_t deadbandMin, int32_t min);
+ void SetBounds(double max, double deadbandMax, double center, double deadbandMin, double min);
+ uint32_t GetChannel() {return m_channel;}
+ uint32_t GetModuleNumber();
protected:
- /**
- * kDefaultPwmPeriod is "ticks" where each tick is 6.525us
- *
- * - 20ms periods (50 Hz) are the "safest" setting in that this works for all devices
- * - 20ms periods seem to be desirable for Vex Motors
- * - 20ms periods are the specified period for HS-322HD servos, but work reliably down
- * to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot;
- * by 5.0ms the hum is nearly continuous
- * - 10ms periods work well for Victor 884
- * - 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers.
- * Due to the shipping firmware on the Jaguar, we can't run the update period less
- * than 5.05 ms.
- *
- * kDefaultPwmPeriod is the 1x period (5.05 ms). In hardware, the period scaling is implemented as an
- * output squelch to get longer periods for old devices.
- *
- * Set to 5.05 ms period / 6.525us clock = 774
- */
- static const UINT32 kDefaultPwmPeriod = 774;
-
- /**
- * kDefaultMinPwmHigh is "ticks" where each tick is 6.525us
- *
- * - There are 128 pwm values less than the center, so...
- * - The minimum output pulse length is 1.5ms - 128 * 6.525us = 0.665ms
- * - 0.665ms / 6.525us per tick = 102
- */
- static const UINT32 kDefaultMinPwmHigh = 102;
-
- static const INT32 kPwmDisabled = 0;
+ /**
+ * kDefaultPwmPeriod is in ms
+ *
+ * - 20ms periods (50 Hz) are the "safest" setting in that this works for all devices
+ * - 20ms periods seem to be desirable for Vex Motors
+ * - 20ms periods are the specified period for HS-322HD servos, but work reliably down
+ * to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot;
+ * by 5.0ms the hum is nearly continuous
+ * - 10ms periods work well for Victor 884
+ * - 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers.
+ * Due to the shipping firmware on the Jaguar, we can't run the update period less
+ * than 5.05 ms.
+ *
+ * kDefaultPwmPeriod is the 1x period (5.05 ms). In hardware, the period scaling is implemented as an
+ * output squelch to get longer periods for old devices.
+ */
+ static constexpr float kDefaultPwmPeriod = 5.05;
+ /**
+ * kDefaultPwmCenter is the PWM range center in ms
+ */
+ static constexpr float kDefaultPwmCenter = 1.5;
+ /**
+ * kDefaultPWMStepsDown is the number of PWM steps below the centerpoint
+ */
+ static const int32_t kDefaultPwmStepsDown = 128;
+ static const int32_t kPwmDisabled = 0;
virtual void SetPosition(float pos);
virtual float GetPosition();
@@ -84,11 +81,11 @@
virtual float GetSpeed();
bool m_eliminateDeadband;
- INT32 m_maxPwm;
- INT32 m_deadbandMaxPwm;
- INT32 m_centerPwm;
- INT32 m_deadbandMinPwm;
- INT32 m_minPwm;
+ int32_t m_maxPwm;
+ int32_t m_deadbandMaxPwm;
+ int32_t m_centerPwm;
+ int32_t m_deadbandMinPwm;
+ int32_t m_minPwm;
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
void UpdateTable();
@@ -101,17 +98,17 @@
ITable *m_table;
private:
- void InitPWM(UINT8 moduleNumber, UINT32 channel);
- UINT32 m_channel;
+ void InitPWM(uint8_t moduleNumber, uint32_t channel);
+ uint32_t m_channel;
DigitalModule *m_module;
- INT32 GetMaxPositivePwm() { return m_maxPwm; };
- INT32 GetMinPositivePwm() { return m_eliminateDeadband ? m_deadbandMaxPwm : m_centerPwm + 1; };
- INT32 GetCenterPwm() { return m_centerPwm; };
- INT32 GetMaxNegativePwm() { return m_eliminateDeadband ? m_deadbandMinPwm : m_centerPwm - 1; };
- INT32 GetMinNegativePwm() { return m_minPwm; };
- INT32 GetPositiveScaleFactor() {return GetMaxPositivePwm() - GetMinPositivePwm();} ///< The scale for positive speeds.
- INT32 GetNegativeScaleFactor() {return GetMaxNegativePwm() - GetMinNegativePwm();} ///< The scale for negative speeds.
- INT32 GetFullRangeScaleFactor() {return GetMaxPositivePwm() - GetMinNegativePwm();} ///< The scale for positions.
+ int32_t GetMaxPositivePwm() { return m_maxPwm; };
+ int32_t GetMinPositivePwm() { return m_eliminateDeadband ? m_deadbandMaxPwm : m_centerPwm + 1; };
+ int32_t GetCenterPwm() { return m_centerPwm; };
+ int32_t GetMaxNegativePwm() { return m_eliminateDeadband ? m_deadbandMinPwm : m_centerPwm - 1; };
+ int32_t GetMinNegativePwm() { return m_minPwm; };
+ int32_t GetPositiveScaleFactor() {return GetMaxPositivePwm() - GetMinPositivePwm();} ///< The scale for positive speeds.
+ int32_t GetNegativeScaleFactor() {return GetMaxNegativePwm() - GetMinNegativePwm();} ///< The scale for negative speeds.
+ int32_t GetFullRangeScaleFactor() {return GetMaxPositivePwm() - GetMinNegativePwm();} ///< The scale for positions.
};
#endif
diff --git a/aos/externals/WPILib/WPILib/Preferences.cpp b/aos/externals/WPILib/WPILib/Preferences.cpp
index e8c0109..9517a05 100644
--- a/aos/externals/WPILib/WPILib/Preferences.cpp
+++ b/aos/externals/WPILib/WPILib/Preferences.cpp
@@ -14,7 +14,7 @@
#include <algorithm>
/** Private NI function needed to write to the VxWorks target */
-extern "C" int Priv_SetWriteFileAllowed(UINT32 enable);
+extern "C" int Priv_SetWriteFileAllowed(uint32_t enable);
/** The Preferences table name */
static const char *kTableName = "Preferences";
@@ -41,7 +41,7 @@
m_tableLock = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
Synchronized sync(m_fileLock);
- m_readTask.Start((UINT32)this);
+ m_readTask.Start((uint32_t)this);
semTake(m_fileOpStarted, WAIT_FOREVER);
nUsageReporting::report(nUsageReporting::kResourceType_Preferences, 0);
@@ -324,7 +324,7 @@
void Preferences::Save()
{
Synchronized sync(m_fileLock);
- m_writeTask.Start((UINT32)this);
+ m_writeTask.Start((uint32_t)this);
semTake(m_fileOpStarted, WAIT_FOREVER);
}
diff --git a/aos/externals/WPILib/WPILib/Relay.cpp b/aos/externals/WPILib/WPILib/Relay.cpp
index 9fb3a2d..1e319c0 100644
--- a/aos/externals/WPILib/WPILib/Relay.cpp
+++ b/aos/externals/WPILib/WPILib/Relay.cpp
@@ -23,8 +23,9 @@
*
* @param moduleNumber The digital module this relay is connected to (1 or 2).
*/
-void Relay::InitRelay (UINT8 moduleNumber)
+void Relay::InitRelay (uint8_t moduleNumber)
{
+ m_table = NULL;
char buf[64];
Resource::CreateResourceObject(&relayChannels, tDIO::kNumSystems * kRelayChannels * 2);
if (!SensorBase::CheckRelayModule(moduleNumber))
@@ -75,7 +76,7 @@
* @param channel The channel number within the module for this relay.
* @param direction The direction that the Relay object will control.
*/
-Relay::Relay(UINT8 moduleNumber, UINT32 channel, Relay::Direction direction)
+Relay::Relay(uint8_t moduleNumber, uint32_t channel, Relay::Direction direction)
: m_channel (channel)
, m_direction (direction)
{
@@ -87,7 +88,7 @@
* @param channel The channel number within the default module for this relay.
* @param direction The direction that the Relay object will control.
*/
-Relay::Relay(UINT32 channel, Relay::Direction direction)
+Relay::Relay(uint32_t channel, Relay::Direction direction)
: m_channel (channel)
, m_direction (direction)
{
@@ -246,11 +247,15 @@
}
void Relay::StartLiveWindowMode() {
- m_table->AddTableListener("Value", this, true);
+ if(m_table != NULL){
+ m_table->AddTableListener("Value", this, true);
+ }
}
void Relay::StopLiveWindowMode() {
- m_table->RemoveTableListener(this);
+ if(m_table != NULL){
+ m_table->RemoveTableListener(this);
+ }
}
std::string Relay::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/Relay.h b/aos/externals/WPILib/WPILib/Relay.h
index 640f657..d7bb459 100644
--- a/aos/externals/WPILib/WPILib/Relay.h
+++ b/aos/externals/WPILib/WPILib/Relay.h
@@ -28,8 +28,8 @@
typedef enum {kOff, kOn, kForward, kReverse} Value;
typedef enum {kBothDirections, kForwardOnly, kReverseOnly} Direction;
- Relay(UINT32 channel, Direction direction = kBothDirections);
- Relay(UINT8 moduleNumber, UINT32 channel, Direction direction = kBothDirections);
+ Relay(uint32_t channel, Direction direction = kBothDirections);
+ Relay(uint8_t moduleNumber, uint32_t channel, Direction direction = kBothDirections);
virtual ~Relay();
void Set(Value value);
@@ -46,9 +46,9 @@
ITable *m_table;
private:
- void InitRelay(UINT8 moduleNumber);
+ void InitRelay(uint8_t moduleNumber);
- UINT32 m_channel;
+ uint32_t m_channel;
Direction m_direction;
DigitalModule *m_module;
};
diff --git a/aos/externals/WPILib/WPILib/Resource.cpp b/aos/externals/WPILib/WPILib/Resource.cpp
index ef7d15d..a5a763e 100644
--- a/aos/externals/WPILib/WPILib/Resource.cpp
+++ b/aos/externals/WPILib/WPILib/Resource.cpp
@@ -14,12 +14,12 @@
* Allocate a bool array of values that will get initialized to indicate that no resources
* have been allocated yet. The indicies of the resources are [0 .. elements - 1].
*/
-Resource::Resource(UINT32 elements)
+Resource::Resource(uint32_t elements)
{
Synchronized sync(m_createLock);
m_size = elements;
m_isAllocated = new bool[m_size];
- for (UINT32 i=0; i < m_size; i++)
+ for (uint32_t i=0; i < m_size; i++)
{
m_isAllocated[i] = false;
}
@@ -36,7 +36,7 @@
* track, that is, it will allocate resource numbers in the range
* [0 .. elements - 1].
*/
-/*static*/ void Resource::CreateResourceObject(Resource **r, UINT32 elements)
+/*static*/ void Resource::CreateResourceObject(Resource **r, uint32_t elements)
{
Synchronized sync(m_createLock);
if (*r == NULL)
@@ -59,10 +59,10 @@
* When a resource is requested, mark it allocated. In this case, a free resource value
* within the range is located and returned after it is marked allocated.
*/
-UINT32 Resource::Allocate(const char *resourceDesc, const ErrorBase *error)
+uint32_t Resource::Allocate(const char *resourceDesc, const ErrorBase *error)
{
Synchronized sync(m_allocateLock);
- for (UINT32 i=0; i < m_size; i++)
+ for (uint32_t i=0; i < m_size; i++)
{
if (!m_isAllocated[i])
{
@@ -79,8 +79,8 @@
* The user requests a specific resource value, i.e. channel number and it is verified
* unallocated, then returned.
*/
-UINT32 Resource::Allocate(UINT32 index, const char *resourceDesc,
- const ErrorBase *error)
+uint32_t Resource::Allocate(uint32_t index, const char *resourceDesc,
+ const ErrorBase *error)
{
Synchronized sync(m_allocateLock);
if (index >= m_size)
@@ -103,7 +103,7 @@
* After a resource is no longer needed, for example a destructor is called for a channel assignment
* class, Free will release the resource value so it can be reused somewhere else in the program.
*/
-void Resource::Free(UINT32 index, const ErrorBase *error)
+void Resource::Free(uint32_t index, const ErrorBase *error)
{
Synchronized sync(m_allocateLock);
if (index == ~0ul) return;
diff --git a/aos/externals/WPILib/WPILib/Resource.h b/aos/externals/WPILib/WPILib/Resource.h
index 11faaec..daac57b 100644
--- a/aos/externals/WPILib/WPILib/Resource.h
+++ b/aos/externals/WPILib/WPILib/Resource.h
@@ -26,18 +26,18 @@
{
public:
virtual ~Resource();
- static void CreateResourceObject(Resource **r, UINT32 elements);
- UINT32 Allocate(const char *resourceDesc, const ErrorBase *error);
- UINT32 Allocate(UINT32 index, const char *resourceDesc,
- const ErrorBase *error);
- void Free(UINT32 index, const ErrorBase *error);
+ static void CreateResourceObject(Resource **r, uint32_t elements);
+ uint32_t Allocate(const char *resourceDesc, const ErrorBase *error);
+ uint32_t Allocate(uint32_t index, const char *resourceDesc,
+ const ErrorBase *error);
+ void Free(uint32_t index, const ErrorBase *error);
private:
- explicit Resource(UINT32 size);
+ explicit Resource(uint32_t size);
bool *m_isAllocated;
ReentrantSemaphore m_allocateLock;
- UINT32 m_size;
+ uint32_t m_size;
static ReentrantSemaphore m_createLock;
diff --git a/aos/externals/WPILib/WPILib/RobotBase.cpp b/aos/externals/WPILib/WPILib/RobotBase.cpp
index 17c7682..2be15c2 100644
--- a/aos/externals/WPILib/WPILib/RobotBase.cpp
+++ b/aos/externals/WPILib/WPILib/RobotBase.cpp
@@ -14,9 +14,14 @@
#include <moduleLib.h>
#include <taskLib.h>
#include <unldLib.h>
+#include <cstring>
RobotBase* RobotBase::m_instance = NULL;
+const char *FILE_NAME = "/c/FRC_Lib_Version.ini";
+const char *VERSION_STRING = "C++ 2014 Update 0";
+
+
void RobotBase::setInstance(RobotBase* robot)
{
// No point in synchronization here because it's private and it only gets
@@ -144,6 +149,14 @@
instance->StartCompetition();
}
+void RobotBase::WriteVersionString() {
+ FILE *file = fopen(FILE_NAME, "w");
+ if (file != NULL) {
+ fputs(VERSION_STRING, file);
+ fclose(file);
+ }
+}
+
/**
*
* Start the robot code.
@@ -170,7 +183,7 @@
#endif
// Check for startup code already running
- INT32 oldId = taskNameToId("FRC_RobotTask");
+ int32_t oldId = taskNameToId(const_cast<char*>("FRC_RobotTask"));
if (oldId != ERROR)
{
// Find the startup code module.
@@ -194,12 +207,14 @@
// Let the Usage Reporting framework know that there is a C++ program running
nUsageReporting::report(nUsageReporting::kResourceType_Language, nUsageReporting::kLanguage_CPlusPlus);
+
+ RobotBase::WriteVersionString();
// Start robot task
// This is done to ensure that the C++ robot task is spawned with the floating point
// context save parameter.
Task *task = new Task("RobotTask", (FUNCPTR)RobotBase::robotTask, Task::kDefaultPriority, 64000);
- task->Start((INT32)factory, (INT32)task);
+ task->Start((int32_t)factory, (int32_t)task);
}
/**
diff --git a/aos/externals/WPILib/WPILib/RobotBase.h b/aos/externals/WPILib/WPILib/RobotBase.h
index 45c24dd..e587089 100644
--- a/aos/externals/WPILib/WPILib/RobotBase.h
+++ b/aos/externals/WPILib/WPILib/RobotBase.h
@@ -24,7 +24,7 @@
return new _ClassName_(); \
} \
extern "C" { \
- INT32 FRC_UserProgram_StartupLibraryInit() \
+ int32_t FRC_UserProgram_StartupLibraryInit() \
{ \
RobotBase::startRobotTask((FUNCPTR)FRC_userClassFactory); \
return 0; \
@@ -56,6 +56,7 @@
virtual ~RobotBase();
virtual void StartCompetition() = 0;
RobotBase();
+ static void WriteVersionString();
static void setInstance(RobotBase* robot);
static void robotTask(FUNCPTR factory, Task *task);
@@ -63,7 +64,6 @@
Task *m_task;
Watchdog m_watchdog;
DriverStation *m_ds;
-
private:
static RobotBase *m_instance;
DISALLOW_COPY_AND_ASSIGN(RobotBase);
diff --git a/aos/externals/WPILib/WPILib/RobotDrive.cpp b/aos/externals/WPILib/WPILib/RobotDrive.cpp
index 1d538c5..4f6b4b6 100644
--- a/aos/externals/WPILib/WPILib/RobotDrive.cpp
+++ b/aos/externals/WPILib/WPILib/RobotDrive.cpp
@@ -17,7 +17,7 @@
#define max(x, y) (((x) > (y)) ? (x) : (y))
-const INT32 RobotDrive::kMaxNumberOfMotors;
+const int32_t RobotDrive::kMaxNumberOfMotors;
/*
* Driving functions
@@ -49,12 +49,12 @@
* @param leftMotorChannel The PWM channel number on the default digital module that drives the left motor.
* @param rightMotorChannel The PWM channel number on the default digital module that drives the right motor.
*/
-RobotDrive::RobotDrive(UINT32 leftMotorChannel, UINT32 rightMotorChannel)
+RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel)
{
InitRobotDrive();
m_rearLeftMotor = new Jaguar(leftMotorChannel);
m_rearRightMotor = new Jaguar(rightMotorChannel);
- for (INT32 i=0; i < kMaxNumberOfMotors; i++)
+ for (int32_t i=0; i < kMaxNumberOfMotors; i++)
{
m_invertedMotors[i] = 1;
}
@@ -72,15 +72,15 @@
* @param frontRightMotor Front right motor channel number on the default digital module
* @param rearRightMotor Rear Right motor channel number on the default digital module
*/
-RobotDrive::RobotDrive(UINT32 frontLeftMotor, UINT32 rearLeftMotor,
- UINT32 frontRightMotor, UINT32 rearRightMotor)
+RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
+ uint32_t frontRightMotor, uint32_t rearRightMotor)
{
InitRobotDrive();
m_rearLeftMotor = new Jaguar(rearLeftMotor);
m_rearRightMotor = new Jaguar(rearRightMotor);
m_frontLeftMotor = new Jaguar(frontLeftMotor);
m_frontRightMotor = new Jaguar(frontRightMotor);
- for (INT32 i=0; i < kMaxNumberOfMotors; i++)
+ for (int32_t i=0; i < kMaxNumberOfMotors; i++)
{
m_invertedMotors[i] = 1;
}
@@ -107,7 +107,7 @@
}
m_rearLeftMotor = leftMotor;
m_rearRightMotor = rightMotor;
- for (INT32 i=0; i < kMaxNumberOfMotors; i++)
+ for (int32_t i=0; i < kMaxNumberOfMotors; i++)
{
m_invertedMotors[i] = 1;
}
@@ -119,7 +119,7 @@
InitRobotDrive();
m_rearLeftMotor = &leftMotor;
m_rearRightMotor = &rightMotor;
- for (INT32 i=0; i < kMaxNumberOfMotors; i++)
+ for (int32_t i=0; i < kMaxNumberOfMotors; i++)
{
m_invertedMotors[i] = 1;
}
@@ -147,7 +147,7 @@
m_rearLeftMotor = rearLeftMotor;
m_frontRightMotor = frontRightMotor;
m_rearRightMotor = rearRightMotor;
- for (INT32 i=0; i < kMaxNumberOfMotors; i++)
+ for (int32_t i=0; i < kMaxNumberOfMotors; i++)
{
m_invertedMotors[i] = 1;
}
@@ -162,7 +162,7 @@
m_rearLeftMotor = &rearLeftMotor;
m_frontRightMotor = &frontRightMotor;
m_rearRightMotor = &rearRightMotor;
- for (INT32 i=0; i < kMaxNumberOfMotors; i++)
+ for (int32_t i=0; i < kMaxNumberOfMotors; i++)
{
m_invertedMotors[i] = 1;
}
@@ -262,8 +262,8 @@
* @param rightStick The Joystick object to use for the right side of the robot.
* @param rightAxis The axis to select on the right side Joystick object.
*/
-void RobotDrive::TankDrive(GenericHID *leftStick, UINT32 leftAxis,
- GenericHID *rightStick, UINT32 rightAxis, bool squaredInputs)
+void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis,
+ GenericHID *rightStick, uint32_t rightAxis, bool squaredInputs)
{
if (leftStick == NULL || rightStick == NULL)
{
@@ -273,8 +273,8 @@
TankDrive(leftStick->GetRawAxis(leftAxis), rightStick->GetRawAxis(rightAxis), squaredInputs);
}
-void RobotDrive::TankDrive(GenericHID &leftStick, UINT32 leftAxis,
- GenericHID &rightStick, UINT32 rightAxis, bool squaredInputs)
+void RobotDrive::TankDrive(GenericHID &leftStick, uint32_t leftAxis,
+ GenericHID &rightStick, uint32_t rightAxis, bool squaredInputs)
{
TankDrive(leftStick.GetRawAxis(leftAxis), rightStick.GetRawAxis(rightAxis), squaredInputs);
}
@@ -361,8 +361,8 @@
* @param rotateAxis The axis on the rotation object to use for the rotate right/left (typically X_AXIS)
* @param squaredInputs Setting this parameter to true increases the sensitivity at lower speeds
*/
-void RobotDrive::ArcadeDrive(GenericHID* moveStick, UINT32 moveAxis,
- GenericHID* rotateStick, UINT32 rotateAxis,
+void RobotDrive::ArcadeDrive(GenericHID* moveStick, uint32_t moveAxis,
+ GenericHID* rotateStick, uint32_t rotateAxis,
bool squaredInputs)
{
float moveValue = moveStick->GetRawAxis(moveAxis);
@@ -382,8 +382,8 @@
* @param squaredInputs Setting this parameter to true increases the sensitivity at lower speeds
*/
-void RobotDrive::ArcadeDrive(GenericHID &moveStick, UINT32 moveAxis,
- GenericHID &rotateStick, UINT32 rotateAxis,
+void RobotDrive::ArcadeDrive(GenericHID &moveStick, uint32_t moveAxis,
+ GenericHID &rotateStick, uint32_t rotateAxis,
bool squaredInputs)
{
float moveValue = moveStick.GetRawAxis(moveAxis);
@@ -505,7 +505,7 @@
Normalize(wheelSpeeds);
- UINT8 syncGroup = 0x80;
+ uint8_t syncGroup = 0x80;
m_frontLeftMotor->Set(wheelSpeeds[kFrontLeftMotor] * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, syncGroup);
m_frontRightMotor->Set(wheelSpeeds[kFrontRightMotor] * m_invertedMotors[kFrontRightMotor] * m_maxOutput, syncGroup);
@@ -554,7 +554,7 @@
Normalize(wheelSpeeds);
- UINT8 syncGroup = 0x80;
+ uint8_t syncGroup = 0x80;
m_frontLeftMotor->Set(wheelSpeeds[kFrontLeftMotor] * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, syncGroup);
m_frontRightMotor->Set(wheelSpeeds[kFrontRightMotor] * m_invertedMotors[kFrontRightMotor] * m_maxOutput, syncGroup);
@@ -593,7 +593,7 @@
{
wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL);
- UINT8 syncGroup = 0x80;
+ uint8_t syncGroup = 0x80;
if (m_frontLeftMotor != NULL)
m_frontLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, syncGroup);
@@ -630,7 +630,7 @@
void RobotDrive::Normalize(double *wheelSpeeds)
{
double maxMagnitude = fabs(wheelSpeeds[0]);
- INT32 i;
+ int32_t i;
for (i=1; i<kMaxNumberOfMotors; i++)
{
double temp = fabs(wheelSpeeds[i]);
diff --git a/aos/externals/WPILib/WPILib/RobotDrive.h b/aos/externals/WPILib/WPILib/RobotDrive.h
index 4567dac..892685c 100644
--- a/aos/externals/WPILib/WPILib/RobotDrive.h
+++ b/aos/externals/WPILib/WPILib/RobotDrive.h
@@ -35,9 +35,9 @@
kRearRightMotor = 3
} MotorType;
- RobotDrive(UINT32 leftMotorChannel, UINT32 rightMotorChannel);
- RobotDrive(UINT32 frontLeftMotorChannel, UINT32 rearLeftMotorChannel,
- UINT32 frontRightMotorChannel, UINT32 rearRightMotorChannel);
+ RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel);
+ RobotDrive(uint32_t frontLeftMotorChannel, uint32_t rearLeftMotorChannel,
+ uint32_t frontRightMotorChannel, uint32_t rearRightMotorChannel);
RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor);
RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor);
RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor,
@@ -49,13 +49,13 @@
void Drive(float outputMagnitude, float curve);
void TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs = true);
void TankDrive(GenericHID &leftStick, GenericHID &rightStick, bool squaredInputs = true);
- void TankDrive(GenericHID *leftStick, UINT32 leftAxis, GenericHID *rightStick, UINT32 rightAxis, bool squaredInputs = true);
- void TankDrive(GenericHID &leftStick, UINT32 leftAxis, GenericHID &rightStick, UINT32 rightAxis, bool squaredInputs = true);
+ void TankDrive(GenericHID *leftStick, uint32_t leftAxis, GenericHID *rightStick, uint32_t rightAxis, bool squaredInputs = true);
+ void TankDrive(GenericHID &leftStick, uint32_t leftAxis, GenericHID &rightStick, uint32_t rightAxis, bool squaredInputs = true);
void TankDrive(float leftValue, float rightValue, bool squaredInputs = true);
void ArcadeDrive(GenericHID *stick, bool squaredInputs = true);
void ArcadeDrive(GenericHID &stick, bool squaredInputs = true);
- void ArcadeDrive(GenericHID *moveStick, UINT32 moveChannel, GenericHID *rotateStick, UINT32 rotateChannel, bool squaredInputs = true);
- void ArcadeDrive(GenericHID &moveStick, UINT32 moveChannel, GenericHID &rotateStick, UINT32 rotateChannel, bool squaredInputs = true);
+ void ArcadeDrive(GenericHID *moveStick, uint32_t moveChannel, GenericHID *rotateStick, uint32_t rotateChannel, bool squaredInputs = true);
+ void ArcadeDrive(GenericHID &moveStick, uint32_t moveChannel, GenericHID &rotateStick, uint32_t rotateChannel, bool squaredInputs = true);
void ArcadeDrive(float moveValue, float rotateValue, bool squaredInputs = true);
void MecanumDrive_Cartesian(float x, float y, float rotation, float gyroAngle = 0.0);
void MecanumDrive_Polar(float magnitude, float direction, float rotation);
@@ -79,9 +79,9 @@
void Normalize(double *wheelSpeeds);
void RotateVector(double &x, double &y, double angle);
- static const INT32 kMaxNumberOfMotors = 4;
+ static const int32_t kMaxNumberOfMotors = 4;
- INT32 m_invertedMotors[kMaxNumberOfMotors];
+ int32_t m_invertedMotors[kMaxNumberOfMotors];
float m_sensitivity;
double m_maxOutput;
bool m_deleteSpeedControllers;
@@ -92,7 +92,7 @@
MotorSafetyHelper *m_safetyHelper;
private:
- INT32 GetNumMotors()
+ int32_t GetNumMotors()
{
int motors = 0;
if (m_frontLeftMotor) motors++;
diff --git a/aos/externals/WPILib/WPILib/SPI.cpp b/aos/externals/WPILib/WPILib/SPI.cpp
index e7038f8..2f90d74 100644
--- a/aos/externals/WPILib/WPILib/SPI.cpp
+++ b/aos/externals/WPILib/WPILib/SPI.cpp
@@ -7,6 +7,7 @@
#include "SPI.h"
#include "ChipObject/tSPI.h"
+#include "DigitalModule.h"
#include "DigitalInput.h"
#include "DigitalOutput.h"
#include "NetworkCommunication/UsageReporting.h"
@@ -161,7 +162,7 @@
m_ss = NULL;
- static INT32 instances = 0;
+ static int32_t instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_SPI, instances);
}
@@ -172,7 +173,7 @@
*
* @param bits The number of bits in one frame (1 to 32 bits).
*/
-void SPI::SetBitsPerWord(UINT32 bits)
+void SPI::SetBitsPerWord(uint32_t bits)
{
m_config.BusBitWidth = bits;
}
@@ -183,7 +184,7 @@
*
* @return The number of bits in one frame (1 to 32 bits).
*/
-UINT32 SPI::GetBitsPerWord()
+uint32_t SPI::GetBitsPerWord()
{
return m_config.BusBitWidth;
}
@@ -197,21 +198,18 @@
void SPI::SetClockRate(double hz)
{
int delay = 0;
- // TODO: compute the appropriate values based on digital loop timing
- if (hz <= 76628.4)
- {
- double v = (1.0/hz)/1.305e-5;
- int intv = (int)v;
- if (v-intv > 0.5)
- delay = intv;
- else
- delay = intv-1;
- }
- if (delay > 255)
- {
- wpi_setWPIError(SPIClockRateTooLow);
- delay = 255;
- }
+ tRioStatusCode localStatus = NiFpga_Status_Success;
+ int loopTiming = DigitalModule::GetInstance(m_spi->readChannels_SCLK_Module(&localStatus))->GetLoopTiming();
+ wpi_setError(localStatus);
+ double v = (1.0 / hz) / (2 * loopTiming / (kSystemClockTicksPerMicrosecond * 1e6));
+ if (v < 1) {
+ wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too high");
+ }
+ delay = (int) (v + .5);
+ if (delay > 255) {
+ wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too low");
+ }
+
m_config.ClockHalfPeriodDelay = delay;
}
@@ -377,10 +375,10 @@
*
* @return The number of words available to be written.
*/
-UINT16 SPI::GetOutputFIFOAvailable()
+uint16_t SPI::GetOutputFIFOAvailable()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT16 result = m_spi->readAvailableToLoad(&localStatus);
+ uint16_t result = m_spi->readAvailableToLoad(&localStatus);
wpi_setError(localStatus);
return result;
}
@@ -391,10 +389,10 @@
*
* @return The number of words available to read.
*/
-UINT16 SPI::GetNumReceived()
+uint16_t SPI::GetNumReceived()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT16 result = m_spi->readReceivedElements(&localStatus);
+ uint16_t result = m_spi->readReceivedElements(&localStatus);
wpi_setError(localStatus);
return result;
}
@@ -433,7 +431,7 @@
* If not running in output only mode, also saves the data received
* on the MISO input during the transfer into the receive FIFO.
*/
-void SPI::Write(UINT32 data)
+void SPI::Write(uint32_t data)
{
if (m_channels.MOSI_Channel == 0 && m_channels.MOSI_Module == 0)
{
@@ -465,7 +463,7 @@
* If false, this function assumes that data is
* already in the receive FIFO from a previous write.
*/
-UINT32 SPI::Read(bool initiate)
+uint32_t SPI::Read(bool initiate)
{
if (m_channels.MISO_Channel == 0 && m_channels.MISO_Module == 0)
{
@@ -474,7 +472,7 @@
}
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 data;
+ uint32_t data;
{
Synchronized sync(m_semaphore);
diff --git a/aos/externals/WPILib/WPILib/SPI.h b/aos/externals/WPILib/WPILib/SPI.h
index 05f8a05..60fd4bc 100644
--- a/aos/externals/WPILib/WPILib/SPI.h
+++ b/aos/externals/WPILib/WPILib/SPI.h
@@ -35,8 +35,8 @@
SPI(DigitalOutput *clk, DigitalInput *miso);
virtual ~SPI();
- void SetBitsPerWord(UINT32 bits);
- UINT32 GetBitsPerWord();
+ void SetBitsPerWord(uint32_t bits);
+ uint32_t GetBitsPerWord();
void SetClockRate(double hz);
void SetMSBFirst();
@@ -54,14 +54,14 @@
virtual void ApplyConfig();
- virtual UINT16 GetOutputFIFOAvailable();
- virtual UINT16 GetNumReceived();
+ virtual uint16_t GetOutputFIFOAvailable();
+ virtual uint16_t GetNumReceived();
virtual bool IsDone();
bool HadReceiveOverflow();
- virtual void Write(UINT32 data);
- virtual UINT32 Read(bool initiate = false);
+ virtual void Write(uint32_t data);
+ virtual uint32_t Read(bool initiate = false);
virtual void Reset();
virtual void ClearReceivedData();
diff --git a/aos/externals/WPILib/WPILib/SafePWM.cpp b/aos/externals/WPILib/WPILib/SafePWM.cpp
index 989d782..d0ddb8b 100644
--- a/aos/externals/WPILib/WPILib/SafePWM.cpp
+++ b/aos/externals/WPILib/WPILib/SafePWM.cpp
@@ -21,7 +21,7 @@
* Constructor for a SafePWM object taking a channel number
* @param channel The channel number to be used for the underlying PWM object
*/
-SafePWM::SafePWM(UINT32 channel): PWM(channel)
+SafePWM::SafePWM(uint32_t channel): PWM(channel)
{
InitSafePWM();
}
@@ -31,7 +31,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The PWM channel number on the module (1..10).
*/
-SafePWM::SafePWM(UINT8 moduleNumber, UINT32 channel): PWM(moduleNumber, channel)
+SafePWM::SafePWM(uint8_t moduleNumber, uint32_t channel): PWM(moduleNumber, channel)
{
InitSafePWM();
}
@@ -100,7 +100,7 @@
void SafePWM::GetDescription(char *desc)
{
- snprintf(desc, 64, "PWM %d on module %d", GetChannel(), GetModuleNumber());
+ snprintf(desc, 64, "PWM %ld on module %ld", GetChannel(), GetModuleNumber());
}
/**
diff --git a/aos/externals/WPILib/WPILib/SafePWM.h b/aos/externals/WPILib/WPILib/SafePWM.h
index feef64c..5b5b0a7 100644
--- a/aos/externals/WPILib/WPILib/SafePWM.h
+++ b/aos/externals/WPILib/WPILib/SafePWM.h
@@ -22,8 +22,8 @@
class SafePWM: public PWM, public MotorSafety
{
public:
- explicit SafePWM(UINT32 channel);
- SafePWM(UINT8 moduleNumber, UINT32 channel);
+ explicit SafePWM(uint32_t channel);
+ SafePWM(uint8_t moduleNumber, uint32_t channel);
~SafePWM();
void SetExpiration(float timeout);
diff --git a/aos/externals/WPILib/WPILib/Scripts/CopyWPILibToUpdateDirectory.cmd b/aos/externals/WPILib/WPILib/Scripts/CopyWPILibToUpdateDirectory.cmd
index 7e0f220..2445cce 100644
--- a/aos/externals/WPILib/WPILib/Scripts/CopyWPILibToUpdateDirectory.cmd
+++ b/aos/externals/WPILib/WPILib/Scripts/CopyWPILibToUpdateDirectory.cmd
@@ -5,6 +5,7 @@
mkdir vxworks-6.3\target\h\WPILib\Buttons
mkdir vxworks-6.3\target\h\WPILib\CAN
mkdir vxworks-6.3\target\h\WPILib\ChipObject
+mkdir vxworks-6.3\target\h\WPILib\ChipObject\fpgainterfacecapi
mkdir vxworks-6.3\target\h\WPILib\CInterfaces
mkdir vxworks-6.3\target\h\WPILib\Commands
mkdir vxworks-6.3\target\h\WPILib\NetworkCommunication
@@ -14,6 +15,7 @@
mkdir vxworks-6.3\target\h\WPILib\Vision2009
mkdir vxworks-6.3\target\h\WPILib\LiveWindow
+mkdir vxworks-6.3\target\h\WPILib\OSAL
mkdir vxworks-6.3\target\h\WPILib\networktables
mkdir vxworks-6.3\target\h\WPILib\tables
mkdir vxworks-6.3\target\h\WPILib\networktables2
@@ -39,6 +41,7 @@
del vxworks-6.3\target\h\WPIlib\Vision2009\*.h
del vxworks-6.3\target\h\WPIlib\LiveWindow\*.h
+del vxworks-6.3\target\h\WPIlib\OSAL\*.h
del vxworks-6.3\target\h\WPIlib\networktables\*.h
del vxworks-6.3\target\h\WPIlib\tables\*.h
del vxworks-6.3\target\h\WPIlib\networktables2\*.h
@@ -57,6 +60,7 @@
copy C:\WindRiver\workspace\WPILib\Buttons\*.h vxworks-6.3\target\h\WPILib\Buttons
copy C:\WindRiver\workspace\WPILib\CAN\*.h vxworks-6.3\target\h\WPILib\CAN
copy C:\WindRiver\workspace\WPILib\ChipObject\*.h vxworks-6.3\target\h\WPILib\ChipObject
+copy C:\WindRiver\workspace\WPILib\ChipObject\fpgainterfacecapi\*.h vxworks-6.3\target\h\WPILib\ChipObject\fpgainterfacecapi
copy C:\WindRiver\workspace\WPILib\CInterfaces\*.h vxworks-6.3\target\h\WPILib\CInterfaces
copy C:\WindRiver\workspace\WPILib\Commands\*.h vxworks-6.3\target\h\WPILib\Commands
copy C:\WindRiver\workspace\WPILib\NetworkCommunication\*.h vxworks-6.3\target\h\WPILib\NetworkCommunication
@@ -66,6 +70,7 @@
copy C:\WindRiver\workspace\WPILib\Vision2009\*.h vxworks-6.3\target\h\WPILib\Vision2009
copy C:\WindRiver\workspace\WPILib\LiveWindow\*.h vxworks-6.3\target\h\WPILib\LiveWindow
+copy C:\WindRiver\workspace\WPILib\OSAL\*.h vxworks-6.3\target\h\WPILib\OSAL
copy C:\WindRiver\workspace\WPILib\networktables\*.h vxworks-6.3\target\h\WPILib\networktables
copy C:\WindRiver\workspace\WPILib\tables\*.h vxworks-6.3\target\h\WPILib\tables
copy C:\WindRiver\workspace\WPILib\networktables2\*.h vxworks-6.3\target\h\WPILib\networktables2
diff --git a/aos/externals/WPILib/WPILib/Scripts/updateBuiltInLibrary.cmd b/aos/externals/WPILib/WPILib/Scripts/updateBuiltInLibrary.cmd
index ebbbcff..cf410c4 100644
--- a/aos/externals/WPILib/WPILib/Scripts/updateBuiltInLibrary.cmd
+++ b/aos/externals/WPILib/WPILib/Scripts/updateBuiltInLibrary.cmd
@@ -15,6 +15,7 @@
mkdir h\WPILib\Vision2009
mkdir h\WPILib\LiveWindow
+mkdir h\WPILib\OSAL
mkdir h\WPILib\networktables
mkdir h\WPILib\tables
mkdir h\WPILib\networktables2
@@ -41,6 +42,7 @@
copy c:\WindRiver\workspace\WPILib\Vision2009\*.h h\WPILib\Vision2009
copy C:\WindRiver\workspace\WPILib\LiveWindow\*.h h\WPILib\LiveWindow
+copy C:\WindRiver\workspace\WPILib\OSAL\*.h h\WPILib\OSAL
copy C:\WindRiver\workspace\WPILib\networktables\*.h h\WPILib\networktables
copy C:\WindRiver\workspace\WPILib\tables\*.h h\WPILib\tables
copy C:\WindRiver\workspace\WPILib\networktables2\*.h h\WPILib\networktables2
diff --git a/aos/externals/WPILib/WPILib/SensorBase.cpp b/aos/externals/WPILib/WPILib/SensorBase.cpp
index 5574a35..82f15c4 100644
--- a/aos/externals/WPILib/WPILib/SensorBase.cpp
+++ b/aos/externals/WPILib/WPILib/SensorBase.cpp
@@ -8,15 +8,15 @@
#include "NetworkCommunication/LoadOut.h"
-const UINT32 SensorBase::kSystemClockTicksPerMicrosecond;
-const UINT32 SensorBase::kDigitalChannels;
-const UINT32 SensorBase::kAnalogChannels;
-const UINT32 SensorBase::kAnalogModules;
-const UINT32 SensorBase::kDigitalModules;
-const UINT32 SensorBase::kSolenoidChannels;
-const UINT32 SensorBase::kSolenoidModules;
-const UINT32 SensorBase::kPwmChannels;
-const UINT32 SensorBase::kRelayChannels;
+const uint32_t SensorBase::kSystemClockTicksPerMicrosecond;
+const uint32_t SensorBase::kDigitalChannels;
+const uint32_t SensorBase::kAnalogChannels;
+const uint32_t SensorBase::kAnalogModules;
+const uint32_t SensorBase::kDigitalModules;
+const uint32_t SensorBase::kSolenoidChannels;
+const uint32_t SensorBase::kSolenoidModules;
+const uint32_t SensorBase::kPwmChannels;
+const uint32_t SensorBase::kRelayChannels;
SensorBase *SensorBase::m_singletonList = NULL;
ReentrantSemaphore SensorBase::m_singletonListSemaphore;
@@ -74,7 +74,7 @@
*
* @return Analog module is valid and present
*/
-bool SensorBase::CheckAnalogModule(UINT8 moduleNumber)
+bool SensorBase::CheckAnalogModule(uint8_t moduleNumber)
{
if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Analog, moduleNumber - 1))
return true;
@@ -86,7 +86,7 @@
*
* @return Digital module is valid and present
*/
-bool SensorBase::CheckDigitalModule(UINT8 moduleNumber)
+bool SensorBase::CheckDigitalModule(uint8_t moduleNumber)
{
if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Digital, moduleNumber - 1))
return true;
@@ -98,7 +98,7 @@
*
* @return Digital module is valid and present
*/
-bool SensorBase::CheckPWMModule(UINT8 moduleNumber)
+bool SensorBase::CheckPWMModule(uint8_t moduleNumber)
{
return CheckDigitalModule(moduleNumber);
}
@@ -108,7 +108,7 @@
*
* @return Digital module is valid and present
*/
-bool SensorBase::CheckRelayModule(UINT8 moduleNumber)
+bool SensorBase::CheckRelayModule(uint8_t moduleNumber)
{
return CheckDigitalModule(moduleNumber);
}
@@ -118,7 +118,7 @@
*
* @return Solenoid module is valid and present
*/
-bool SensorBase::CheckSolenoidModule(UINT8 moduleNumber)
+bool SensorBase::CheckSolenoidModule(uint8_t moduleNumber)
{
if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Solenoid, moduleNumber - 1))
return true;
@@ -132,7 +132,7 @@
*
* @return Digital channel is valid
*/
-bool SensorBase::CheckDigitalChannel(UINT32 channel)
+bool SensorBase::CheckDigitalChannel(uint32_t channel)
{
if (channel > 0 && channel <= kDigitalChannels)
return true;
@@ -146,7 +146,7 @@
*
* @return Relay channel is valid
*/
-bool SensorBase::CheckRelayChannel(UINT32 channel)
+bool SensorBase::CheckRelayChannel(uint32_t channel)
{
if (channel > 0 && channel <= kRelayChannels)
return true;
@@ -160,7 +160,7 @@
*
* @return PWM channel is valid
*/
-bool SensorBase::CheckPWMChannel(UINT32 channel)
+bool SensorBase::CheckPWMChannel(uint32_t channel)
{
if (channel > 0 && channel <= kPwmChannels)
return true;
@@ -174,7 +174,7 @@
*
* @return Analog channel is valid
*/
-bool SensorBase::CheckAnalogChannel(UINT32 channel)
+bool SensorBase::CheckAnalogChannel(uint32_t channel)
{
if (channel > 0 && channel <= kAnalogChannels)
return true;
@@ -186,7 +186,7 @@
*
* @return Solenoid channel is valid
*/
-bool SensorBase::CheckSolenoidChannel(UINT32 channel)
+bool SensorBase::CheckSolenoidChannel(uint32_t channel)
{
if (channel > 0 && channel <= kSolenoidChannels)
return true;
diff --git a/aos/externals/WPILib/WPILib/SensorBase.h b/aos/externals/WPILib/WPILib/SensorBase.h
index 3f12360..58e3977 100644
--- a/aos/externals/WPILib/WPILib/SensorBase.h
+++ b/aos/externals/WPILib/WPILib/SensorBase.h
@@ -21,32 +21,32 @@
public:
SensorBase();
static void DeleteSingletons();
- static UINT32 GetDefaultAnalogModule() { return 1; }
- static UINT32 GetDefaultDigitalModule() { return 1; }
- static UINT32 GetDefaultSolenoidModule() { return 1; }
- static bool CheckAnalogModule(UINT8 moduleNumber);
- static bool CheckDigitalModule(UINT8 moduleNumber);
- static bool CheckPWMModule(UINT8 moduleNumber);
- static bool CheckRelayModule(UINT8 moduleNumber);
- static bool CheckSolenoidModule(UINT8 moduleNumber);
- static bool CheckDigitalChannel(UINT32 channel);
- static bool CheckRelayChannel(UINT32 channel);
- static bool CheckPWMChannel(UINT32 channel);
- static bool CheckAnalogChannel(UINT32 channel);
- static bool CheckSolenoidChannel(UINT32 channel);
+ static uint32_t GetDefaultAnalogModule() { return 1; }
+ static uint32_t GetDefaultDigitalModule() { return 1; }
+ static uint32_t GetDefaultSolenoidModule() { return 1; }
+ static bool CheckAnalogModule(uint8_t moduleNumber);
+ static bool CheckDigitalModule(uint8_t moduleNumber);
+ static bool CheckPWMModule(uint8_t moduleNumber);
+ static bool CheckRelayModule(uint8_t moduleNumber);
+ static bool CheckSolenoidModule(uint8_t moduleNumber);
+ static bool CheckDigitalChannel(uint32_t channel);
+ static bool CheckRelayChannel(uint32_t channel);
+ static bool CheckPWMChannel(uint32_t channel);
+ static bool CheckAnalogChannel(uint32_t channel);
+ static bool CheckSolenoidChannel(uint32_t channel);
// NOT vxworks system clock ticks (returned by sysClkRateGet() from sysLib).
// TODO: Document what this actually is (has something to do with FPGA times).
// 40kHz clock?
- static const UINT32 kSystemClockTicksPerMicrosecond = 40;
- static const UINT32 kDigitalChannels = 14;
- static const UINT32 kAnalogChannels = 8;
- static const UINT32 kAnalogModules = 2;
- static const UINT32 kDigitalModules = 2;
- static const UINT32 kSolenoidChannels = 8;
- static const UINT32 kSolenoidModules = 2;
- static const UINT32 kPwmChannels = 10;
- static const UINT32 kRelayChannels = 8;
+ static const uint32_t kSystemClockTicksPerMicrosecond = 40;
+ static const uint32_t kDigitalChannels = 14;
+ static const uint32_t kAnalogChannels = 8;
+ static const uint32_t kAnalogModules = 2;
+ static const uint32_t kDigitalModules = 2;
+ static const uint32_t kSolenoidChannels = 8;
+ static const uint32_t kSolenoidModules = 2;
+ static const uint32_t kPwmChannels = 10;
+ static const uint32_t kRelayChannels = 8;
protected:
void AddToSingletonList();
diff --git a/aos/externals/WPILib/WPILib/SerialPort.cpp b/aos/externals/WPILib/WPILib/SerialPort.cpp
index f161016..7a1047e 100644
--- a/aos/externals/WPILib/WPILib/SerialPort.cpp
+++ b/aos/externals/WPILib/WPILib/SerialPort.cpp
@@ -19,7 +19,7 @@
* @param parity Select the type of parity checking to use.
* @param stopBits The number of stop bits to use as defined by the enum StopBits.
*/
-SerialPort::SerialPort(UINT32 baudRate, UINT8 dataBits, SerialPort::Parity parity, SerialPort::StopBits stopBits)
+SerialPort::SerialPort(uint32_t baudRate, uint8_t dataBits, SerialPort::Parity parity, SerialPort::StopBits stopBits)
: m_resourceManagerHandle (0)
, m_portHandle (0)
, m_consoleModeEnabled (false)
@@ -28,7 +28,7 @@
localStatus = viOpenDefaultRM((ViSession*)&m_resourceManagerHandle);
wpi_setError(localStatus);
- localStatus = viOpen(m_resourceManagerHandle, "ASRL1::INSTR", VI_NULL, VI_NULL, (ViSession*)&m_portHandle);
+ localStatus = viOpen(m_resourceManagerHandle, const_cast<char*>("ASRL1::INSTR"), VI_NULL, VI_NULL, (ViSession*)&m_portHandle);
wpi_setError(localStatus);
if (localStatus != 0)
{
@@ -122,9 +122,9 @@
*
* @return The number of bytes available to read.
*/
-INT32 SerialPort::GetBytesReceived()
+int32_t SerialPort::GetBytesReceived()
{
- INT32 bytes = 0;
+ int32_t bytes = 0;
if (!m_consoleModeEnabled)
{
ViStatus localStatus = viGetAttribute(m_portHandle, VI_ATTR_ASRL_AVAIL_NUM, &bytes);
@@ -178,9 +178,9 @@
* @param count The maximum number of bytes to read.
* @return The number of bytes actually read into the buffer.
*/
-UINT32 SerialPort::Read(char *buffer, INT32 count)
+uint32_t SerialPort::Read(char *buffer, int32_t count)
{
- UINT32 retCount = 0;
+ uint32_t retCount = 0;
if (!m_consoleModeEnabled)
{
ViStatus localStatus = viBufRead(m_portHandle, (ViPBuf)buffer, count, (ViPUInt32)&retCount);
@@ -204,9 +204,9 @@
* @param count The maximum number of bytes to write.
* @return The number of bytes actually written into the port.
*/
-UINT32 SerialPort::Write(const char *buffer, INT32 count)
+uint32_t SerialPort::Write(const char *buffer, int32_t count)
{
- UINT32 retCount = 0;
+ uint32_t retCount = 0;
if (!m_consoleModeEnabled)
{
ViStatus localStatus = viBufWrite(m_portHandle, (ViPBuf)buffer, count, (ViPUInt32)&retCount);
@@ -227,7 +227,7 @@
{
if (!m_consoleModeEnabled)
{
- ViStatus localStatus = viSetAttribute(m_portHandle, VI_ATTR_TMO_VALUE, (UINT32)(timeout * 1e3));
+ ViStatus localStatus = viSetAttribute(m_portHandle, VI_ATTR_TMO_VALUE, (uint32_t)(timeout * 1e3));
wpi_setError(localStatus);
}
}
@@ -244,7 +244,7 @@
*
* @param size The read buffer size.
*/
-void SerialPort::SetReadBufferSize(UINT32 size)
+void SerialPort::SetReadBufferSize(uint32_t size)
{
if (!m_consoleModeEnabled)
{
@@ -261,7 +261,7 @@
*
* @param size The write buffer size.
*/
-void SerialPort::SetWriteBufferSize(UINT32 size)
+void SerialPort::SetWriteBufferSize(uint32_t size)
{
if (!m_consoleModeEnabled)
{
@@ -319,7 +319,7 @@
}
}
-//void SerialPort::_internalHandler(UINT32 port, UINT32 eventType, UINT32 event)
+//void SerialPort::_internalHandler(uint32_t port, uint32_t eventType, uint32_t event)
//{
//}
diff --git a/aos/externals/WPILib/WPILib/SerialPort.h b/aos/externals/WPILib/WPILib/SerialPort.h
index fbff896..64b7724 100644
--- a/aos/externals/WPILib/WPILib/SerialPort.h
+++ b/aos/externals/WPILib/WPILib/SerialPort.h
@@ -30,19 +30,19 @@
typedef enum {kFlowControl_None=0, kFlowControl_XonXoff=1, kFlowControl_RtsCts=2, kFlowControl_DtrDsr=4} FlowControl;
typedef enum {kFlushOnAccess=1, kFlushWhenFull=2} WriteBufferMode;
- SerialPort(UINT32 baudRate, UINT8 dataBits = 8, Parity parity = kParity_None, StopBits stopBits = kStopBits_One);
+ SerialPort(uint32_t baudRate, uint8_t dataBits = 8, Parity parity = kParity_None, StopBits stopBits = kStopBits_One);
~SerialPort();
void SetFlowControl(FlowControl flowControl);
void EnableTermination(char terminator = '\n');
void DisableTermination();
- INT32 GetBytesReceived();
+ int32_t GetBytesReceived();
void Printf(const char *writeFmt, ...);
void Scanf(const char *readFmt, ...);
- UINT32 Read(char *buffer, INT32 count);
- UINT32 Write(const char *buffer, INT32 count);
+ uint32_t Read(char *buffer, int32_t count);
+ uint32_t Write(const char *buffer, int32_t count);
void SetTimeout(float timeout);
- void SetReadBufferSize(UINT32 size);
- void SetWriteBufferSize(UINT32 size);
+ void SetReadBufferSize(uint32_t size);
+ void SetWriteBufferSize(uint32_t size);
void SetWriteBufferMode(WriteBufferMode mode);
void Flush();
void Reset();
@@ -50,10 +50,10 @@
/*
* Do not call me!
*/
- //void _internalHandler(UINT32 port, UINT32 eventType, UINT32 event);
+ //void _internalHandler(uint32_t port, uint32_t eventType, uint32_t event);
private:
- UINT32 m_resourceManagerHandle;
- UINT32 m_portHandle;
+ uint32_t m_resourceManagerHandle;
+ uint32_t m_portHandle;
bool m_consoleModeEnabled;
DISALLOW_COPY_AND_ASSIGN(SerialPort);
};
diff --git a/aos/externals/WPILib/WPILib/Servo.cpp b/aos/externals/WPILib/WPILib/Servo.cpp
index 172044f..865767e 100644
--- a/aos/externals/WPILib/WPILib/Servo.cpp
+++ b/aos/externals/WPILib/WPILib/Servo.cpp
@@ -9,8 +9,8 @@
#include "NetworkCommunication/UsageReporting.h"
#include "LiveWindow/LiveWindow.h"
-const float Servo::kMaxServoAngle;
-const float Servo::kMinServoAngle;
+constexpr float Servo::kMaxServoAngle;
+constexpr float Servo::kMinServoAngle;
/**
* Common initialization code called by all constructors.
@@ -20,8 +20,8 @@
*/
void Servo::InitServo()
{
- // TODO: compute the appropriate values based on digital loop timing
- SetBounds(245, 0, 0, 0, 11);
+ m_table = NULL;
+ SetBounds(2.27, 1.513, 1.507, 1.5, .743);
SetPeriodMultiplier(kPeriodMultiplier_4X);
@@ -34,7 +34,7 @@
*
* @param channel The PWM channel on the digital module to which the servo is attached.
*/
-Servo::Servo(UINT32 channel) : SafePWM(channel)
+Servo::Servo(uint32_t channel) : SafePWM(channel)
{
InitServo();
}
@@ -45,7 +45,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The PWM channel on the digital module to which the servo is attached (1..10).
*/
-Servo::Servo(UINT8 moduleNumber, UINT32 channel) : SafePWM(moduleNumber, channel)
+Servo::Servo(uint8_t moduleNumber, uint32_t channel) : SafePWM(moduleNumber, channel)
{
InitServo();
}
@@ -134,11 +134,15 @@
}
void Servo::StartLiveWindowMode() {
- m_table->AddTableListener("Value", this, true);
+ if (m_table != NULL) {
+ m_table->AddTableListener("Value", this, true);
+ }
}
void Servo::StopLiveWindowMode() {
- m_table->RemoveTableListener(this);
+ if (m_table != NULL) {
+ m_table->RemoveTableListener(this);
+ }
}
std::string Servo::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/Servo.h b/aos/externals/WPILib/WPILib/Servo.h
index 0d9da50..8f3f046 100644
--- a/aos/externals/WPILib/WPILib/Servo.h
+++ b/aos/externals/WPILib/WPILib/Servo.h
@@ -19,8 +19,8 @@
class Servo : public SafePWM
{
public:
- explicit Servo(UINT32 channel);
- Servo(UINT8 moduleNumber, UINT32 channel);
+ explicit Servo(uint32_t channel);
+ Servo(uint8_t moduleNumber, uint32_t channel);
virtual ~Servo();
void Set(float value);
void SetOffline();
@@ -44,8 +44,8 @@
void InitServo();
float GetServoAngleRange() {return kMaxServoAngle - kMinServoAngle;}
- static const float kMaxServoAngle = 170.0;
- static const float kMinServoAngle = 0.0;
+ static constexpr float kMaxServoAngle = 170.0;
+ static constexpr float kMinServoAngle = 0.0;
};
#endif
diff --git a/aos/externals/WPILib/WPILib/Solenoid.cpp b/aos/externals/WPILib/WPILib/Solenoid.cpp
index 7a56a09..20aab19 100644
--- a/aos/externals/WPILib/WPILib/Solenoid.cpp
+++ b/aos/externals/WPILib/WPILib/Solenoid.cpp
@@ -14,6 +14,7 @@
*/
void Solenoid::InitSolenoid()
{
+ m_table = NULL;
char buf[64];
if (!CheckSolenoidModule(m_moduleNumber))
{
@@ -46,7 +47,7 @@
*
* @param channel The channel on the solenoid module to control (1..8).
*/
-Solenoid::Solenoid(UINT32 channel)
+Solenoid::Solenoid(uint32_t channel)
: SolenoidBase (GetDefaultSolenoidModule())
, m_channel (channel)
{
@@ -59,7 +60,7 @@
* @param moduleNumber The solenoid module (1 or 2).
* @param channel The channel on the solenoid module to control (1..8).
*/
-Solenoid::Solenoid(UINT8 moduleNumber, UINT32 channel)
+Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
: SolenoidBase (moduleNumber)
, m_channel (channel)
{
@@ -86,8 +87,8 @@
void Solenoid::Set(bool on)
{
if (StatusIsFatal()) return;
- UINT8 value = on ? 0xFF : 0x00;
- UINT8 mask = 1 << (m_channel - 1);
+ uint8_t value = on ? 0xFF : 0x00;
+ uint8_t mask = 1 << (m_channel - 1);
SolenoidBase::Set(value, mask);
}
@@ -100,7 +101,7 @@
bool Solenoid::Get()
{
if (StatusIsFatal()) return false;
- UINT8 value = GetAll() & ( 1 << (m_channel - 1));
+ uint8_t value = GetAll() & ( 1 << (m_channel - 1));
return (value != 0);
}
@@ -117,12 +118,16 @@
void Solenoid::StartLiveWindowMode() {
Set(false);
- m_table->AddTableListener("Value", this, true);
+ if (m_table != NULL) {
+ m_table->AddTableListener("Value", this, true);
+ }
}
void Solenoid::StopLiveWindowMode() {
Set(false);
- m_table->RemoveTableListener(this);
+ if (m_table != NULL) {
+ m_table->RemoveTableListener(this);
+ }
}
std::string Solenoid::GetSmartDashboardType() {
diff --git a/aos/externals/WPILib/WPILib/Solenoid.h b/aos/externals/WPILib/WPILib/Solenoid.h
index 6d535c6..5c30b15 100644
--- a/aos/externals/WPILib/WPILib/Solenoid.h
+++ b/aos/externals/WPILib/WPILib/Solenoid.h
@@ -20,8 +20,8 @@
*/
class Solenoid : public SolenoidBase, public LiveWindowSendable, public ITableListener {
public:
- explicit Solenoid(UINT32 channel);
- Solenoid(UINT8 moduleNumber, UINT32 channel);
+ explicit Solenoid(uint32_t channel);
+ Solenoid(uint8_t moduleNumber, uint32_t channel);
virtual ~Solenoid();
virtual void Set(bool on);
virtual bool Get();
@@ -38,7 +38,7 @@
private:
void InitSolenoid();
- UINT32 m_channel; ///< The channel on the module to control.
+ uint32_t m_channel; ///< The channel on the module to control.
ITable *m_table;
};
diff --git a/aos/externals/WPILib/WPILib/SolenoidBase.cpp b/aos/externals/WPILib/WPILib/SolenoidBase.cpp
index 1f38869..58c0430 100644
--- a/aos/externals/WPILib/WPILib/SolenoidBase.cpp
+++ b/aos/externals/WPILib/WPILib/SolenoidBase.cpp
@@ -11,7 +11,7 @@
Resource *SolenoidBase::m_allocated = NULL;
tSolenoid *SolenoidBase::m_fpgaSolenoidModule = NULL;
-UINT32 SolenoidBase::m_refCount = 0;
+uint32_t SolenoidBase::m_refCount = 0;
/**
@@ -19,7 +19,7 @@
*
* @param moduleNumber The solenoid module (1 or 2).
*/
-SolenoidBase::SolenoidBase(UINT8 moduleNumber)
+SolenoidBase::SolenoidBase(uint8_t moduleNumber)
: m_moduleNumber (moduleNumber)
{
Synchronized sync(m_semaphore);
@@ -55,13 +55,13 @@
* @param value The value you want to set on the module.
* @param mask The channels you want to be affected.
*/
-void SolenoidBase::Set(UINT8 value, UINT8 mask)
+void SolenoidBase::Set(uint8_t value, uint8_t mask)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
if (CheckSolenoidModule(m_moduleNumber))
{
Synchronized sync(m_semaphore);
- UINT8 currentValue = m_fpgaSolenoidModule->readDO7_0(m_moduleNumber - 1, &localStatus);
+ uint8_t currentValue = m_fpgaSolenoidModule->readDO7_0(m_moduleNumber - 1, &localStatus);
// Zero out the values to change
currentValue &= ~mask;
// Actually set the values.
@@ -76,12 +76,12 @@
*
* @return The current value of all 8 solenoids on the module.
*/
-UINT8 SolenoidBase::GetAll()
+uint8_t SolenoidBase::GetAll()
{
if (CheckSolenoidModule(m_moduleNumber))
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT8 solenoids = m_fpgaSolenoidModule->readDO7_0(m_moduleNumber - 1, &localStatus);
+ uint8_t solenoids = m_fpgaSolenoidModule->readDO7_0(m_moduleNumber - 1, &localStatus);
wpi_setError(localStatus);
return solenoids;
}
diff --git a/aos/externals/WPILib/WPILib/SolenoidBase.h b/aos/externals/WPILib/WPILib/SolenoidBase.h
index a9fdf61..3b1a5cb 100644
--- a/aos/externals/WPILib/WPILib/SolenoidBase.h
+++ b/aos/externals/WPILib/WPILib/SolenoidBase.h
@@ -20,26 +20,26 @@
*/
class SolenoidBase : public SensorBase {
public:
- explicit SolenoidBase(UINT8 moduleNumber);
+ explicit SolenoidBase(uint8_t moduleNumber);
virtual ~SolenoidBase();
- void Set(UINT8 value, UINT8 mask);
+ void Set(uint8_t value, uint8_t mask);
- UINT8 GetAll();
+ uint8_t GetAll();
/**
* Set the value of all of the solenoids at the same time.
*
* @param value The values you want to set all of the solenoids to.
*/
- void SetAll(UINT8 value) { Set(value, 0xFF); }
+ void SetAll(uint8_t value) { Set(value, 0xFF); }
protected:
- UINT32 m_moduleNumber; ///< Slot number where the module is plugged into the chassis.
+ uint32_t m_moduleNumber; ///< Slot number where the module is plugged into the chassis.
static Resource *m_allocated;
private:
static tSolenoid *m_fpgaSolenoidModule; ///< FPGA Solenoid Module object.
- static UINT32 m_refCount; ///< Reference count for the chip object.
+ static uint32_t m_refCount; ///< Reference count for the chip object.
static ReentrantSemaphore m_semaphore;
};
diff --git a/aos/externals/WPILib/WPILib/SpeedController.h b/aos/externals/WPILib/WPILib/SpeedController.h
index 7fc1732..7f88646 100644
--- a/aos/externals/WPILib/WPILib/SpeedController.h
+++ b/aos/externals/WPILib/WPILib/SpeedController.h
@@ -23,7 +23,7 @@
* @param speed The speed to set. Value should be between -1.0 and 1.0.
* @param syncGroup The update group to add this Set() to, pending UpdateSyncGroup(). If 0, update immediately.
*/
- virtual void Set(float speed, UINT8 syncGroup=0) = 0;
+ virtual void Set(float speed, uint8_t syncGroup=0) = 0;
/**
* Common interface for getting the current set speed of a speed controller.
*
diff --git a/aos/externals/WPILib/WPILib/Talon.cpp b/aos/externals/WPILib/WPILib/Talon.cpp
index 42cbecf..b1081d4 100644
--- a/aos/externals/WPILib/WPILib/Talon.cpp
+++ b/aos/externals/WPILib/WPILib/Talon.cpp
@@ -25,12 +25,10 @@
* - 49 = full "reverse"
*/
void Talon::InitTalon() {
- // TODO: compute the appropriate values based on digital loop timing
- SetBounds(211, 133, 129, 125, 49);
+ SetBounds(2.037, 1.539, 1.513, 1.487, .989);
SetPeriodMultiplier(kPeriodMultiplier_2X);
SetRaw(m_centerPwm);
- // TODO: Add Talon to Usage Reporting
nUsageReporting::report(nUsageReporting::kResourceType_Talon, GetChannel(), GetModuleNumber() - 1);
LiveWindow::GetInstance()->AddActuator("Talon", GetModuleNumber(), GetChannel(), this);
}
@@ -40,7 +38,7 @@
*
* @param channel The PWM channel on the digital module that the Talon is attached to.
*/
-Talon::Talon(UINT32 channel) : SafePWM(channel)
+Talon::Talon(uint32_t channel) : SafePWM(channel)
{
InitTalon();
}
@@ -51,7 +49,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The PWM channel on the digital module that the Talon is attached to (1..10).
*/
-Talon::Talon(UINT8 moduleNumber, UINT32 channel) : SafePWM(moduleNumber, channel)
+Talon::Talon(uint8_t moduleNumber, uint32_t channel) : SafePWM(moduleNumber, channel)
{
InitTalon();
}
@@ -69,7 +67,7 @@
* @param speed The speed value between -1.0 and 1.0 to set.
* @param syncGroup Unused interface.
*/
-void Talon::Set(float speed, UINT8 syncGroup)
+void Talon::Set(float speed, uint8_t syncGroup)
{
SetSpeed(speed);
}
diff --git a/aos/externals/WPILib/WPILib/Talon.h b/aos/externals/WPILib/WPILib/Talon.h
index 66f475e..89c396c 100644
--- a/aos/externals/WPILib/WPILib/Talon.h
+++ b/aos/externals/WPILib/WPILib/Talon.h
@@ -17,10 +17,10 @@
class Talon : public SafePWM, public SpeedController
{
public:
- explicit Talon(UINT32 channel);
- Talon(UINT8 moduleNumber, UINT32 channel);
+ explicit Talon(uint32_t channel);
+ Talon(uint8_t moduleNumber, uint32_t channel);
virtual ~Talon();
- virtual void Set(float value, UINT8 syncGroup=0);
+ virtual void Set(float value, uint8_t syncGroup=0);
virtual float Get();
virtual void Disable();
diff --git a/aos/externals/WPILib/WPILib/Task.cpp b/aos/externals/WPILib/WPILib/Task.cpp
index 37f7d2f..c159202 100644
--- a/aos/externals/WPILib/WPILib/Task.cpp
+++ b/aos/externals/WPILib/WPILib/Task.cpp
@@ -13,8 +13,8 @@
#include <taskLib.h>
#include <usrLib.h>
-const UINT32 Task::kDefaultPriority;
-const INT32 Task::kInvalidTaskID;
+const uint32_t Task::kDefaultPriority;
+const int32_t Task::kInvalidTaskID;
/**
* Create but don't launch a task.
@@ -24,7 +24,7 @@
* @param priority The VxWorks priority for the task.
* @param stackSize The size of the stack for the task
*/
-Task::Task(const char* name, FUNCPTR function, INT32 priority, UINT32 stackSize)
+Task::Task(const char* name, FUNCPTR function, int32_t priority, uint32_t stackSize)
{
m_taskID = kInvalidTaskID;
m_function = function;
@@ -34,7 +34,7 @@
strcpy(m_taskName, "FRC_");
strcpy(m_taskName+4, name);
- static INT32 instances = 0;
+ static int32_t instances = 0;
instances++;
nUsageReporting::report(nUsageReporting::kResourceType_Task, instances, 0, m_taskName);
}
@@ -54,8 +54,8 @@
* Does not use any floating point registers.
* @return true on success
*/
-bool Task::Start(UINT32 arg0, UINT32 arg1, UINT32 arg2, UINT32 arg3, UINT32 arg4,
- UINT32 arg5, UINT32 arg6, UINT32 arg7, UINT32 arg8, UINT32 arg9)
+bool Task::Start(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
+ uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8, uint32_t arg9)
{
// Don't have to lock m_prioritySemaphore because this code isn't changing it.
m_taskID = taskSpawn(m_taskName,
@@ -149,7 +149,7 @@
* Gets the priority of a task.
* @returns task priority or 0 if an error occured
*/
-INT32 Task::GetPriority()
+int32_t Task::GetPriority()
{
Synchronized sync(m_prioritySemaphore);
if (HandleError(taskPriorityGet(m_taskID, &m_priority)))
@@ -165,7 +165,7 @@
* @param priority The priority the task should run at.
* @returns true on success.
*/
-bool Task::SetPriority(INT32 priority)
+bool Task::SetPriority(int32_t priority)
{
Synchronized sync(m_prioritySemaphore);
m_priority = priority;
@@ -185,7 +185,7 @@
* Get the ID of a task
* @returns Task ID of this task. Task::kInvalidTaskID (-1) if the task has not been started or has already exited.
*/
-INT32 Task::GetID()
+int32_t Task::GetID()
{
if (Verify())
return m_taskID;
diff --git a/aos/externals/WPILib/WPILib/Task.h b/aos/externals/WPILib/WPILib/Task.h
index d1ad259..dbd9295 100644
--- a/aos/externals/WPILib/WPILib/Task.h
+++ b/aos/externals/WPILib/WPILib/Task.h
@@ -21,14 +21,14 @@
class Task : public ErrorBase
{
public:
- static const UINT32 kDefaultPriority = 101;
- static const INT32 kInvalidTaskID = -1;
+ static const uint32_t kDefaultPriority = 101;
+ static const int32_t kInvalidTaskID = -1;
- Task(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
+ Task(const char* name, FUNCPTR function, int32_t priority = kDefaultPriority, uint32_t stackSize = 20000);
virtual ~Task();
- bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0,
- UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0, UINT32 arg9 = 0);
+ bool Start(uint32_t arg0 = 0, uint32_t arg1 = 0, uint32_t arg2 = 0, uint32_t arg3 = 0, uint32_t arg4 = 0,
+ uint32_t arg5 = 0, uint32_t arg6 = 0, uint32_t arg7 = 0, uint32_t arg8 = 0, uint32_t arg9 = 0);
bool Restart();
bool Stop();
@@ -40,17 +40,17 @@
bool Verify();
- INT32 GetPriority();
- bool SetPriority(INT32 priority);
+ int32_t GetPriority();
+ bool SetPriority(int32_t priority);
const char* GetName();
- INT32 GetID();
+ int32_t GetID();
private:
FUNCPTR m_function;
char* m_taskName;
- INT32 m_taskID;
- UINT32 m_stackSize;
- INT32 m_priority;
+ int32_t m_taskID;
+ uint32_t m_stackSize;
+ int m_priority;
ReentrantSemaphore m_prioritySemaphore;
bool HandleError(STATUS results);
DISALLOW_COPY_AND_ASSIGN(Task);
diff --git a/aos/externals/WPILib/WPILib/Timer.cpp b/aos/externals/WPILib/WPILib/Timer.cpp
index 7638b59..576858e 100644
--- a/aos/externals/WPILib/WPILib/Timer.cpp
+++ b/aos/externals/WPILib/WPILib/Timer.cpp
@@ -26,7 +26,7 @@
void Wait(double seconds)
{
if (seconds < 0.0) return;
- taskDelay((INT32)((double)sysClkRateGet() * seconds));
+ taskDelay((int32_t)((double)sysClkRateGet() * seconds));
}
/*
@@ -143,7 +143,7 @@
Synchronized sync(m_semaphore);
if (m_running)
{
- m_accumulatedTime += temp;
+ m_accumulatedTime = temp;
m_running = false;
}
}
@@ -187,8 +187,8 @@
// Internal function that reads the PPC timestamp counter.
extern "C"
{
- UINT32 niTimestamp32(void);
- UINT64 niTimestamp64(void);
+ uint32_t niTimestamp32(void);
+ uint64_t niTimestamp64(void);
}
/*
diff --git a/aos/externals/WPILib/WPILib/Ultrasonic.cpp b/aos/externals/WPILib/WPILib/Ultrasonic.cpp
index c896a32..19b773b 100644
--- a/aos/externals/WPILib/WPILib/Ultrasonic.cpp
+++ b/aos/externals/WPILib/WPILib/Ultrasonic.cpp
@@ -15,10 +15,10 @@
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
-const double Ultrasonic::kPingTime; ///< Time (sec) for the ping trigger pulse.
-const UINT32 Ultrasonic::kPriority; ///< Priority that the ultrasonic round robin task runs.
-const double Ultrasonic::kMaxUltrasonicTime; ///< Max time (ms) between readings.
-const double Ultrasonic::kSpeedOfSoundInchesPerSec;
+constexpr double Ultrasonic::kPingTime; ///< Time (sec) for the ping trigger pulse.
+const uint32_t Ultrasonic::kPriority; ///< Priority that the ultrasonic round robin task runs.
+constexpr double Ultrasonic::kMaxUltrasonicTime; ///< Max time (ms) between readings.
+constexpr double Ultrasonic::kSpeedOfSoundInchesPerSec;
Task Ultrasonic::m_task("UltrasonicChecker", (FUNCPTR)UltrasonicChecker); // task doing the round-robin automatic sensing
Ultrasonic *Ultrasonic::m_firstSensor = NULL; // head of the ultrasonic sensor list
bool Ultrasonic::m_automaticEnabled = false; // automatic round robin mode
@@ -56,6 +56,7 @@
*/
void Ultrasonic::Initialize()
{
+ m_table = NULL;
bool originalMode = m_automaticEnabled;
if (m_semaphore == 0) m_semaphore = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
SetAutomaticMode(false); // kill task when adding a new sensor
@@ -90,7 +91,7 @@
* echo is high represents the round trip time of the ping, and the distance.
* @param units The units returned in either kInches or kMilliMeters
*/
-Ultrasonic::Ultrasonic(UINT32 pingChannel, UINT32 echoChannel, DistanceUnit units)
+Ultrasonic::Ultrasonic(uint32_t pingChannel, uint32_t echoChannel, DistanceUnit units)
{
m_pingChannel = new DigitalOutput(pingChannel);
m_echoChannel = new DigitalInput(echoChannel);
@@ -148,8 +149,8 @@
* that the echo is high represents the round trip time of the ping, and the distance.
* @param units The units returned in either kInches or kMilliMeters
*/
-Ultrasonic::Ultrasonic(UINT8 pingModuleNumber, UINT32 pingChannel,
- UINT8 echoModuleNumber, UINT32 echoChannel, DistanceUnit units)
+Ultrasonic::Ultrasonic(uint8_t pingModuleNumber, uint32_t pingChannel,
+ uint8_t echoModuleNumber, uint32_t echoChannel, DistanceUnit units)
{
m_pingChannel = new DigitalOutput(pingModuleNumber, pingChannel);
m_echoChannel = new DigitalInput(echoModuleNumber, echoChannel);
diff --git a/aos/externals/WPILib/WPILib/Ultrasonic.h b/aos/externals/WPILib/WPILib/Ultrasonic.h
index 08a4788..3d7fba3 100644
--- a/aos/externals/WPILib/WPILib/Ultrasonic.h
+++ b/aos/externals/WPILib/WPILib/Ultrasonic.h
@@ -36,9 +36,9 @@
Ultrasonic(DigitalOutput *pingChannel, DigitalInput *echoChannel, DistanceUnit units = kInches);
Ultrasonic(DigitalOutput &pingChannel, DigitalInput &echoChannel, DistanceUnit units = kInches);
- Ultrasonic(UINT32 pingChannel, UINT32 echoChannel, DistanceUnit units = kInches);
- Ultrasonic(UINT8 pingModuleNumber, UINT32 pingChannel,
- UINT8 echoModuleNumber, UINT32 echoChannel, DistanceUnit units = kInches);
+ Ultrasonic(uint32_t pingChannel, uint32_t echoChannel, DistanceUnit units = kInches);
+ Ultrasonic(uint8_t pingModuleNumber, uint32_t pingChannel,
+ uint8_t echoModuleNumber, uint32_t echoChannel, DistanceUnit units = kInches);
virtual ~Ultrasonic();
void Ping();
@@ -65,10 +65,10 @@
static void UltrasonicChecker();
- static const double kPingTime = 10 * 1e-6; ///< Time (sec) for the ping trigger pulse.
- static const UINT32 kPriority = 90; ///< Priority that the ultrasonic round robin task runs.
- static const double kMaxUltrasonicTime = 0.1; ///< Max time (ms) between readings.
- static const double kSpeedOfSoundInchesPerSec = 1130.0 * 12.0;
+ static constexpr double kPingTime = 10 * 1e-6; ///< Time (sec) for the ping trigger pulse.
+ static const uint32_t kPriority = 90; ///< Priority that the ultrasonic round robin task runs.
+ static constexpr double kMaxUltrasonicTime = 0.1; ///< Max time (ms) between readings.
+ static constexpr double kSpeedOfSoundInchesPerSec = 1130.0 * 12.0;
static Task m_task; // task doing the round-robin automatic sensing
static Ultrasonic *m_firstSensor; // head of the ultrasonic sensor list
diff --git a/aos/externals/WPILib/WPILib/Utility.cpp b/aos/externals/WPILib/WPILib/Utility.cpp
index 680da97..2ace5da 100644
--- a/aos/externals/WPILib/WPILib/Utility.cpp
+++ b/aos/externals/WPILib/WPILib/Utility.cpp
@@ -18,12 +18,12 @@
extern "C"
{
- extern char * cplusDemangle (char *source, char *dest, INT32 n);
+ extern char * cplusDemangle (char *source, char *dest, int32_t n);
}
-void wpi_getLabel(UINT addr, char *label, INT32 *found)
+void wpi_getLabel(UINT addr, char *label, int32_t *found)
{
- INT32 pVal;
+ int pVal;
SYM_TYPE pType;
char name[MAX_SYS_SYM_LEN + 1];
static const size_t kLabelSize = DBG_DEMANGLE_PRINT_LEN + 1 + 11;
@@ -49,12 +49,12 @@
}
}
/*
-static void wpiTracePrint(INSTR *caller, INT32 func, INT32 nargs, INT32 *args, INT32 taskId, BOOL isKernelAdrs)
+static void wpiTracePrint(INSTR *caller, int32_t func, int32_t nargs, int32_t *args, int32_t taskId, BOOL isKernelAdrs)
{
char buf [MAX_SYS_SYM_LEN * 2];
- INT32 ix;
- INT32 len = 0;
- len += snprintf (&buf [len], sizeof(buf) - len, "%s <%#010x>: ", wpi_getLabel((UINT)caller), (INT32)caller);
+ int32_t ix;
+ int32_t len = 0;
+ len += snprintf (&buf [len], sizeof(buf) - len, "%s <%#010x>: ", wpi_getLabel((UINT)caller), (int32_t)caller);
len += snprintf (&buf [len], sizeof(buf) - len, "%s <%#010x> (", wpi_getLabel((UINT)func), func);
for (ix = 0; ix < nargs; ix++)
{
@@ -68,14 +68,14 @@
printf(buf);
}
*/
-static void wpiCleanTracePrint(INSTR *caller, INT32 func, INT32 nargs, INT32 *args, INT32 taskId, BOOL isKernelAdrs)
+static void wpiCleanTracePrint(INSTR *caller, int32_t func, int32_t nargs, int32_t *args, int32_t taskId, BOOL isKernelAdrs)
{
char buf [MAX_SYS_SYM_LEN];
- INT32 ix;
- INT32 len = 0;
- INT32 nameFound = 0;
- INT32 params = 0;
- INT32 totalnargs = nargs;
+ int32_t ix;
+ int32_t len = 0;
+ int32_t nameFound = 0;
+ int32_t params = 0;
+ int32_t totalnargs = nargs;
char funcName[DBG_DEMANGLE_PRINT_LEN + 1 + 11];
wpi_getLabel((UINT)func, funcName, &nameFound);
// Ignore names that are not exact symbol address matches.
@@ -112,7 +112,7 @@
// If this is a member function, print out the this pointer value.
if (totalnargs - params == 1)
{
- len += snprintf (buf + len, sizeof(buf) - len, "<this=%#x>", args [0]);
+ len += snprintf (&buf [len], sizeof(buf) - len, "<this=%#lx>", args [0]);
}
// Print out the argument values.
@@ -120,9 +120,9 @@
for (ix = totalnargs - params; ix < nargs; ix++)
{
if (ix != totalnargs - params) {
- len += snprintf (buf + len, sizeof(buf) - len, ", ");
+ len += snprintf (&buf [len], sizeof(buf) - len, ", ");
}
- len += snprintf (buf + len, sizeof(buf) - len, "%#x", args [ix]);
+ len += snprintf (&buf [len], sizeof(buf) - len, "%#lx", args [ix]);
}
len += snprintf (buf + len, sizeof(buf) - len, ")\n");
@@ -131,10 +131,10 @@
extern "C"
{
- extern void trcStack(REG_SET* pRegs, FUNCPTR printRtn, INT32 tid);
+ extern void trcStack(REG_SET* pRegs, FUNCPTR printRtn, int32_t tid);
}
-static INT32 wpiStackTask(INT32 taskId)
+static int32_t wpiStackTask(int32_t taskId)
{
// Make sure it's suspended in spite of any scheduler weirdness or whatever.
while (!taskIsSuspended(taskId)) {
@@ -155,7 +155,7 @@
void wpi_selfTrace()
{
- INT32 priority=100;
+ int priority=100;
taskPriorityGet(0, &priority);
// Lower priority than the calling task.
Task traceTask("StackTrace", (FUNCPTR)wpiStackTask, priority + 1);
@@ -206,7 +206,7 @@
const char *conditionText,
const char *message,
const char *fileName,
- UINT32 lineNumber,
+ uint32_t lineNumber,
const char *funcName)
{
if (!conditionValue)
@@ -217,10 +217,10 @@
// If an error message was specified, include it
// Build error string
if(message != NULL) {
- snprintf(error, sizeof(error), "Assertion failed: \"%s\", \"%s\" failed in %s() in %s at line %d\n",
+ snprintf(error, sizeof(error), "Assertion failed: \"%s\", \"%s\" failed in %s() in %s at line %ld\n",
message, conditionText, funcName, fileName, lineNumber);
} else {
- snprintf(error, sizeof(error), "Assertion failed: \"%s\" in %s() in %s at line %d\n",
+ snprintf(error, sizeof(error), "Assertion failed: \"%s\" in %s() in %s at line %ld\n",
conditionText, funcName, fileName, lineNumber);
}
@@ -244,7 +244,7 @@
const char *equalityType,
const char *message,
const char *fileName,
- UINT32 lineNumber,
+ uint32_t lineNumber,
const char *funcName)
{
// Error string buffer
@@ -253,10 +253,10 @@
// If an error message was specified, include it
// Build error string
if(message != NULL) {
- snprintf(error, sizeof(error), "Assertion failed: \"%s\", \"%d\" %s \"%d\" in %s() in %s at line %d\n",
+ snprintf(error, sizeof(error), "Assertion failed: \"%s\", \"%d\" %s \"%d\" in %s() in %s at line %ld\n",
message, valueA, equalityType, valueB, funcName, fileName, lineNumber);
} else {
- snprintf(error, sizeof(error), "Assertion failed: \"%d\" %s \"%d\" in %s() in %s at line %d\n",
+ snprintf(error, sizeof(error), "Assertion failed: \"%d\" %s \"%d\" in %s() in %s at line %ld\n",
valueA, equalityType, valueB, funcName, fileName, lineNumber);
}
@@ -278,7 +278,7 @@
int valueB,
const char *message,
const char *fileName,
- UINT32 lineNumber,
+ uint32_t lineNumber,
const char *funcName)
{
if(!(valueA == valueB))
@@ -298,7 +298,7 @@
int valueB,
const char *message,
const char *fileName,
- UINT32 lineNumber,
+ uint32_t lineNumber,
const char *funcName)
{
if(!(valueA != valueB))
diff --git a/aos/externals/WPILib/WPILib/Utility.h b/aos/externals/WPILib/WPILib/Utility.h
index 4462b7c..bb6d0d0 100644
--- a/aos/externals/WPILib/WPILib/Utility.h
+++ b/aos/externals/WPILib/WPILib/Utility.h
@@ -18,12 +18,12 @@
#define wpi_assertNotEqual(a, b) wpi_assertNotEqual_impl(a, b, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqualWithMessage(a, b, message) wpi_assertNotEqual_impl(a, b, message, __FILE__, __LINE__, __FUNCTION__)
-bool wpi_assert_impl(bool conditionValue, const char *conditionText, const char *message, const char *fileName, UINT32 lineNumber, const char *funcName);
-bool wpi_assertEqual_impl(int valueA, int valueB, const char *message, const char *fileName,UINT32 lineNumber, const char *funcName);
-bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *message, const char *fileName,UINT32 lineNumber, const char *funcName);
+bool wpi_assert_impl(bool conditionValue, const char *conditionText, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName);
+bool wpi_assertEqual_impl(int valueA, int valueB, const char *message, const char *fileName,uint32_t lineNumber, const char *funcName);
+bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *message, const char *fileName,uint32_t lineNumber, const char *funcName);
// Will use up to (DBG_DEMANGLE_PRINT_LEN + 1 + 11) of label.
-void wpi_getLabel(UINT addr, char *label, INT32 *found = NULL);
+void wpi_getLabel(UINT addr, char *label, int32_t *found = NULL);
void wpi_selfTrace();
void wpi_suspendOnAssertEnabled(bool enabled);
void wpi_stackTraceOnAssertEnable(bool enabled);
diff --git a/aos/externals/WPILib/WPILib/Victor.cpp b/aos/externals/WPILib/WPILib/Victor.cpp
index 68c649c..c8a0565 100644
--- a/aos/externals/WPILib/WPILib/Victor.cpp
+++ b/aos/externals/WPILib/WPILib/Victor.cpp
@@ -26,8 +26,8 @@
* - 56 = full "reverse"
*/
void Victor::InitVictor() {
- // TODO: compute the appropriate values based on digital loop timing
- SetBounds(206, 131, 128, 125, 56);
+ SetBounds(2.027, 1.525, 1.507, 1.49, 1.026);
+
SetPeriodMultiplier(kPeriodMultiplier_2X);
SetRaw(m_centerPwm);
@@ -40,7 +40,7 @@
*
* @param channel The PWM channel on the digital module that the Victor is attached to.
*/
-Victor::Victor(UINT32 channel) : SafePWM(channel)
+Victor::Victor(uint32_t channel) : SafePWM(channel)
{
InitVictor();
}
@@ -51,7 +51,7 @@
* @param moduleNumber The digital module (1 or 2).
* @param channel The PWM channel on the digital module that the Victor is attached to (1..10).
*/
-Victor::Victor(UINT8 moduleNumber, UINT32 channel) : SafePWM(moduleNumber, channel)
+Victor::Victor(uint8_t moduleNumber, uint32_t channel) : SafePWM(moduleNumber, channel)
{
InitVictor();
}
@@ -69,7 +69,7 @@
* @param speed The speed value between -1.0 and 1.0 to set.
* @param syncGroup Unused interface.
*/
-void Victor::Set(float speed, UINT8 syncGroup)
+void Victor::Set(float speed, uint8_t syncGroup)
{
SetSpeed(speed);
}
diff --git a/aos/externals/WPILib/WPILib/Victor.h b/aos/externals/WPILib/WPILib/Victor.h
index 6aab0a9..e140db3 100644
--- a/aos/externals/WPILib/WPILib/Victor.h
+++ b/aos/externals/WPILib/WPILib/Victor.h
@@ -17,10 +17,10 @@
class Victor : public SafePWM, public SpeedController
{
public:
- explicit Victor(UINT32 channel);
- Victor(UINT8 moduleNumber, UINT32 channel);
+ explicit Victor(uint32_t channel);
+ Victor(uint8_t moduleNumber, uint32_t channel);
virtual ~Victor();
- virtual void Set(float value, UINT8 syncGroup=0);
+ virtual void Set(float value, uint8_t syncGroup=0);
virtual float Get();
virtual void Disable();
diff --git a/aos/externals/WPILib/WPILib/Vision/AxisCamera.cpp b/aos/externals/WPILib/WPILib/Vision/AxisCamera.cpp
index 7cd20f4..ef8a57d 100644
--- a/aos/externals/WPILib/WPILib/Vision/AxisCamera.cpp
+++ b/aos/externals/WPILib/WPILib/Vision/AxisCamera.cpp
@@ -13,7 +13,7 @@
#include "WPIErrors.h"
/** Private NI function to decode JPEG */
-IMAQ_FUNC int Priv_ReadJPEGString_C(Image* _image, const unsigned char* _string, UINT32 _stringLength);
+IMAQ_FUNC int Priv_ReadJPEGString_C(Image* _image, const unsigned char* _string, uint32_t _stringLength);
// Max packet without jumbo frames is 1500... add 36 because??
#define kMaxPacketSize 1536
@@ -234,6 +234,7 @@
ReadImagesFromCamera();
}
}
+ return 0;
}
/**
diff --git a/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.cpp b/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.cpp
index c537271..5cc2f8d 100644
--- a/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.cpp
+++ b/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.cpp
@@ -51,7 +51,7 @@
#else
DriverStation *ds = DriverStation::GetInstance();
ds->WaitForData();
- UINT16 teamNumber = ds->GetTeamNumber();
+ uint16_t teamNumber = ds->GetTeamNumber();
char cameraIP[16];
snprintf(cameraIP, 16, "10.%d.%d.11", teamNumber / 100, teamNumber % 100);
m_ipAddress = inet_addr(cameraIP);
@@ -353,7 +353,7 @@
*/
int AxisCameraParams::UpdateCamParam(const char* param)
{
- char *requestString =
+ const char *requestString =
"GET /axis-cgi/admin/param.cgi?action=update&%s HTTP/1.1\n\
User-Agent: HTTPStreamClient\n\
Connection: Keep-Alive\n\
@@ -378,7 +378,7 @@
*/
int AxisCameraParams::ReadCamParams()
{
- char * requestString =
+ const char * requestString =
"GET /axis-cgi/admin/param.cgi?action=list HTTP/1.1\n\
User-Agent: HTTPStreamClient\n\
Connection: Keep-Alive\n\
diff --git a/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.h b/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.h
index a98b007..4e1f35e 100644
--- a/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.h
+++ b/aos/externals/WPILib/WPILib/Vision/AxisCameraParams.h
@@ -23,10 +23,10 @@
class AxisCameraParams : public ErrorBase
{
public:
- typedef enum Exposure_t {kExposure_Automatic, kExposure_Hold, kExposure_FlickerFree50Hz, kExposure_FlickerFree60Hz};
- typedef enum WhiteBalance_t {kWhiteBalance_Automatic, kWhiteBalance_Hold, kWhiteBalance_FixedOutdoor1, kWhiteBalance_FixedOutdoor2, kWhiteBalance_FixedIndoor, kWhiteBalance_FixedFlourescent1, kWhiteBalance_FixedFlourescent2};
- typedef enum Resolution_t {kResolution_640x480, kResolution_640x360, kResolution_320x240, kResolution_160x120};
- typedef enum Rotation_t {kRotation_0, kRotation_180};
+ typedef enum Exposure_t {kExposure_Automatic, kExposure_Hold, kExposure_FlickerFree50Hz, kExposure_FlickerFree60Hz} Exposure;
+ typedef enum WhiteBalance_t {kWhiteBalance_Automatic, kWhiteBalance_Hold, kWhiteBalance_FixedOutdoor1, kWhiteBalance_FixedOutdoor2, kWhiteBalance_FixedIndoor, kWhiteBalance_FixedFlourescent1, kWhiteBalance_FixedFlourescent2} WhiteBalance;
+ typedef enum Resolution_t {kResolution_640x480, kResolution_640x360, kResolution_320x240, kResolution_160x120} Resolution;
+ typedef enum Rotation_t {kRotation_0, kRotation_180} Rotation;
protected:
AxisCameraParams(const char* ipAddress);
@@ -66,7 +66,7 @@
int ReadCamParams();
Task m_paramTask;
- UINT32 m_ipAddress; // IPv4
+ uint32_t m_ipAddress; // IPv4
SEM_ID m_paramChangedSem;
SEM_ID m_socketPossessionSem;
diff --git a/aos/externals/WPILib/WPILib/Vision/BinaryImage.cpp b/aos/externals/WPILib/WPILib/Vision/BinaryImage.cpp
index 55c8802..f4cd1bb 100644
--- a/aos/externals/WPILib/WPILib/Vision/BinaryImage.cpp
+++ b/aos/externals/WPILib/WPILib/Vision/BinaryImage.cpp
@@ -6,9 +6,10 @@
#include "BinaryImage.h"
#include "WPIErrors.h"
+#include <cstring>
/** Private NI function needed to write to the VxWorks target */
-IMAQ_FUNC int Priv_SetWriteFileAllowed(UINT32 enable);
+IMAQ_FUNC int Priv_SetWriteFileAllowed(uint32_t enable);
BinaryImage::BinaryImage() : MonoImage()
{
diff --git a/aos/externals/WPILib/WPILib/Vision/ImageBase.cpp b/aos/externals/WPILib/WPILib/Vision/ImageBase.cpp
index 9ec70f3..769d2bc 100644
--- a/aos/externals/WPILib/WPILib/Vision/ImageBase.cpp
+++ b/aos/externals/WPILib/WPILib/Vision/ImageBase.cpp
@@ -8,7 +8,7 @@
#include "nivision.h"
/** Private NI function needed to write to the VxWorks target */
-IMAQ_FUNC int Priv_SetWriteFileAllowed(UINT32 enable);
+IMAQ_FUNC int Priv_SetWriteFileAllowed(uint32_t enable);
/**
* Create a new instance of an ImageBase.
diff --git a/aos/externals/WPILib/WPILib/Vision/IntCameraParameter.h b/aos/externals/WPILib/WPILib/Vision/IntCameraParameter.h
index d3bc5ef..f47ec53 100644
--- a/aos/externals/WPILib/WPILib/Vision/IntCameraParameter.h
+++ b/aos/externals/WPILib/WPILib/Vision/IntCameraParameter.h
@@ -26,6 +26,7 @@
public:
IntCameraParameter(const char *setString, const char *getString, bool requiresRestart);
+ virtual ~IntCameraParameter(){}
int GetValue();
void SetValue(int value);
virtual bool CheckChanged(bool &changed, char *param);
diff --git a/aos/externals/WPILib/WPILib/Vision/PCVideoServer.cpp b/aos/externals/WPILib/WPILib/Vision/PCVideoServer.cpp
index 4cae9d0..8b754b3 100644
--- a/aos/externals/WPILib/WPILib/Vision/PCVideoServer.cpp
+++ b/aos/externals/WPILib/WPILib/Vision/PCVideoServer.cpp
@@ -12,6 +12,7 @@
#include <hostLib.h>
#include <inetLib.h>
#include <sockLib.h>
+#include <cstring>
#include "NetworkCommunication/UsageReporting.h"
#include "Task.h"
diff --git a/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.cpp b/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.cpp
index d5e48cc..dbb337a 100644
--- a/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.cpp
+++ b/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.cpp
@@ -35,11 +35,14 @@
#include "Timer.h"
#include "VisionAPI.h"
+#include <cstring>
+#include <cstdio>
+
/** packet size */
#define DEFAULT_PACKET_SIZE 512
/** Private NI function to decode JPEG */
-IMAQ_FUNC int Priv_ReadJPEGString_C(Image* _image, const unsigned char* _string, UINT32 _stringLength);
+IMAQ_FUNC int Priv_ReadJPEGString_C(Image* _image, const unsigned char* _string, uint32_t _stringLength);
// To locally enable debug printing: set AxisCamera_debugFlag to a 1, to disable set to 0
int AxisCamera_debugFlag = 0;
@@ -286,7 +289,7 @@
* @param socket Socket to close
* @return error
*/
-int CameraCloseSocket(char *errstring, int socket)
+int CameraCloseSocket(const char *errstring, int socket)
{
DPRINTF (LOG_CRITICAL, "Closing socket - CAMERA ERROR: %s", errstring );
close (socket);
@@ -485,12 +488,12 @@
*/
int ConfigureCamera(char *configString){
char funcName[]="ConfigureCamera";
- char *serverName = "192.168.0.90"; /* camera @ */
+ const char *serverName = "192.168.0.90"; /* camera @ */
int success = 0;
int camSock = 0;
/* Generate camera configuration string */
- char * getStr1 =
+ const char * getStr1 =
"GET /axis-cgi/admin/param.cgi?action=update&ImageSource.I0.Sensor.";
char cameraRequest[strlen(getStr1) + strlen(configString)];
@@ -525,12 +528,12 @@
* @return success: 0=failure; 1=success
*/
int GetCameraSetting(char *configString, char *cameraResponse){
- char *serverName = "192.168.0.90"; /* camera @ */
+ const char *serverName = "192.168.0.90"; /* camera @ */
int success = 0;
int camSock = 0;
/* Generate camera request string */
- char * getStr1 =
+ const char * getStr1 =
"GET /axis-cgi/admin/param.cgi?action=list&group=ImageSource.I0.Sensor.";
char cameraRequest[strlen(getStr1) + strlen(configString)];
sprintf (cameraRequest, "%s%s", getStr1, configString);
@@ -558,12 +561,12 @@
* @return success: 0=failure; 1=success
*/
int GetImageSetting(char *configString, char *cameraResponse){
- char *serverName = "192.168.0.90"; /* camera @ */
+ const char *serverName = "192.168.0.90"; /* camera @ */
int success = 0;
int camSock = 0;
/* Generate camera request string */
- char *getStr1 = "GET /axis-cgi/admin/param.cgi?action=list&group=Image.I0.Appearance.";
+ const char *getStr1 = "GET /axis-cgi/admin/param.cgi?action=list&group=Image.I0.Appearance.";
char cameraRequest[strlen(getStr1) + strlen(configString)];
sprintf (cameraRequest, "%s%s", getStr1, configString);
DPRINTF(LOG_DEBUG, "camera configuration string: \n%s", cameraRequest);
@@ -596,7 +599,7 @@
int cameraJPEGServer(int frames, int compression, ImageResolution resolution, ImageRotation rotation)
{
char funcName[]="cameraJPEGServer";
- char *serverName = "192.168.0.90"; /* camera @ */
+ char serverName[] = "192.168.0.90"; /* camera @ */
cont = 1;
int errorCode = 0;
int printCounter = 0;
@@ -627,14 +630,14 @@
/* Generate camera initialization string */
/* changed resolution to 160x120 from 320x240 */
/* supported resolutions are: 640x480, 640x360, 320x240, 160x120 */
- char * getStr1 =
+ const char * getStr1 =
"GET /axis-cgi/mjpg/video.cgi?showlength=1&camera=1&";
char insertStr[100];
sprintf (insertStr, "des_fps=%i&compression=%i&resolution=%s&rotation=%i",
frames, compression, resStr, (int)rotation);
- char * getStr2 = " HTTP/1.1\n\
+ const char * getStr2 = " HTTP/1.1\n\
User-Agent: HTTPStreamClient\n\
Host: 192.150.1.100\n\
Connection: Keep-Alive\n\
@@ -683,7 +686,7 @@
DPRINTF (LOG_DEBUG, "getting IP" );
if (( (int)(cameraAddr.sin_addr.s_addr = inet_addr (serverName) ) == ERROR) &&
- ( (int)(cameraAddr.sin_addr.s_addr = hostGetByName (serverName) ) == ERROR))
+ ( (int)(cameraAddr.sin_addr.s_addr = hostGetByName (serverName) ) == ERROR))
{
CameraCloseSocket("Failed to get IP, check hostname or IP", camSock);
continue;
@@ -714,8 +717,8 @@
//DPRINTF (LOG_DEBUG, "reading header" );
/* Find content-length, then read that many bytes */
int counter = 2;
- char* contentString = "Content-Length: ";
- char* authorizeString = "200 OK";
+ const char* contentString = "Content-Length: ";
+ const char* authorizeString = "200 OK";
#define MEASURE_TIME 0
#if MEASURE_TIME
@@ -846,10 +849,14 @@
/* signal a listening task */
if (globalCamera.readerPID) {
if (taskKill (globalCamera.readerPID,SIGUSR1) == OK)
+ {
DPRINTF (LOG_DEBUG, "SIGNALING PID= %i", globalCamera.readerPID);
+ }
else
+ {
globalCamera.cameraMetrics[CAM_PID_SIGNAL_ERR]++;
DPRINTF (LOG_DEBUG, "ERROR SIGNALING PID= %i", globalCamera.readerPID);
+ }
}
globalCamera.cameraMetrics[CAM_NUM_IMAGE]++;
diff --git a/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.h b/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.h
index a6b21d0..16815a8 100644
--- a/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.h
+++ b/aos/externals/WPILib/WPILib/Vision2009/AxisCamera.h
@@ -44,7 +44,7 @@
#define CAM_NUM_METRICS 17
/** Private NI function needed to write to the VxWorks target */
-IMAQ_FUNC int Priv_SetWriteFileAllowed(UINT32 enable);
+IMAQ_FUNC int Priv_SetWriteFileAllowed(uint32_t enable);
/**
@brief Possible image sizes that you can set on the camera.
diff --git a/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.cpp b/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.cpp
index 6515893..4be8275 100644
--- a/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.cpp
+++ b/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.cpp
@@ -47,21 +47,21 @@
* The file line number will also be printed.
* @param tempString The format string.
*/
-void dprintf ( char * tempString, ... ) /* Variable argument list */
+void dprintf ( const char * tempString, ... ) /* Variable argument list */
{
- va_list args; /* Input argument list */
- int line_number; /* Line number passed in argument */
- int type;
- char *functionName; /* Format passed in argument */
- char *fmt; /* Format passed in argument */
- char text[512]; /* Text string */
- char outtext[512]; /* Text string */
- FILE *outfile_fd; /* Output file pointer */
- char filepath[128]; /* Text string */
- int fatalFlag=0;
- char *filename;
- int index;
- int tempStringLen;
+ va_list args; /* Input argument list */
+ int line_number; /* Line number passed in argument */
+ int type;
+ const char *functionName; /* Format passed in argument */
+ const char *fmt; /* Format passed in argument */
+ char text[512]; /* Text string */
+ char outtext[512]; /* Text string */
+ FILE *outfile_fd; /* Output file pointer */
+ char filepath[128]; /* Text string */
+ int fatalFlag=0;
+ const char *filename;
+ int index;
+ int tempStringLen;
if (dprintfFlag == DEBUG_OFF) { return; }
@@ -78,7 +78,7 @@
}
/* Extract function name */
- functionName = va_arg (args, char *);
+ functionName = va_arg (args, const char *);
/* Extract line number from argument list */
line_number = va_arg (args, int);
@@ -87,7 +87,7 @@
type = va_arg (args, int);
/* Extract format from argument list */
- fmt = va_arg (args, char *);
+ fmt = va_arg (args, const char *);
vsprintf (text, fmt, args);
@@ -298,8 +298,6 @@
FILE *infile;
int stringSize = 80; // max size of one line in file
char inputStr[stringSize];
- struct stat fileStatus;
- int fileSize=0;
int lineCount=0;
if (lineNumber < 0)
@@ -309,12 +307,6 @@
printf ("Fatal error opening file %s\n",inputFile);
return (0);
}
- memset (&fileStatus, 0, sizeof(fileStatus));
- if (!stat(inputFile, &fileStatus)) {
- if (S_ISREG(fileStatus.st_mode)) {
- fileSize = fileStatus.st_size;
- }
- }
while (!feof(infile)) {
if (fgets (inputStr, stringSize, infile) != NULL) {
diff --git a/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.h b/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.h
index cd8ac23..318fcb6 100644
--- a/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.h
+++ b/aos/externals/WPILib/WPILib/Vision2009/BaeUtilities.h
@@ -39,7 +39,7 @@
/* debug */
void SetDebugFlag ( DebugOutputType flag );
-void dprintf ( char * tempString, ... ); /* Variable argument list */
+void dprintf ( const char * tempString, ... ); /* Variable argument list */
/* set FRC ranges for drive */
double RangeToNormalized(double pixel, int range);
diff --git a/aos/externals/WPILib/WPILib/Vision2009/FrcError.cpp b/aos/externals/WPILib/WPILib/Vision2009/FrcError.cpp
index a7f0ba1..2addfd1 100644
--- a/aos/externals/WPILib/WPILib/Vision2009/FrcError.cpp
+++ b/aos/externals/WPILib/WPILib/Vision2009/FrcError.cpp
@@ -35,9 +35,9 @@
* @param errorCode The error code to find the text for.
* @return The error text
*/
-char* GetVisionErrorText(int errorCode)
+const char* GetVisionErrorText(int errorCode)
{
- char* errorText;
+ const char* errorText;
switch (errorCode)
{
diff --git a/aos/externals/WPILib/WPILib/Vision2009/FrcError.h b/aos/externals/WPILib/WPILib/Vision2009/FrcError.h
index 95a0356..34b0b01 100644
--- a/aos/externals/WPILib/WPILib/Vision2009/FrcError.h
+++ b/aos/externals/WPILib/WPILib/Vision2009/FrcError.h
@@ -35,7 +35,7 @@
/* error handling functions */
int GetLastVisionError();
-char* GetVisionErrorText(int errorCode);
+const char* GetVisionErrorText(int errorCode);
#endif
diff --git a/aos/externals/WPILib/WPILib/WPILib.h b/aos/externals/WPILib/WPILib/WPILib.h
index b6e9329..9091063 100644
--- a/aos/externals/WPILib/WPILib/WPILib.h
+++ b/aos/externals/WPILib/WPILib/WPILib.h
@@ -8,7 +8,7 @@
#define WPILIB_H_
#include "string.h"
-#include <iostream.h>
+#include <iostream>
#include "Accelerometer.h"
#include "ADXL345_I2C.h"
diff --git a/aos/externals/WPILib/WPILib/Watchdog.cpp b/aos/externals/WPILib/WPILib/Watchdog.cpp
index 30a386e..e88e00e 100644
--- a/aos/externals/WPILib/WPILib/Watchdog.cpp
+++ b/aos/externals/WPILib/WPILib/Watchdog.cpp
@@ -6,7 +6,7 @@
#include "Watchdog.h"
-const double Watchdog::kDefaultWatchdogExpiration;
+constexpr double Watchdog::kDefaultWatchdogExpiration;
/**
* The Watchdog is born.
@@ -73,7 +73,7 @@
double Watchdog::GetTimer()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 timer = m_fpgaWatchDog->readTimer(&localStatus);
+ uint32_t timer = m_fpgaWatchDog->readTimer(&localStatus);
wpi_setError(localStatus);
return timer / (kSystemClockTicksPerMicrosecond * 1e6);
}
@@ -86,7 +86,7 @@
double Watchdog::GetExpiration()
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- UINT32 expiration = m_fpgaWatchDog->readExpiration(&localStatus);
+ uint32_t expiration = m_fpgaWatchDog->readExpiration(&localStatus);
wpi_setError(localStatus);
return expiration / (kSystemClockTicksPerMicrosecond * 1e6);
}
@@ -99,7 +99,7 @@
void Watchdog::SetExpiration(double expiration)
{
tRioStatusCode localStatus = NiFpga_Status_Success;
- m_fpgaWatchDog->writeExpiration((UINT32)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), &localStatus);
+ m_fpgaWatchDog->writeExpiration((uint32_t)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), &localStatus);
wpi_setError(localStatus);
}
diff --git a/aos/externals/WPILib/WPILib/Watchdog.h b/aos/externals/WPILib/WPILib/Watchdog.h
index b7e35da..6af6a01 100644
--- a/aos/externals/WPILib/WPILib/Watchdog.h
+++ b/aos/externals/WPILib/WPILib/Watchdog.h
@@ -25,7 +25,7 @@
class Watchdog : public SensorBase
{
public:
- static const double kDefaultWatchdogExpiration = 0.5;
+ static constexpr double kDefaultWatchdogExpiration = 0.5;
Watchdog();
virtual ~Watchdog();
diff --git a/aos/externals/WPILib/WPILib/networktables/NetworkTable.cpp b/aos/externals/WPILib/WPILib/networktables/NetworkTable.cpp
index 78dd4a4..e9b4c89 100644
--- a/aos/externals/WPILib/WPILib/networktables/NetworkTable.cpp
+++ b/aos/externals/WPILib/WPILib/networktables/NetworkTable.cpp
@@ -7,7 +7,7 @@
#include "networktables2/util/StringCache.h"
#include "networktables/NetworkTableProvider.h"
#include "networktables/NetworkTableMode.h"
-#include "Synchronized.h"
+#include "OSAL/Synchronized.h"
#include "tables/TableKeyNotDefinedException.h"
#include "networktables2/type/DefaultEntryTypes.h"
#include "tables/ITableListener.h"
@@ -23,10 +23,14 @@
DefaultThreadManager NetworkTable::threadManager;
NetworkTableProvider* NetworkTable::staticProvider = NULL;
+NetworkTableNode* NetworkTable::staticNode = NULL;
+void* NetworkTable::streamFactory = NULL;
+NetworkTableEntryTypeManager* NetworkTable::typeManager = NULL;
+StreamDeleter streamDeleter = NULL;
NetworkTableMode* NetworkTable::mode = &NetworkTableMode::Server;
int NetworkTable::port = DEFAULT_PORT;
std::string NetworkTable::ipAddress;
-ReentrantSemaphore NetworkTable::STATIC_LOCK;
+NTReentrantSemaphore NetworkTable::STATIC_LOCK;
@@ -34,8 +38,9 @@
void NetworkTable::CheckInit(){
- {
- Synchronized sync(STATIC_LOCK);
+ printf("[NT] NetworkTable::CheckInit()...\n");
+ {
+ NTSynchronized sync(STATIC_LOCK);
if(staticProvider!=NULL)
throw new IllegalStateException("Network tables has already been initialized");
}
@@ -43,7 +48,34 @@
void NetworkTable::Initialize() {
CheckInit();
- staticProvider = new NetworkTableProvider(*(mode->CreateNode(ipAddress.c_str(), port, threadManager)));
+ printf("[NT] NetworkTable::Initialize()...\n");
+ staticProvider = new NetworkTableProvider(*(staticNode = mode->CreateNode(ipAddress.c_str(), port, threadManager, streamFactory, streamDeleter, typeManager)));
+ printf("[NT] ...NetworkTable::Initialize().\n");
+}
+
+void NetworkTable::Shutdown()
+{
+ if (staticProvider!=NULL)
+ {
+ delete staticProvider;
+ staticProvider=NULL;
+ }
+ if (staticNode!=NULL)
+ {
+ delete staticNode;
+ staticNode=NULL;
+ }
+ if (streamDeleter!=NULL && streamFactory!=NULL)
+ {
+ streamDeleter(streamFactory);
+ streamFactory=NULL;
+ streamDeleter=NULL;
+ }
+ if (typeManager!=NULL)
+ {
+ delete typeManager;
+ typeManager=NULL;
+ }
}
void NetworkTable::SetTableProvider(NetworkTableProvider* provider){
@@ -73,11 +105,14 @@
}
NetworkTable* NetworkTable::GetTable(std::string key) {
+ printf("[NT] NetworkTable::GetTable()...\n");
if(staticProvider==NULL){
+ printf("[NT] \tInitializing...\n");
Initialize();
}
std::string tmp(PATH_SEPARATOR);
tmp+=key;
+ printf("[NT] ...Ready to get Table.\n");
return (NetworkTable*)staticProvider->GetTable(tmp);
}
@@ -154,7 +189,7 @@
NetworkTableEntry* NetworkTable::GetEntry(std::string key){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
return entryCache.Get(key);
}
}
@@ -162,7 +197,7 @@
NetworkTable* NetworkTable::GetSubTable(std::string key) {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
return (NetworkTable*)provider.GetTable(absoluteKeyCache.Get(key));
}
}
diff --git a/aos/externals/WPILib/WPILib/networktables/NetworkTable.h b/aos/externals/WPILib/WPILib/networktables/NetworkTable.h
index 5e32891..8c49e3f 100644
--- a/aos/externals/WPILib/WPILib/networktables/NetworkTable.h
+++ b/aos/externals/WPILib/WPILib/networktables/NetworkTable.h
@@ -55,10 +55,13 @@
private:
static DefaultThreadManager threadManager;
static NetworkTableProvider* staticProvider;
+ static NetworkTableNode* staticNode;
+ static void* streamFactory;
+ static NetworkTableEntryTypeManager* typeManager;
static NetworkTableMode* mode;
static int port;
static std::string ipAddress;
- static ReentrantSemaphore STATIC_LOCK;
+ static NTReentrantSemaphore STATIC_LOCK;
@@ -67,7 +70,7 @@
NetworkTableKeyCache absoluteKeyCache;
NetworkTableProvider& provider;
NetworkTableNode& node;
- ReentrantSemaphore LOCK;
+ NTReentrantSemaphore LOCK;
map<IRemoteConnectionListener*, NetworkTableConnectionListenerAdapter*> connectionListenerMap;
@@ -94,7 +97,8 @@
* @throws IOException
*/
static void Initialize();
-
+ static void Shutdown();
+
/**
* set the table provider for static network tables methods
* This must be called before getTable
diff --git a/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.cpp b/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.cpp
index ec06980..879d0e8 100644
--- a/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.cpp
+++ b/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.cpp
@@ -10,6 +10,7 @@
NetworkTableConnectionListenerAdapter::NetworkTableConnectionListenerAdapter(IRemote* _targetSource, IRemoteConnectionListener* _targetListener):
targetSource(_targetSource), targetListener(_targetListener){}
+NetworkTableConnectionListenerAdapter::~NetworkTableConnectionListenerAdapter(){}
void NetworkTableConnectionListenerAdapter::Connected(IRemote* remote) {
targetListener->Connected(targetSource);
diff --git a/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.h b/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.h
index fca9046..8b9ef9d 100644
--- a/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.h
+++ b/aos/externals/WPILib/WPILib/networktables/NetworkTableConnectionListenerAdapter.h
@@ -22,6 +22,7 @@
public:
NetworkTableConnectionListenerAdapter(IRemote* targetSource, IRemoteConnectionListener* targetListener);
+ virtual ~NetworkTableConnectionListenerAdapter();
void Connected(IRemote* remote);
void Disconnected(IRemote* remote);
};
diff --git a/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.cpp b/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.cpp
index 75fca34..95fa1e7 100644
--- a/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.cpp
+++ b/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.cpp
@@ -21,11 +21,24 @@
NetworkTableServerMode::NetworkTableServerMode(){}
NetworkTableClientMode::NetworkTableClientMode(){}
-NetworkTableNode* NetworkTableServerMode::CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager){
- IOStreamProvider* streamProvider = new SocketServerStreamProvider(port);
- return new NetworkTableServer(*streamProvider, *new NetworkTableEntryTypeManager(), threadManager);
+static void deleteIOStreamProvider(void* ptr){
+ delete (IOStreamProvider*)ptr;
}
-NetworkTableNode* NetworkTableClientMode::CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager){
+static void deleteIOStreamFactory(void* ptr){
+ delete (IOStreamFactory*)ptr;
+}
+
+NetworkTableNode* NetworkTableServerMode::CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager, void*& streamFactory_out, StreamDeleter& streamDeleter_out, NetworkTableEntryTypeManager*& typeManager_out){
+ IOStreamProvider* streamProvider = new SocketServerStreamProvider(port);
+ streamFactory_out = streamProvider;
+ typeManager_out = new NetworkTableEntryTypeManager();
+ streamDeleter_out = deleteIOStreamFactory;
+ return new NetworkTableServer(*streamProvider, *typeManager_out, threadManager);
+}
+NetworkTableNode* NetworkTableClientMode::CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager, void*& streamFactory_out, StreamDeleter& streamDeleter_out, NetworkTableEntryTypeManager*& typeManager_out){
IOStreamFactory* streamFactory = new SocketStreamFactory(ipAddress, port);
- return new NetworkTableClient(*streamFactory, *new NetworkTableEntryTypeManager(), threadManager);
+ streamFactory_out = streamFactory;
+ typeManager_out = new NetworkTableEntryTypeManager();
+ streamDeleter_out = deleteIOStreamProvider;
+ return new NetworkTableClient(*streamFactory, *typeManager_out, threadManager);
}
diff --git a/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.h b/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.h
index ba22cb1..bf3e4c1 100644
--- a/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.h
+++ b/aos/externals/WPILib/WPILib/networktables/NetworkTableMode.h
@@ -10,7 +10,7 @@
#include "networktables2/NetworkTableNode.h"
#include "networktables2/thread/NTThreadManager.h"
-
+typedef void (*StreamDeleter)(void*);
/**
*
* Represents a different modes that network tables can be configured in
@@ -28,7 +28,7 @@
* @return a new node that can back a network table
* @throws IOException
*/
- virtual NetworkTableNode* CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager) = 0;
+ virtual NetworkTableNode* CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager, void*& streamFactory_out, StreamDeleter& streamDeleter_out, NetworkTableEntryTypeManager*& typeManager_out) = 0;
static NetworkTableServerMode Server;
static NetworkTableClientMode Client;
@@ -37,13 +37,13 @@
class NetworkTableServerMode : public NetworkTableMode{
public:
NetworkTableServerMode();
- virtual NetworkTableNode* CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager);
+ virtual NetworkTableNode* CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager, void*& streamFactory_out, StreamDeleter& streamDeleter_out, NetworkTableEntryTypeManager*& typeManager_out);
};
class NetworkTableClientMode : public NetworkTableMode{
public:
NetworkTableClientMode();
- virtual NetworkTableNode* CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager);
+ virtual NetworkTableNode* CreateNode(const char* ipAddress, int port, NTThreadManager& threadManager, void*& streamFactory_out, StreamDeleter& streamDeleter_out, NetworkTableEntryTypeManager*& typeManager_out);
};
diff --git a/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.cpp b/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.cpp
index c502432..00829a0 100644
--- a/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.cpp
@@ -23,7 +23,7 @@
delete itr->second;
namedEntries.erase(itr++);
}
- };
+ }
/**
* Get an entry based on it's name
@@ -32,7 +32,7 @@
*/
NetworkTableEntry* AbstractNetworkTableEntryStore::GetEntry(std::string& name){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator value_itr = namedEntries.find(name);
if(value_itr != namedEntries.end()) {
return value_itr->second;
@@ -43,7 +43,7 @@
NetworkTableEntry* AbstractNetworkTableEntryStore::GetEntry(EntryId entryId){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<EntryId, NetworkTableEntry*>::iterator value_itr = idEntries.find(entryId);
if(value_itr != idEntries.end()) {
@@ -55,7 +55,7 @@
std::vector<std::string>* AbstractNetworkTableEntryStore::keys(){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::vector<std::string>* keys = new std::vector<std::string>();
std::map<std::string, NetworkTableEntry*>::iterator itr;
@@ -77,7 +77,7 @@
*/
void AbstractNetworkTableEntryStore::clearEntries(){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
namedEntries.clear();
idEntries.clear();
}
@@ -88,7 +88,7 @@
*/
void AbstractNetworkTableEntryStore::clearIds(){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator itr;
idEntries.clear();
@@ -119,7 +119,7 @@
*/
void AbstractNetworkTableEntryStore::PutOutgoing(std::string& name, NetworkTableEntryType* type, EntryValue value){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator index = namedEntries.find(name);
NetworkTableEntry* tableEntry;
if(index == namedEntries.end())//if the name does not exist in the current entries
@@ -138,29 +138,36 @@
throw TableKeyExistsWithDifferentTypeException(name, tableEntry->GetType());
}
- if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){
- outgoingReceiver->offerOutgoingUpdate(tableEntry);
- }
+ EntryValue oldValue = tableEntry->GetValue();
+ if(!type->areEqual(value, oldValue)){
+ if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){
+ outgoingReceiver->offerOutgoingUpdate(tableEntry);
+ }
- tableEntry->FireListener(listenerManager);
+ tableEntry->FireListener(listenerManager);
+ }
}
}
}
void AbstractNetworkTableEntryStore::PutOutgoing(NetworkTableEntry* tableEntry, EntryValue value){
{
- Synchronized sync(LOCK);
- if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){
- outgoingReceiver->offerOutgoingUpdate(tableEntry);
- }
+ NTSynchronized sync(LOCK);
+ NetworkTableEntryType* type = tableEntry->GetType();
+ EntryValue oldValue = tableEntry->GetValue();
+ if(!type->areEqual(value, oldValue)){
+ if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){
+ outgoingReceiver->offerOutgoingUpdate(tableEntry);
+ }
- tableEntry->FireListener(listenerManager);
+ tableEntry->FireListener(listenerManager);
+ }
}
}
void AbstractNetworkTableEntryStore::offerIncomingAssignment(NetworkTableEntry* entry){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator itr = namedEntries.find(entry->name);
NetworkTableEntry* tableEntry;
if(addEntry(entry)){
@@ -181,7 +188,7 @@
void AbstractNetworkTableEntryStore::offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber squenceNumber, EntryValue value){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
if(updateEntry(entry, squenceNumber, value)){
entry->FireListener(listenerManager);
incomingReceiver->offerOutgoingUpdate(entry);
@@ -196,7 +203,7 @@
*/
void AbstractNetworkTableEntryStore::notifyEntries(ITable* table, ITableListener* listener){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator itr;
for(itr = namedEntries.begin(); itr != namedEntries.end(); itr++)
{
diff --git a/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.h b/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.h
index 593dc91..b394cfb 100644
--- a/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.h
+++ b/aos/externals/WPILib/WPILib/networktables2/AbstractNetworkTableEntryStore.h
@@ -14,12 +14,12 @@
class AbstractNetworkTableEntryStore;
-#include "Synchronized.h"
+#include "OSAL/Synchronized.h"
#include <string>
-#include "NetworkTableEntry.h"
-#include "IncomingEntryReceiver.h"
-#include "OutgoingEntryReceiver.h"
-#include "type/NetworkTableEntryType.h"
+#include "networktables2/NetworkTableEntry.h"
+#include "networktables2/IncomingEntryReceiver.h"
+#include "networktables2/OutgoingEntryReceiver.h"
+#include "networktables2/type/NetworkTableEntryType.h"
#include "tables/ITable.h"
#include "tables/ITableListener.h"
#include <map>
@@ -52,7 +52,7 @@
public:
virtual ~AbstractNetworkTableEntryStore();
- ReentrantSemaphore LOCK;
+ NTReentrantSemaphore LOCK;
NetworkTableEntry* GetEntry(EntryId entryId);
NetworkTableEntry* GetEntry(std::string& name);
diff --git a/aos/externals/WPILib/WPILib/networktables2/FlushableOutgoingEntryReceiver.h b/aos/externals/WPILib/WPILib/networktables2/FlushableOutgoingEntryReceiver.h
index c2acb8d..f87e905 100644
--- a/aos/externals/WPILib/WPILib/networktables2/FlushableOutgoingEntryReceiver.h
+++ b/aos/externals/WPILib/WPILib/networktables2/FlushableOutgoingEntryReceiver.h
@@ -10,7 +10,7 @@
class FlushableOutgoingEntryReceiver;
-#include "OutgoingEntryReceiver.h"
+#include "networktables2/OutgoingEntryReceiver.h"
class FlushableOutgoingEntryReceiver : public OutgoingEntryReceiver
{
diff --git a/aos/externals/WPILib/WPILib/networktables2/IncomingEntryReceiver.h b/aos/externals/WPILib/WPILib/networktables2/IncomingEntryReceiver.h
index fe99e2b..7ee60df 100644
--- a/aos/externals/WPILib/WPILib/networktables2/IncomingEntryReceiver.h
+++ b/aos/externals/WPILib/WPILib/networktables2/IncomingEntryReceiver.h
@@ -8,9 +8,7 @@
#ifndef INCOMINGENTRYRECEIVER_H_
#define INCOMINGENTRYRECEIVER_H_
-class IncomingEntryReceiver;
-
-#include "NetworkTableEntry.h"
+#include "networktables2/NetworkTableEntry.h"
#include "tables/ITable.h"
class IncomingEntryReceiver
diff --git a/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.cpp b/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.cpp
index 58872eb..9538c91 100644
--- a/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.cpp
@@ -1,5 +1,5 @@
#include "networktables2/NetworkTableEntry.h"
-
+#include "networktables2/AbstractNetworkTableEntryStore.h"
NetworkTableEntry::NetworkTableEntry(std::string& _name, NetworkTableEntryType* _type, EntryValue _value)
diff --git a/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.h b/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.h
index d522e92..2a29004 100644
--- a/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.h
+++ b/aos/externals/WPILib/WPILib/networktables2/NetworkTableEntry.h
@@ -10,13 +10,13 @@
typedef uint16_t EntryId;
typedef uint16_t SequenceNumber;
class NetworkTableEntry;
+class TableListenerManager;
-#include "connection/DataIOStream.h"
-#include "connection/NetworkTableConnection.h"
-#include "type/NetworkTableEntryType.h"
-#include "util/IllegalStateException.h"
-#include "AbstractNetworkTableEntryStore.h"
+#include "networktables2/connection/DataIOStream.h"
+#include "networktables2/connection/NetworkTableConnection.h"
+#include "networktables2/type/NetworkTableEntryType.h"
+#include "networktables2/util/IllegalStateException.h"
#include <string>
#include "tables/ITable.h"
diff --git a/aos/externals/WPILib/WPILib/networktables2/NetworkTableMessageType.h b/aos/externals/WPILib/WPILib/networktables2/NetworkTableMessageType.h
index f54d2f0..1b4e90f 100644
--- a/aos/externals/WPILib/WPILib/networktables2/NetworkTableMessageType.h
+++ b/aos/externals/WPILib/WPILib/networktables2/NetworkTableMessageType.h
@@ -37,7 +37,7 @@
/**
* a field update message
*/
- FIELD_UPDATE = 0x11,
+ FIELD_UPDATE = 0x11
};
#endif /* NETWORKTABLEMESSAGETYPE_H_ */
diff --git a/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.cpp b/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.cpp
index 316a61e..6631ba3 100644
--- a/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.cpp
@@ -69,7 +69,7 @@
void NetworkTableNode::retrieveValue(std::string& name, ComplexData& externalData){
{
- Synchronized sync(entryStore.LOCK);
+ NTSynchronized sync(entryStore.LOCK);
NetworkTableEntry* entry = entryStore.GetEntry(name);
if(entry==NULL)
throw TableKeyNotDefinedException(name);
@@ -85,7 +85,7 @@
void NetworkTableNode::PutValue(std::string& name, NetworkTableEntryType* type, EntryValue value){
if(type->isComplex()){
{
- Synchronized sync(entryStore.LOCK);
+ NTSynchronized sync(entryStore.LOCK);
ComplexData* complexData = (ComplexData*)value.ptr;
ComplexEntryType* entryType = (ComplexEntryType*)type;
NetworkTableEntry* entry = entryStore.GetEntry(name);
@@ -93,7 +93,9 @@
entryStore.PutOutgoing(entry, entryType->internalizeValue(entry->name, *complexData, entry->GetValue()));
else{
EntryValue nullValue = {0};
- entryStore.PutOutgoing(name, type, entryType->internalizeValue(name, *complexData, nullValue));
+ EntryValue entryValue = entryType->internalizeValue(name, *complexData, nullValue);
+ entryStore.PutOutgoing(name, type, entryValue);//TODO the entry gets copied when creating the entry should make lifecycle cleaner
+ type->deleteValue(entryValue);
}
}
}
@@ -104,7 +106,7 @@
void NetworkTableNode::PutValue(NetworkTableEntry* entry, EntryValue value){
if(entry->GetType()->isComplex()){
{
- Synchronized sync(entryStore.LOCK);
+ NTSynchronized sync(entryStore.LOCK);
ComplexEntryType* entryType = (ComplexEntryType*)entry->GetType();
entryStore.PutOutgoing(entry, entryType->internalizeValue(entry->name, *(ComplexData*)value.ptr, entry->GetValue()));
@@ -116,7 +118,7 @@
EntryValue NetworkTableNode::GetValue(std::string& name){//TODO don't allow get of complex types
{
- Synchronized sync(entryStore.LOCK);
+ NTSynchronized sync(entryStore.LOCK);
NetworkTableEntry* entry = entryStore.GetEntry(name);
if(entry==NULL)
throw TableKeyNotDefinedException(name);
diff --git a/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.h b/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.h
index a3bb6bf..1a23bd6 100644
--- a/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.h
+++ b/aos/externals/WPILib/WPILib/networktables2/NetworkTableNode.h
@@ -11,11 +11,11 @@
class NetworkTableNode;
-#include "AbstractNetworkTableEntryStore.h"
-#include "client/ClientConnectionListenerManager.h"
-#include "type/NetworkTableEntryType.h"
-#include "type/ComplexData.h"
-#include "type/ComplexEntryType.h"
+#include "networktables2/AbstractNetworkTableEntryStore.h"
+#include "networktables2/client/ClientConnectionListenerManager.h"
+#include "networktables2/type/NetworkTableEntryType.h"
+#include "networktables2/type/ComplexData.h"
+#include "networktables2/type/ComplexEntryType.h"
#include "tables/IRemote.h"
#include <string>
#include <vector>
diff --git a/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReceiver.h b/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReceiver.h
index eff2daa..a88f7ec 100644
--- a/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReceiver.h
+++ b/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReceiver.h
@@ -10,7 +10,7 @@
class OutgoingEntryReceiver;
-#include "NetworkTableEntry.h"
+#include "networktables2/NetworkTableEntry.h"
class NetworkTableEntry;
diff --git a/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReciever.cpp b/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReciever.cpp
index affefe3..ae78363 100644
--- a/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReciever.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/OutgoingEntryReciever.cpp
@@ -9,5 +9,5 @@
OutgoingEntryReceiver_NULL_t OutgoingEntryReceiver_NULL;
-void OutgoingEntryReceiver_NULL_t::offerOutgoingAssignment(NetworkTableEntry* entry){};
-void OutgoingEntryReceiver_NULL_t::offerOutgoingUpdate(NetworkTableEntry* entry){};
+void OutgoingEntryReceiver_NULL_t::offerOutgoingAssignment(NetworkTableEntry* entry){}
+void OutgoingEntryReceiver_NULL_t::offerOutgoingUpdate(NetworkTableEntry* entry){}
diff --git a/aos/externals/WPILib/WPILib/networktables2/TransactionDirtier.h b/aos/externals/WPILib/WPILib/networktables2/TransactionDirtier.h
index c92190f..76cd1db 100644
--- a/aos/externals/WPILib/WPILib/networktables2/TransactionDirtier.h
+++ b/aos/externals/WPILib/WPILib/networktables2/TransactionDirtier.h
@@ -12,7 +12,7 @@
class TransactionDirtier;
-#include "OutgoingEntryReceiver.h"
+#include "networktables2/OutgoingEntryReceiver.h"
diff --git a/aos/externals/WPILib/WPILib/networktables2/WriteManager.cpp b/aos/externals/WPILib/WPILib/networktables2/WriteManager.cpp
index 3f762bb..bbe08f5 100644
--- a/aos/externals/WPILib/WPILib/networktables2/WriteManager.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/WriteManager.cpp
@@ -7,6 +7,7 @@
#include "networktables2/WriteManager.h"
#include "networktables2/util/System.h"
+#include "networktables2/AbstractNetworkTableEntryStore.h"
#include <iostream>
@@ -24,9 +25,10 @@
}
WriteManager::~WriteManager(){
- transactionsLock.take();
-
stop();
+
+ //Note: this must occur after stop() to avoid deadlock
+ transactionsLock.take();
delete incomingAssignmentQueue;
delete incomingUpdateQueue;
@@ -44,7 +46,7 @@
void WriteManager::stop(){
if(thread!=NULL){
thread->stop();
- //delete thread;
+ delete thread;
thread = NULL;
}
}
@@ -52,7 +54,7 @@
void WriteManager::offerOutgoingAssignment(NetworkTableEntry* entry) {
{
- Synchronized sync(transactionsLock);
+ NTSynchronized sync(transactionsLock);
((std::queue<NetworkTableEntry*>*)incomingAssignmentQueue)->push(entry);
if(((std::queue<NetworkTableEntry*>*)incomingAssignmentQueue)->size()>=queueSize){
@@ -65,7 +67,7 @@
void WriteManager::offerOutgoingUpdate(NetworkTableEntry* entry) {
{
- Synchronized sync(transactionsLock);
+ NTSynchronized sync(transactionsLock);
((std::queue<NetworkTableEntry*>*)incomingUpdateQueue)->push(entry);
if(((std::queue<NetworkTableEntry*>*)incomingUpdateQueue)->size()>=queueSize){
run();
@@ -77,7 +79,7 @@
void WriteManager::run() {
{
- Synchronized sync(transactionsLock);
+ NTSynchronized sync(transactionsLock);
//swap the assignment and update queue
volatile std::queue<NetworkTableEntry*>* tmp = incomingAssignmentQueue;
incomingAssignmentQueue = outgoingAssignmentQueue;
@@ -95,7 +97,7 @@
entry = ((std::queue<NetworkTableEntry*>*)outgoingAssignmentQueue)->front();
((std::queue<NetworkTableEntry*>*)outgoingAssignmentQueue)->pop();
{
- Synchronized sync(entryStore.LOCK);
+ NTSynchronized sync(entryStore.LOCK);
entry->MakeClean();
wrote = true;
receiver.offerOutgoingAssignment(entry);
@@ -106,7 +108,7 @@
entry = ((std::queue<NetworkTableEntry*>*)outgoingUpdateQueue)->front();
((std::queue<NetworkTableEntry*>*)outgoingUpdateQueue)->pop();
{
- Synchronized sync(entryStore.LOCK);
+ NTSynchronized sync(entryStore.LOCK);
entry->MakeClean();
wrote = true;
receiver.offerOutgoingUpdate(entry);
diff --git a/aos/externals/WPILib/WPILib/networktables2/WriteManager.h b/aos/externals/WPILib/WPILib/networktables2/WriteManager.h
index ec3607a..c376b8c 100644
--- a/aos/externals/WPILib/WPILib/networktables2/WriteManager.h
+++ b/aos/externals/WPILib/WPILib/networktables2/WriteManager.h
@@ -8,18 +8,18 @@
#ifndef WRITEMANAGER_H_
#define WRITEMANAGER_H_
-
+class AbstractNetworkTableEntryStore;
class WriteManager;
-#include "thread/PeriodicRunnable.h"
-#include "OutgoingEntryReceiver.h"
-#include "thread/NTThread.h"
-#include "thread/NTThreadManager.h"
-#include "FlushableOutgoingEntryReceiver.h"
-#include "NetworkTableEntry.h"
+#include "networktables2/thread/PeriodicRunnable.h"
+#include "networktables2/OutgoingEntryReceiver.h"
+#include "networktables2/thread/NTThread.h"
+#include "networktables2/thread/NTThreadManager.h"
+#include "networktables2/FlushableOutgoingEntryReceiver.h"
+#include "networktables2/NetworkTableEntry.h"
#include <queue>
-#include "Synchronized.h"
+#include "OSAL/Synchronized.h"
@@ -33,7 +33,7 @@
private:
const static size_t queueSize = 500;
- ReentrantSemaphore transactionsLock;
+ NTReentrantSemaphore transactionsLock;
NTThread* thread;
diff --git a/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.cpp b/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.cpp
index 2e3a185..9510c04 100644
--- a/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.cpp
@@ -6,19 +6,23 @@
*/
#include "networktables2/client/ClientConnectionAdapter.h"
-#include "networktables2/connection/ConnectionMonitorThread.h"
+#include "networktables2/util/System.h"
void ClientConnectionAdapter::gotoState(ClientConnectionState* newState){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
if(connectionState!=newState){
- fprintf(stdout, "%p entered connection state: %s\n",this, newState->toString());
+ fprintf(stdout, "[NT] %p entered connection state: %s\n", (void*)this, newState->toString());
fflush(stdout);
if(newState==&ClientConnectionState::IN_SYNC_WITH_SERVER)
connectionListenerManager.FireConnectedEvent();
if(connectionState==&ClientConnectionState::IN_SYNC_WITH_SERVER)
connectionListenerManager.FireDisconnectedEvent();
+ //TODO find better way to manage memory leak
+ ClientConnectionState_Error *temp=dynamic_cast<ClientConnectionState_Error *>(connectionState);
connectionState = newState;
+ if (temp)
+ delete temp;
}
}
}
@@ -49,12 +53,40 @@
threadManager(_threadManager),
connectionListenerManager(_connectionListenerManager),
typeManager(_typeManager),
- readThread(NULL),
- connection(NULL){
+ readThread(NULL),
+ monitor(NULL),
+ connection(NULL){
connectionState = &ClientConnectionState::DISCONNECTED_FROM_SERVER;
}
-ClientConnectionAdapter::~ClientConnectionAdapter(){
- close();
+ClientConnectionAdapter::~ClientConnectionAdapter()
+{
+ if(readThread!=NULL)
+ readThread->stop();
+ if (connection)
+ connection->close();
+ if(readThread!=NULL)
+ {
+ delete readThread;
+ readThread = NULL;
+ }
+ if(monitor!=NULL)
+ {
+ delete monitor;
+ monitor = NULL;
+ }
+ close();
+ if(connection!=NULL){
+ delete connection;
+ connection = NULL;
+ }
+
+ //TODO find better way to manage memory leak
+ ClientConnectionState_Error *temp=dynamic_cast<ClientConnectionState_Error *>(connectionState);
+ if (temp)
+ {
+ delete temp;
+ connectionState=NULL;
+ }
}
@@ -65,15 +97,25 @@
* Reconnect the client to the server (even if the client is not currently connected)
*/
void ClientConnectionAdapter::reconnect() {
+ //This is in reconnect so that the entry store doesn't have to be valid when this object is deleted
+ //Note: clearIds() cannot be in a LOCK critical section
+ entryStore.clearIds();
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
close();//close the existing stream and monitor thread if needed
try{
IOStream* stream = streamFactory.createStream();
if(stream==NULL)
return;
- connection = new NetworkTableConnection(stream, typeManager);
- readThread = threadManager.newBlockingPeriodicThread(new ConnectionMonitorThread(*this, *connection), "Client Connection Reader Thread");
+ if (!connection)
+ connection = new NetworkTableConnection(stream, typeManager);
+ else
+ connection->SetIOStream(stream);
+ m_IsConnectionClosed=false;
+ if (!monitor)
+ monitor = new ConnectionMonitorThread(*this, *connection);
+ if (!readThread)
+ readThread = threadManager.newBlockingPeriodicThread(monitor, "Client Connection Reader Thread");
connection->sendClientHello();
gotoState(&ClientConnectionState::CONNECTED_TO_SERVER);
} catch(IOException& e){
@@ -94,17 +136,15 @@
*/
void ClientConnectionAdapter::close(ClientConnectionState* newState) {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
gotoState(newState);
- if(readThread!=NULL){
- readThread->stop();
- readThread = NULL;
- }
- if(connection!=NULL){
+ //Disconnect the socket
+ if(connection!=NULL)
+ {
connection->close();
- connection = NULL;
+ connection->SetIOStream(NULL); //disconnect the table connection from the IO stream
}
- entryStore.clearIds();
+ m_IsConnectionClosed=true;
}
}
@@ -112,12 +152,19 @@
void ClientConnectionAdapter::badMessage(BadMessageException& e) {
close(new ClientConnectionState_Error(e));
+ sleep_ms(33); //avoid busy wait
}
void ClientConnectionAdapter::ioException(IOException& e) {
if(connectionState!=&ClientConnectionState::DISCONNECTED_FROM_SERVER)//will get io exception when on read thread connection is closed
+ {
reconnect();
- //gotoState(new ClientConnectionState.Error(e));
+ sleep_ms(500);
+ }
+ else
+ {
+ sleep_ms(33); //avoid busy wait
+ }
}
NetworkTableEntry* ClientConnectionAdapter::GetEntry(EntryId id) {
@@ -125,7 +172,8 @@
}
-void ClientConnectionAdapter::keepAlive() {
+bool ClientConnectionAdapter::keepAlive() {
+ return true;
}
void ClientConnectionAdapter::clientHello(ProtocolVersion protocolRevision) {
@@ -161,7 +209,7 @@
void ClientConnectionAdapter::offerOutgoingAssignment(NetworkTableEntry* entry) {
try {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
if(connection!=NULL && connectionState==&ClientConnectionState::IN_SYNC_WITH_SERVER)
connection->sendEntryAssignment(*entry);
}
@@ -173,7 +221,7 @@
void ClientConnectionAdapter::offerOutgoingUpdate(NetworkTableEntry* entry) {
try {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
if(connection!=NULL && connectionState==&ClientConnectionState::IN_SYNC_WITH_SERVER)
connection->sendEntryUpdate(*entry);
}
@@ -183,7 +231,7 @@
}
void ClientConnectionAdapter::flush() {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
if(connection!=NULL) {
try {
connection->flush();
@@ -195,8 +243,8 @@
}
void ClientConnectionAdapter::ensureAlive() {
{
- Synchronized sync(LOCK);
- if(connection!=NULL) {
+ NTSynchronized sync(LOCK);
+ if ((connection!=NULL)&&(!m_IsConnectionClosed)) {
try {
connection->sendKeepAlive();
} catch (IOException& e) {
diff --git a/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.h b/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.h
index 4260d51..c718083 100644
--- a/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.h
+++ b/aos/externals/WPILib/WPILib/networktables2/client/ClientConnectionAdapter.h
@@ -19,6 +19,7 @@
#include "networktables2/thread/NTThread.h"
#include "networktables2/client/ClientConnectionState.h"
#include "networktables2/client/ClientConnectionListenerManager.h"
+#include "networktables2/connection/ConnectionMonitorThread.h"
/**
@@ -35,13 +36,14 @@
ClientConnectionState* connectionState;
ClientConnectionListenerManager& connectionListenerManager;
- ReentrantSemaphore LOCK;
+ NTReentrantSemaphore LOCK;
NetworkTableEntryTypeManager& typeManager;
NTThread* readThread;
+ ConnectionMonitorThread* monitor;
NetworkTableConnection* connection;
void gotoState(ClientConnectionState* newState);
-
+ bool m_IsConnectionClosed; //Keep track of when this is closed to issue reconnect
public:
/**
* @return the state of the connection
@@ -91,7 +93,7 @@
NetworkTableEntry* GetEntry(EntryId id);
- void keepAlive();
+ bool keepAlive();
void clientHello(ProtocolVersion protocolRevision);
diff --git a/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.cpp b/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.cpp
index ab2d4eb..d2fc19d 100644
--- a/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.cpp
@@ -17,7 +17,7 @@
bool ClientNetworkTableEntryStore::addEntry(NetworkTableEntry* newEntry){
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
NetworkTableEntry* entry = (NetworkTableEntry*)namedEntries[newEntry->name];
if(entry!=NULL){
@@ -42,7 +42,7 @@
bool ClientNetworkTableEntryStore::updateEntry(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value) {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
entry->ForcePut(sequenceNumber, value);
if(entry->GetId()==NetworkTableEntry::UNKNOWN_ID){
return false;
@@ -58,7 +58,7 @@
*/
void ClientNetworkTableEntryStore::sendUnknownEntries(NetworkTableConnection& connection) {
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator itr;
for(itr = namedEntries.begin(); itr != namedEntries.end(); itr++)
{
diff --git a/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.h b/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.h
index dacee43..8dd171c 100644
--- a/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.h
+++ b/aos/externals/WPILib/WPILib/networktables2/client/ClientNetworkTableEntryStore.h
@@ -14,7 +14,7 @@
#include "networktables2/AbstractNetworkTableEntryStore.h"
#include "networktables2/NetworkTableEntry.h"
-#include "Synchronized.h"
+#include "OSAL/Synchronized.h"
/**
* The entry store for a {@link NetworkTableClient}
diff --git a/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.cpp b/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.cpp
index 8fb6a2d..08bbf4b 100644
--- a/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.cpp
@@ -6,7 +6,6 @@
*/
#include "networktables2/client/NetworkTableClient.h"
-#include "networktables2/TransactionDirtier.h"
/**
* Create a new NetworkTable Client
@@ -16,14 +15,22 @@
*/
NetworkTableClient::NetworkTableClient(IOStreamFactory& streamFactory, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager):
NetworkTableNode(*new ClientNetworkTableEntryStore(*this)),
- adapter((ClientNetworkTableEntryStore&)entryStore, threadManager, streamFactory, *this, typeManager),
- writeManager(adapter, threadManager, GetEntryStore(), 1000){
+ adapter(*new ClientConnectionAdapter((ClientNetworkTableEntryStore&)entryStore, threadManager, streamFactory, *this, typeManager)),
+ writeManager(*new WriteManager(adapter, threadManager, GetEntryStore(), 1000)),
+ dirtier(new TransactionDirtier(writeManager)){
- GetEntryStore().SetOutgoingReceiver(new TransactionDirtier(writeManager));
+ GetEntryStore().SetOutgoingReceiver(dirtier);
GetEntryStore().SetIncomingReceiver(&OutgoingEntryReceiver_NULL);
writeManager.start();
}
-NetworkTableClient::~NetworkTableClient(){}
+NetworkTableClient::~NetworkTableClient(){
+ //Closing this now will cause a reconnect from the write manager -James
+ //Close();
+ delete &writeManager;
+ delete &adapter;
+ delete &entryStore;
+ delete dirtier;
+}
/**
* force the client to disconnect and reconnect to the server again. Will connect if the client is currently disconnected
diff --git a/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.h b/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.h
index 7303298..0dbe2f0 100644
--- a/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.h
+++ b/aos/externals/WPILib/WPILib/networktables2/client/NetworkTableClient.h
@@ -13,6 +13,7 @@
#include "networktables2/NetworkTableNode.h"
#include "networktables2/client/ClientConnectionAdapter.h"
#include "networktables2/WriteManager.h"
+#include "networktables2/TransactionDirtier.h"
/**
* A client node in NetworkTables 2.0
@@ -22,8 +23,9 @@
*/
class NetworkTableClient : public NetworkTableNode{
private:
- ClientConnectionAdapter adapter;
- WriteManager writeManager;
+ ClientConnectionAdapter& adapter;
+ WriteManager& writeManager;
+ TransactionDirtier* dirtier;
public:
/**
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionAdapter.h b/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionAdapter.h
index e8dc494..277c011 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionAdapter.h
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionAdapter.h
@@ -10,8 +10,8 @@
class ConnectionAdapter;
-#include "../NetworkTableEntry.h"
-#include "BadMessageException.h"
+#include "networktables2/NetworkTableEntry.h"
+#include "networktables2/connection/BadMessageException.h"
#include "networktables2/util/IOException.h"
#include "tables/ITable.h"
@@ -21,7 +21,8 @@
virtual ~ConnectionAdapter()
{
}
- virtual void keepAlive() = 0;
+ //returns true if the connection should still be alive
+ virtual bool keepAlive() = 0;
virtual void clientHello(ProtocolVersion protocolRevision) = 0;
virtual void serverHelloComplete() = 0;
virtual void protocolVersionUnsupported(ProtocolVersion protocolRevision) = 0;
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.cpp b/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.cpp
index 75ff177..1cd4a02 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.cpp
@@ -7,7 +7,7 @@
#include "networktables2/connection/ConnectionMonitorThread.h"
#include "networktables2/connection/BadMessageException.h"
-
+#include "networktables2/util/System.h"
ConnectionMonitorThread::ConnectionMonitorThread(ConnectionAdapter& _adapter, NetworkTableConnection& _connection) :
adapter(_adapter), connection(_connection) {
@@ -15,12 +15,21 @@
void ConnectionMonitorThread::run() {
- try{
- connection.read(adapter);
- } catch(BadMessageException& e){
- adapter.badMessage(e);
- } catch(IOException& e){
- adapter.ioException(e);
+ if (adapter.keepAlive())
+ {
+ try{
+ connection.read(adapter);
+ } catch(BadMessageException& e){
+ adapter.badMessage(e);
+ } catch(IOException& e){
+ adapter.ioException(e);
+ }
+ }
+ else
+ {
+ sleep_ms(10); //avoid busy-wait
+ //Test to see this working properly
+ //printf("--ConnectionMonitorThread::run Waiting to close\n");
}
}
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.h b/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.h
index 5068244..64c96b5 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.h
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/ConnectionMonitorThread.h
@@ -11,9 +11,9 @@
class ConnectionMonitorThread;
-#include "ConnectionAdapter.h"
-#include "NetworkTableConnection.h"
-#include "../thread/PeriodicRunnable.h"
+#include "networktables2/connection/ConnectionAdapter.h"
+#include "networktables2/connection/NetworkTableConnection.h"
+#include "networktables2/thread/PeriodicRunnable.h"
@@ -35,6 +35,8 @@
* @param connection
*/
ConnectionMonitorThread(ConnectionAdapter& adapter, NetworkTableConnection& connection);
+ //This can be used it identify which connection adapter instance the thread procedure is running (read-only)
+ const NetworkTableConnection *GetNetworkTableConnection() const {return &connection;}
void run();
};
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.cpp b/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.cpp
index 2152240..f9e1b63 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.cpp
@@ -5,23 +5,45 @@
#include <malloc.h>
#endif
+///This is used in case NULL is passed so all logic calls to IOstream can continue to assume there is never a null pointer
+class InertStream : public IOStream
+{
+protected:
+ virtual int read(void* ptr, int numbytes) {return numbytes;} //return success
+ virtual int write(const void* ptr, int numbytes) {return numbytes;}
+ virtual void flush() {}
+ virtual void close() {}
+};
+
+static InertStream s_InertStream;
+
DataIOStream::DataIOStream(IOStream* _iostream) :
- iostream(*_iostream)
+ iostream(_iostream)
{
}
DataIOStream::~DataIOStream()
{
close();
- delete &iostream;
+ if (iostream!=&s_InertStream)
+ delete iostream;
}
+
+void DataIOStream::SetIOStream(IOStream* stream)
+{
+ IOStream *temp=iostream;
+ iostream=stream ? stream : &s_InertStream; //We'll never assign NULL
+ if (temp!=&s_InertStream)
+ delete temp;
+}
+
void DataIOStream::close()
{
- iostream.close();
+ iostream->close();
}
void DataIOStream::writeByte(uint8_t b)
{
- iostream.write(&b, 1);
+ iostream->write(&b, 1);
}
void DataIOStream::write2BytesBE(uint16_t s)
{
@@ -31,16 +53,16 @@
void DataIOStream::writeString(std::string& str)
{
write2BytesBE(str.length());
- iostream.write(str.c_str(), str.length());
+ iostream->write(str.c_str(), str.length());
}
void DataIOStream::flush()
{
- iostream.flush();
+ iostream->flush();
}
uint8_t DataIOStream::readByte()
{
uint8_t value;
- iostream.read(&value, 1);
+ iostream->read(&value, 1);
return value;
}
uint16_t DataIOStream::read2BytesBE()
@@ -58,7 +80,7 @@
#else
uint8_t* bytes = (uint8_t*)alloca(byteLength+1);
#endif
- iostream.read(bytes, byteLength);
+ iostream->read(bytes, byteLength);
bytes[byteLength] = 0;
return new std::string((char*)bytes);//FIXME implement UTF-8 aware version
}
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.h b/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.h
index bd52c93..a653892 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.h
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/DataIOStream.h
@@ -2,7 +2,7 @@
#define DATAIOSTREAM_H_
#include <stdlib.h>
-#include "../stream/IOStream.h"
+#include "networktables2/stream/IOStream.h"
#include <exception>
#include <string>
@@ -41,8 +41,10 @@
std::string* readString();
void close();
+ void SetIOStream(IOStream* stream);
+
//private:
- IOStream& iostream;
+ IOStream *iostream;
};
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.cpp b/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.cpp
index d9dcc34..6f675b0 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.cpp
@@ -17,9 +17,14 @@
delete ioStream;
}
+void NetworkTableConnection::SetIOStream(IOStream* stream)
+{
+ ioStream->SetIOStream(stream); //just passing through
+}
+
void NetworkTableConnection::close() {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
if (isValid) {
isValid = false;
ioStream->close();
@@ -28,7 +33,7 @@
}
void NetworkTableConnection::flush() {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
ioStream->flush();
}
}
@@ -36,14 +41,14 @@
void NetworkTableConnection::sendMessageHeader(
NetworkTableMessageType messageType) {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
ioStream->writeByte((uint8_t) messageType);
}
}
void NetworkTableConnection::sendKeepAlive() {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
sendMessageHeader(KEEP_ALIVE);
flush();
}
@@ -51,7 +56,7 @@
void NetworkTableConnection::sendClientHello() {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
sendMessageHeader(CLIENT_HELLO);
ioStream->write2BytesBE(PROTOCOL_REVISION);
flush();
@@ -59,7 +64,7 @@
}
void NetworkTableConnection::sendServerHelloComplete() {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
sendMessageHeader(SERVER_HELLO_COMPLETE);
flush();
}
@@ -67,7 +72,7 @@
void NetworkTableConnection::sendProtocolVersionUnsupported() {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
sendMessageHeader(PROTOCOL_VERSION_UNSUPPORTED);
ioStream->write2BytesBE(PROTOCOL_REVISION);
flush();
@@ -76,7 +81,7 @@
void NetworkTableConnection::sendEntryAssignment(NetworkTableEntry& entry) {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
sendMessageHeader(ENTRY_ASSIGNMENT);
ioStream->writeString(entry.name);
ioStream->writeByte(entry.GetType()->id);
@@ -88,7 +93,7 @@
void NetworkTableConnection::sendEntryUpdate(NetworkTableEntry& entry) {
{
- Synchronized sync(WRITE_LOCK);
+ NTSynchronized sync(WRITE_LOCK);
sendMessageHeader(FIELD_UPDATE);
ioStream->write2BytesBE(entry.GetId());
ioStream->write2BytesBE(entry.GetSequenceNumber());
diff --git a/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.h b/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.h
index 08317e8..e73a835 100644
--- a/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.h
+++ b/aos/externals/WPILib/WPILib/networktables2/connection/NetworkTableConnection.h
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "Synchronized.h"
+#include "OSAL/Synchronized.h"
#ifndef _WRS_KERNEL
#include <stdint.h>
#endif
@@ -19,12 +19,12 @@
class NetworkTableConnection;
typedef uint16_t ProtocolVersion;
-#include "DataIOStream.h"
-#include "../NetworkTableEntry.h"
-#include "../type/NetworkTableEntryType.h"
-#include "../type/NetworkTableEntryTypeManager.h"
-#include "ConnectionAdapter.h"
-#include "../NetworkTableMessageType.h"
+#include "networktables2/connection/DataIOStream.h"
+#include "networktables2/NetworkTableEntry.h"
+#include "networktables2/type/NetworkTableEntryType.h"
+#include "networktables2/type/NetworkTableEntryTypeManager.h"
+#include "networktables2/connection/ConnectionAdapter.h"
+#include "networktables2/NetworkTableMessageType.h"
class NetworkTableConnection{
@@ -42,8 +42,9 @@
void sendEntryAssignment(NetworkTableEntry& entry);
void sendEntryUpdate(NetworkTableEntry& entry);
void read(ConnectionAdapter& adapter);
+ void SetIOStream(IOStream* stream);
private:
- ReentrantSemaphore WRITE_LOCK;
+ NTReentrantSemaphore WRITE_LOCK;
DataIOStream* const ioStream;
NetworkTableEntryTypeManager& typeManager;
bool isValid;
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.cpp b/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.cpp
index fae14e5..ea85356 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.cpp
@@ -13,9 +13,9 @@
NetworkTableServer::NetworkTableServer(IOStreamProvider& _streamProvider, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager):
NetworkTableNode(*new ServerNetworkTableEntryStore(*this)),
streamProvider(_streamProvider),
- connectionList(),
- writeManager(connectionList, threadManager, GetEntryStore(), ULONG_MAX),
incomingStreamMonitor(streamProvider, (ServerNetworkTableEntryStore&)entryStore, *this, connectionList, typeManager, threadManager),
+ connectionList(&incomingStreamMonitor),
+ writeManager(connectionList, threadManager, GetEntryStore(), ULONG_MAX),
continuingReceiver(writeManager){
GetEntryStore().SetIncomingReceiver(&continuingReceiver);
@@ -24,6 +24,7 @@
incomingStreamMonitor.start();
writeManager.start();
}
+//TODO implement simplified NetworkTableServer constructor
/*NetworkTableServer::NetworkTableServer(IOStreamProvider& streamProvider){
this(streamProvider, new NetworkTableEntryTypeManager(), new DefaultThreadManager());
}*/
@@ -37,7 +38,6 @@
incomingStreamMonitor.stop();
writeManager.stop();
connectionList.closeAll();
- streamProvider.close();
} catch (const std::exception& ex) {
//TODO print stack trace?
}
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.h b/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.h
index 6af6870..d38e44f 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/NetworkTableServer.h
@@ -13,11 +13,11 @@
#include "networktables2/TransactionDirtier.h"
#include "networktables2/NetworkTableNode.h"
-#include "ServerIncomingStreamMonitor.h"
-#include "ServerIncomingConnectionListener.h"
+#include "networktables2/server/ServerIncomingStreamMonitor.h"
+#include "networktables2/server/ServerIncomingConnectionListener.h"
#include "networktables2/WriteManager.h"
#include "networktables2/stream/IOStreamProvider.h"
-#include "ServerConnectionList.h"
+#include "networktables2/server/ServerConnectionList.h"
/**
* A server node in NetworkTables 2.0
@@ -28,9 +28,9 @@
class NetworkTableServer : public NetworkTableNode, public ServerIncomingConnectionListener{
private:
IOStreamProvider& streamProvider;
+ ServerIncomingStreamMonitor incomingStreamMonitor;
ServerConnectionList connectionList;
WriteManager writeManager;
- ServerIncomingStreamMonitor incomingStreamMonitor;
TransactionDirtier continuingReceiver;
public:
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerAdapterManager.h b/aos/externals/WPILib/WPILib/networktables2/server/ServerAdapterManager.h
index c6e967c..bc15254 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerAdapterManager.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerAdapterManager.h
@@ -10,7 +10,7 @@
class ServerAdapterManager;
-#include "ServerConnectionAdapter.h"
+#include "networktables2/server/ServerConnectionAdapter.h"
/**
* A class that manages connections to a server
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.cpp b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.cpp
index 34f262d..195f6e7 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.cpp
@@ -11,7 +11,7 @@
void ServerConnectionAdapter::gotoState(ServerConnectionState* newState){
if(connectionState!=newState){
- fprintf(stdout, "%p entered connection state: %s\n",this, newState->toString());
+ fprintf(stdout, "[NT] %p entered connection state: %s\n", (void*)this, newState->toString());
fflush(stdout);
connectionState = newState;
}
@@ -19,7 +19,7 @@
ServerConnectionAdapter::ServerConnectionAdapter(IOStream* stream, ServerNetworkTableEntryStore& _entryStore, IncomingEntryReceiver& _transactionReceiver, ServerAdapterManager& _adapterListener, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager) :
entryStore(_entryStore), transactionReceiver(_transactionReceiver), adapterListener(_adapterListener),
- connection(stream, typeManager), monitorThread(*this, connection){
+ connection(stream, typeManager), monitorThread(*this, connection), m_IsAdapterListenerClosed(false) {
connectionState = &ServerConnectionState::CLIENT_DISCONNECTED;
gotoState(&ServerConnectionState::GOT_CONNECTION_FROM_CLIENT);
readThread = threadManager.newBlockingPeriodicThread(&monitorThread, "Server Connection Reader Thread");
@@ -31,20 +31,22 @@
void ServerConnectionAdapter::badMessage(BadMessageException& e) {
- fprintf(stdout, "Bad message: %s\n", e.what());
+ fprintf(stdout, "[NT] Bad message: %s\n", e.what());
fflush(stdout);
gotoState(new ServerConnectionState_Error(e));
adapterListener.close(*this, true);
+ m_IsAdapterListenerClosed=true;
}
void ServerConnectionAdapter::ioException(IOException& e) {
- fprintf(stdout, "IOException message: %s\n", e.what());
+ fprintf(stdout, "[NT] IOException message: %s\n", e.what());
fflush(stdout);
if(e.isEOF())
gotoState(&ServerConnectionState::CLIENT_DISCONNECTED);
else
gotoState(new ServerConnectionState_Error(e));
adapterListener.close(*this, false);
+ m_IsAdapterListenerClosed=true;
}
@@ -54,8 +56,8 @@
connection.close();
}
-void ServerConnectionAdapter::keepAlive() {
- //just let it happen
+bool ServerConnectionAdapter::keepAlive() {
+ return !m_IsAdapterListenerClosed; //returns true as long as the adapter listener has not been flagged for closing
}
void ServerConnectionAdapter::clientHello(ProtocolVersion protocolRevision) {
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.h b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.h
index 6db1e0b..f1a268c 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionAdapter.h
@@ -30,7 +30,7 @@
* @author Mitchell
*
*/
-class ServerConnectionAdapter : ConnectionAdapter, IncomingEntryReceiver, FlushableOutgoingEntryReceiver{
+class ServerConnectionAdapter : public ConnectionAdapter, public IncomingEntryReceiver, public FlushableOutgoingEntryReceiver{
private:
ServerNetworkTableEntryStore& entryStore;
IncomingEntryReceiver& transactionReceiver;
@@ -48,7 +48,7 @@
ServerConnectionState* connectionState;
void gotoState(ServerConnectionState* newState);
-
+ bool m_IsAdapterListenerClosed;
public:
/**
* Create a server connection adapter for a given stream
@@ -63,44 +63,39 @@
ServerConnectionAdapter(IOStream* stream, ServerNetworkTableEntryStore& entryStore, IncomingEntryReceiver& transactionReceiver, ServerAdapterManager& adapterListener, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager);
virtual ~ServerConnectionAdapter();
- void badMessage(BadMessageException& e);
-
- void ioException(IOException& e);
-
-
/**
- * stop the read thread and close the stream
- */
+ * stop the read thread and close the stream
+ */
void shutdown(bool closeStream);
- void keepAlive();
-
- void clientHello(ProtocolVersion protocolRevision);
-
- void protocolVersionUnsupported(ProtocolVersion protocolRevision);
-
- void serverHelloComplete();
-
- void offerIncomingAssignment(NetworkTableEntry* entry);
-
- void offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
-
- NetworkTableEntry* GetEntry(EntryId id);
-
void offerOutgoingAssignment(NetworkTableEntry* entry);
-
+
void offerOutgoingUpdate(NetworkTableEntry* entry);
void flush();
/**
- * @return the state of the connection
- */
+ * @return the state of the connection
+ */
ServerConnectionState* getConnectionState();
void ensureAlive();
+ //return true once the close has been issued
+ bool IsAdapterListenerClosed() const {return m_IsAdapterListenerClosed;}
+ ConnectionAdapter &AsConnectionAdapter() {return *this;}
+protected: //from ConnectionAdapter
+
+ bool keepAlive();
+ void badMessage(BadMessageException& e);
+ void ioException(IOException& e);
+ void clientHello(ProtocolVersion protocolRevision);
+ void protocolVersionUnsupported(ProtocolVersion protocolRevision);
+ void serverHelloComplete();
+ void offerIncomingAssignment(NetworkTableEntry* entry);
+ void offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
+ NetworkTableEntry* GetEntry(EntryId id);
};
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.cpp b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.cpp
index c774577..731333f 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.cpp
@@ -6,12 +6,13 @@
*/
#include "networktables2/server/ServerConnectionList.h"
+#include "networktables2/server/ServerIncomingStreamMonitor.h"
#include <algorithm>
#include <stdio.h>
-ServerConnectionList::ServerConnectionList()
+ServerConnectionList::ServerConnectionList(ServerIncomingStreamMonitor *Factory) : m_Factory(Factory)
{
}
ServerConnectionList::~ServerConnectionList()
@@ -22,27 +23,28 @@
void ServerConnectionList::add(ServerConnectionAdapter& connection)
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
connections.push_back(&connection);
}
void ServerConnectionList::close(ServerConnectionAdapter& connectionAdapter, bool closeStream)
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
std::vector<ServerConnectionAdapter*>::iterator connectionPosition = std::find(connections.begin(), connections.end(), &connectionAdapter);
if (connectionPosition != connections.end() && (*connectionPosition)==&connectionAdapter)
{
- fprintf(stdout, "Close: %p\n", &connectionAdapter);
+ fprintf(stdout, "[NT] Close: %p\n", (void*)&connectionAdapter);
fflush(stdout);
connections.erase(connectionPosition);
- connectionAdapter.shutdown(closeStream);
- delete &connectionAdapter;
+ m_Factory->close(&connectionAdapter);
+ //connectionAdapter.shutdown(closeStream);
+ //delete &connectionAdapter;
}
}
void ServerConnectionList::closeAll()
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
while(connections.size() > 0)
{
close(*connections[0], true);
@@ -51,7 +53,7 @@
void ServerConnectionList::offerOutgoingAssignment(NetworkTableEntry* entry)
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
for(unsigned int i = 0; i < connections.size(); ++i)
{
connections[i]->offerOutgoingAssignment(entry);
@@ -59,7 +61,7 @@
}
void ServerConnectionList::offerOutgoingUpdate(NetworkTableEntry* entry)
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
for(unsigned int i = 0; i < connections.size(); ++i)
{
connections[i]->offerOutgoingUpdate(entry);
@@ -67,7 +69,7 @@
}
void ServerConnectionList::flush()
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
for(unsigned int i = 0; i < connections.size(); ++i)
{
connections[i]->flush();
@@ -75,7 +77,7 @@
}
void ServerConnectionList::ensureAlive()
{
- Synchronized sync(connectionsLock);
+ NTSynchronized sync(connectionsLock);
for(unsigned int i = 0; i < connections.size(); ++i)
{
connections[i]->ensureAlive();
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.h b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.h
index fb6573c..8b3211e 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerConnectionList.h
@@ -11,12 +11,12 @@
class ServerConnectionList;
-
+class ServerIncomingStreamMonitor;
#include "networktables2/FlushableOutgoingEntryReceiver.h"
#include "networktables2/NetworkTableEntry.h"
-#include "ServerAdapterManager.h"
-#include "ServerConnectionAdapter.h"
+#include "networktables2/server/ServerAdapterManager.h"
+#include "networktables2/server/ServerConnectionAdapter.h"
#include <vector>
@@ -29,11 +29,11 @@
*/
class ServerConnectionList : public FlushableOutgoingEntryReceiver, public ServerAdapterManager{
private:
- ReentrantSemaphore connectionsLock;
+ NTReentrantSemaphore connectionsLock;
std::vector<ServerConnectionAdapter*> connections;
-
+ ServerIncomingStreamMonitor * const m_Factory; //make call to close connection
public:
- ServerConnectionList();
+ ServerConnectionList(ServerIncomingStreamMonitor *Factory);
virtual ~ServerConnectionList();
/**
* Add a connection to the list
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingConnectionListener.h b/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingConnectionListener.h
index 0ec2fe7..82ec0d1 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingConnectionListener.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingConnectionListener.h
@@ -8,7 +8,7 @@
#ifndef SERVERINCOMINGCONNECTIONLISTENER_H_
#define SERVERINCOMINGCONNECTIONLISTENER_H_
-#include "ServerConnectionAdapter.h"
+#include "networktables2/server/ServerConnectionAdapter.h"
/**
* Listener for new incoming server connections
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.cpp b/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.cpp
index 139439a..51c5733 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.cpp
@@ -16,6 +16,11 @@
{
}
+ServerIncomingStreamMonitor::~ServerIncomingStreamMonitor()
+{
+ stop();
+}
+
/**
* Start the monitor thread
*/
@@ -32,9 +37,11 @@
{
if (monitorThread != NULL)
{
- monitorThread->stop();
- delete monitorThread;
- monitorThread = NULL;
+ streamProvider.close(); //This would get called on deletion too
+ NTThread *temp=monitorThread;
+ monitorThread = NULL; //call this before stop for the check below to ensure a new server connection adapter will not happen
+ temp->stop();
+ delete temp;
}
}
@@ -42,11 +49,26 @@
{
try
{
- IOStream* newStream = streamProvider.accept();
- if(newStream != NULL)
+ while (monitorThread!=NULL)
{
- ServerConnectionAdapter* connectionAdapter = new ServerConnectionAdapter(newStream, entryStore, entryStore, adapterListener, typeManager, threadManager);
- incomingListener.OnNewConnection(*connectionAdapter);
+ IOStream* newStream = streamProvider.accept();
+ {
+ NTSynchronized sync(BlockDeletionList);
+ for (size_t i=0;i<m_DeletionList.size();i++)
+ {
+ ServerConnectionAdapter *Element=m_DeletionList[i];
+ Element->shutdown(true); //TODO assume to always close stream
+ delete Element;
+ }
+ m_DeletionList.clear();
+ }
+ //Note: monitorThread must be checked to avoid crash on exit
+ // [8/31/2013 Terminator]
+ if ((monitorThread!=NULL)&&(newStream != NULL))
+ {
+ ServerConnectionAdapter* connectionAdapter = new ServerConnectionAdapter(newStream, entryStore, entryStore, adapterListener, typeManager, threadManager);
+ incomingListener.OnNewConnection(*connectionAdapter);
+ }
}
}
catch (IOException& e)
@@ -55,3 +77,8 @@
}
}
+void ServerIncomingStreamMonitor::close(ServerConnectionAdapter *Adapter)
+{
+ NTSynchronized sync(BlockDeletionList);
+ m_DeletionList.push_back(Adapter);
+}
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.h b/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.h
index f81ff4e..7b2ba5a 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerIncomingStreamMonitor.h
@@ -40,6 +40,8 @@
NTThreadManager& threadManager;
NTThread* monitorThread;
+ NTReentrantSemaphore BlockDeletionList;
+ std::vector<ServerConnectionAdapter *> m_DeletionList;
public:
/**
* Create a new incoming stream monitor
@@ -55,6 +57,7 @@
ServerAdapterManager& adapterListener,
NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager);
+ ~ServerIncomingStreamMonitor();
/**
* Start the monitor thread
*/
@@ -66,7 +69,7 @@
void run();
-
+ void close(ServerConnectionAdapter *Adapter);
};
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.cpp b/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.cpp
index 2427d90..b1d86c9 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.cpp
@@ -18,7 +18,7 @@
bool ServerNetworkTableEntryStore::addEntry(NetworkTableEntry* newEntry)
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
NetworkTableEntry* entry = namedEntries[newEntry->name];
if (entry == NULL)
@@ -33,7 +33,7 @@
bool ServerNetworkTableEntryStore::updateEntry(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value)
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
return entry->PutValue(sequenceNumber, value);
}
@@ -44,7 +44,7 @@
*/
void ServerNetworkTableEntryStore::sendServerHello(NetworkTableConnection& connection)
{
- Synchronized sync(LOCK);
+ NTSynchronized sync(LOCK);
std::map<std::string, NetworkTableEntry*>::iterator itr;
for (itr = namedEntries.begin(); itr != namedEntries.end(); itr++)
{
diff --git a/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.h b/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.h
index 8a9cead..f9c4621 100644
--- a/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.h
+++ b/aos/externals/WPILib/WPILib/networktables2/server/ServerNetworkTableEntryStore.h
@@ -14,7 +14,7 @@
#include "networktables2/AbstractNetworkTableEntryStore.h"
#include "networktables2/NetworkTableEntry.h"
-#include "Synchronized.h"
+#include "OSAL/Synchronized.h"
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.cpp b/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.cpp
index 5f9fa3e..da8e13d 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.cpp
@@ -13,9 +13,12 @@
#include <stdlib.h>
#ifdef _WRS_KERNEL
#include <ioLib.h>
+#include <selectLib.h>
#else
#include <unistd.h>
+#include <sys/time.h>
#endif
+#include <string.h>
#include <stdio.h>
@@ -34,18 +37,34 @@
return 0;
char* bufferPointer = (char*)ptr;
int totalRead = 0;
+
+ struct timeval timeout;
+ fd_set fdSet;
+
while (totalRead < numbytes) {
- int numRead = ::read(fd, bufferPointer, numbytes-totalRead);
- if(numRead == 0){
- throw EOFException();
+ FD_ZERO(&fdSet);
+ FD_SET(fd, &fdSet);
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+ int select_result = select(FD_SETSIZE, &fdSet, NULL, NULL, &timeout);
+ if ( select_result < 0)
+ throw IOException("Select returned an error on read");
+
+ int numRead = 0;
+ if (FD_ISSET(fd, &fdSet)) {
+ numRead = ::read(fd, bufferPointer, numbytes-totalRead);
+
+ if(numRead == 0){
+ throw EOFException();
+ }
+ else if (numRead < 0) {
+ perror("read error: ");
+ fflush(stderr);
+ throw IOException("Error on FDIO read");
+ }
+ bufferPointer += numRead;
+ totalRead += numRead;
}
- else if (numRead < 0) {
- perror("read error: ");
- fflush(stderr);
- throw IOException("Error on FDIO read");
- }
- bufferPointer += numRead;
- totalRead += numRead;
}
return totalRead;
}
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.h b/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.h
index df8048a..574bbc6 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.h
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/FDIOStream.h
@@ -13,7 +13,7 @@
class FDIOStream;
-#include "IOStream.h"
+#include "networktables2/stream/IOStream.h"
#include <stdio.h>
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamFactory.h b/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamFactory.h
index 537e201..79a3920 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamFactory.h
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamFactory.h
@@ -8,7 +8,7 @@
#ifndef IOSTREAMFACTORY_H_
#define IOSTREAMFACTORY_H_
-#include "IOStream.h"
+#include "networktables2/stream/IOStream.h"
/**
* A factory that will create the same IOStream. A stream returned by this factory should be closed before calling createStream again
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamProvider.h b/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamProvider.h
index 138b690..77f2bf8 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamProvider.h
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/IOStreamProvider.h
@@ -8,7 +8,7 @@
#ifndef IOSTREAMPROVIDER_H_
#define IOSTREAMPROVIDER_H_
-#include "IOStream.h"
+#include "networktables2/stream/IOStream.h"
/**
* An object that will provide the IOStream of clients to a NetworkTable Server
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.cpp b/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.cpp
index b4bbc00..cf1175c 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.cpp
@@ -40,7 +40,7 @@
#endif
#endif
-#ifndef ERROR
+#ifndef _WRS_KERNEL
#define ERROR -1
#endif
@@ -93,30 +93,31 @@
IOStream* SocketServerStreamProvider::accept(){
struct timeval timeout;
// Check for a shutdown once per second
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
while (true)
{
fd_set fdSet;
FD_ZERO(&fdSet);
FD_SET(serverSocket, &fdSet);
- if (select(FD_SETSIZE, &fdSet, NULL, NULL, &timeout) > 0)
- {
- if (FD_ISSET(serverSocket, &fdSet))
- {
- struct sockaddr clientAddr = {0};
- addrlen_t clientAddrSize = 0;
- int connectedSocket = ::accept(serverSocket, &clientAddr, &clientAddrSize);
- if (connectedSocket == ERROR)
- return NULL;
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+ int select_result = select(FD_SETSIZE, &fdSet, NULL, NULL, &timeout);
+ if ( select_result < 0)
+ return NULL;
+
+ if (FD_ISSET(serverSocket, &fdSet))
+ {
+ struct sockaddr clientAddr;
+ memset(&clientAddr, 0, sizeof(struct sockaddr));
+ addrlen_t clientAddrSize = sizeof(clientAddr);
+ int connectedSocket = ::accept(serverSocket, &clientAddr, &clientAddrSize);
+ if (connectedSocket == ERROR)
+ return NULL;
- //int on = 1;
- //setsockopt(connectedSocket, IPPROTO_TCP, TCP_NODELAY, (char *)&on, sizeof(on));
-
- return new FDIOStream(connectedSocket);
- }
- }
+ return new FDIOStream(connectedSocket);
+ }
+
+
}
return NULL;
}
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.h b/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.h
index 6efe5fd..8813e2e 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.h
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/SocketServerStreamProvider.h
@@ -11,8 +11,8 @@
class SocketServerStreamProvider;
-#include "IOStream.h"
-#include "IOStreamProvider.h"
+#include "networktables2/stream/IOStream.h"
+#include "networktables2/stream/IOStreamProvider.h"
diff --git a/aos/externals/WPILib/WPILib/networktables2/stream/SocketStreams.h b/aos/externals/WPILib/WPILib/networktables2/stream/SocketStreams.h
index daa2376..8887197 100644
--- a/aos/externals/WPILib/WPILib/networktables2/stream/SocketStreams.h
+++ b/aos/externals/WPILib/WPILib/networktables2/stream/SocketStreams.h
@@ -12,8 +12,8 @@
class SocketStreams;
-#include "IOStreamFactory.h"
-#include "IOStreamProvider.h"
+#include "networktables2/stream/IOStreamFactory.h"
+#include "networktables2/stream/IOStreamProvider.h"
diff --git a/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManager.h b/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManager.h
index a793405..9519a7a 100644
--- a/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManager.h
+++ b/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManager.h
@@ -1,5 +1,6 @@
/*
* DefaultThreadManager.h
+ * Desktop
*
* Created on: Sep 21, 2012
* Author: Mitchell Wills
@@ -8,29 +9,42 @@
#ifndef DEFAULTTHREADMANAGER_H_
#define DEFAULTTHREADMANAGER_H_
+
class DefaultThreadManager;
class PeriodicNTThread;
#include "networktables2/thread/PeriodicRunnable.h"
#include "networktables2/thread/NTThreadManager.h"
#include "networktables2/thread/NTThread.h"
-#include "Task.h"
-
-
+#if (defined __vxworks || defined WIN32)
+#include "OSAL/Task.h"
+#else
+#include <pthread.h>
+#endif
class DefaultThreadManager : public NTThreadManager{
+public:
virtual NTThread* newBlockingPeriodicThread(PeriodicRunnable* r, const char* name);
};
class PeriodicNTThread : public NTThread {
private:
+#if (defined __vxworks || defined WIN32)
const char* name;
- Task* thread;
+ NTTask* thread;
+#else
+ pthread_t thread;
+#endif
PeriodicRunnable* r;
bool run;
+#if (defined __vxworks || defined WIN32)
int _taskMain();
static int taskMain(PeriodicNTThread* o);
+#else//TODO make return int for pthread as well
+ void _taskMain();
+ static void* taskMain(PeriodicNTThread* o);
+#endif
public:
PeriodicNTThread(PeriodicRunnable* r, const char* name);
virtual ~PeriodicNTThread();
@@ -38,5 +52,4 @@
virtual bool isRunning();
};
-
#endif /* DEFAULTTHREADMANAGER_H_ */
diff --git a/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManger.cpp b/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManger.cpp
index bc95344..ebc5edf 100644
--- a/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManger.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/thread/DefaultThreadManger.cpp
@@ -10,7 +10,7 @@
PeriodicNTThread::PeriodicNTThread(PeriodicRunnable* _r, const char* _name) :
- name(_name), thread(new Task(name, (FUNCPTR)PeriodicNTThread::taskMain)), r(_r), run(true){
+ name(_name), thread(new NTTask(name, (FUNCPTR)PeriodicNTThread::taskMain)), r(_r), run(true){
fprintf(stdout, "Starting task: %s\n", name);
fflush(stdout);
thread->Start((UINT32)this);
@@ -29,17 +29,16 @@
r->run();
}
} catch (...) {
- fprintf(stdout, "Task exited with uncaught exception %s\n", name);
+ fprintf(stdout, "NTTask exited with uncaught exception %s\n", name);
fflush(stdout);
return 1;
}
- fprintf(stdout, "Task exited normally: %s\n", name);
+ fprintf(stdout, "NTTask exited normally: %s\n", name);
fflush(stdout);
return 0;
}
void PeriodicNTThread::stop() {
run = false;
- //TODO thread->Stop();
}
bool PeriodicNTThread::isRunning() {
return thread->IsReady();
diff --git a/aos/externals/WPILib/WPILib/networktables2/thread/NTThreadManager.h b/aos/externals/WPILib/WPILib/networktables2/thread/NTThreadManager.h
index a5c8698..a376cb7 100644
--- a/aos/externals/WPILib/WPILib/networktables2/thread/NTThreadManager.h
+++ b/aos/externals/WPILib/WPILib/networktables2/thread/NTThreadManager.h
@@ -10,7 +10,7 @@
class NTThreadManager;
-#include "NTThread.h"
+#include "networktables2/thread/NTThread.h"
#include "networktables2/thread/PeriodicRunnable.h"
/**
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.cpp b/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.cpp
index 386fff5..3d0f84a 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.cpp
@@ -18,6 +18,9 @@
m_size = 0;
data = NULL;
}
+ArrayData::~ArrayData(){
+ free(data);
+}
EntryValue ArrayData::_get(unsigned int index){//TODO bounds checking
return data[index];
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.h b/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.h
index 4cb733e..ffd2daa 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.h
+++ b/aos/externals/WPILib/WPILib/networktables2/type/ArrayData.h
@@ -10,8 +10,8 @@
class ArrayData;
-#include "ArrayEntryType.h"
-#include "ComplexData.h"
+#include "networktables2/type/ArrayEntryType.h"
+#include "networktables2/type/ComplexData.h"
#include "networktables2/NetworkTableEntry.h"
/**
@@ -30,7 +30,7 @@
* information that this ArrayData should satisfy.
*/
ArrayData(ArrayEntryType& type);
-
+ virtual ~ArrayData();
protected:
/**
* Gets the value stored at the specified index.
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.cpp b/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.cpp
index 719a738..ab433fe 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.cpp
@@ -17,6 +17,9 @@
void ArrayEntryType::deleteElement(EntryValue value){
m_elementType.deleteValue(value);
}
+bool ArrayEntryType::areElementsEqual(EntryValue v1, EntryValue v2){
+ return m_elementType.areEqual(v1, v2);
+}
void ArrayEntryType::sendValue(EntryValue value, DataIOStream& os) {
@@ -49,9 +52,9 @@
EntryValue ArrayEntryType::copyValue(EntryValue value){
ArrayEntryData* otherDataArray = (ArrayEntryData*) value.ptr;
- EntryValue* array = (EntryValue*)malloc(otherDataArray->length*sizeof(EntryValue));//TODO cache object arrays
+ EntryValue* array = (EntryValue*)malloc(otherDataArray->length*sizeof(EntryValue));
for (int i = 0; i < otherDataArray->length; ++i) {
- array[i] = m_elementType.copyValue(otherDataArray->array[i]);
+ array[i] = copyElement(otherDataArray->array[i]);
}
ArrayEntryData* dataArray = (ArrayEntryData*)malloc(sizeof(ArrayEntryData));
@@ -66,35 +69,58 @@
ArrayEntryData* dataArray = (ArrayEntryData*) value.ptr;
if(dataArray!=NULL){
for (int i = 0; i < dataArray->length; ++i) {
- m_elementType.deleteValue(dataArray->array[i]);
+ deleteElement(dataArray->array[i]);
}
- free(dataArray->array);
+ if(dataArray->array != NULL)
+ free(dataArray->array);
+
free(dataArray);
}
}
+bool ArrayEntryType::areEqual(EntryValue v1, EntryValue v2) {
+ ArrayEntryData* a1 = (ArrayEntryData*) v1.ptr;
+ ArrayEntryData* a2 = (ArrayEntryData*) v2.ptr;
+ if(a1->length != a2->length)
+ return false;
+ for (int i = 0; i < a1->length; ++i) {
+ if(!areElementsEqual(a1->array[i], a2->array[i]))
+ return false;
+ }
+ return true;
+}
EntryValue ArrayEntryType::internalizeValue(std::string& key, ComplexData& externalRepresentation, EntryValue currentInteralValue) {
// TODO: Argument 'key' appears unused.
ArrayData& externalArrayData = (ArrayData&)externalRepresentation;
+
+ EntryValue eValue = currentInteralValue;
ArrayEntryData* internalArray = (ArrayEntryData*) currentInteralValue.ptr;
- if(internalArray != NULL && internalArray->length==externalArrayData.size()){
+ if(internalArray == NULL){
+ internalArray = (ArrayEntryData*)malloc(sizeof(ArrayEntryData));
+ internalArray->length = 0;
+ internalArray->array = NULL;
+ eValue.ptr = internalArray;
+ }
+
+ if(internalArray->length==externalArrayData.size()){
for(int i = 0; i<internalArray->length; ++i){
- m_elementType.deleteValue(internalArray->array[i]);
- internalArray->array[i] = m_elementType.copyValue(externalArrayData._get(i));
+ deleteElement(internalArray->array[i]);
+ internalArray->array[i] = copyElement(externalArrayData._get(i));
}
- return currentInteralValue;
}
else{
- internalArray = (ArrayEntryData*)malloc(sizeof(ArrayEntryData));
- internalArray->array = (EntryValue*)malloc(externalArrayData.size()*sizeof(EntryValue));//TODO cache object arrays
+ if(internalArray->array != NULL)
+ free(internalArray->array);
internalArray->length = externalArrayData.size();
+ if(internalArray->length == 0)
+ internalArray->array = NULL;
+ else
+ internalArray->array = (EntryValue*)malloc(externalArrayData.size()*sizeof(EntryValue));
for (int i = 0; i < internalArray->length; ++i) {
- internalArray->array[i] = m_elementType.copyValue(externalArrayData._get(i));
+ internalArray->array[i] = copyElement(externalArrayData._get(i));
}
- EntryValue eValue;
- eValue.ptr = internalArray;
- return eValue;
}
+ return eValue;
}
void ArrayEntryType::exportValue(std::string& key, EntryValue internalData, ComplexData& externalRepresentation) {
@@ -102,6 +128,6 @@
ArrayData& externalArrayData = (ArrayData&)externalRepresentation;
externalArrayData.setSize(internalArray->length);
for(int i = 0; i<internalArray->length; ++i){
- externalArrayData._set(i, m_elementType.copyValue(internalArray->array[i]));
+ externalArrayData._set(i, copyElement(internalArray->array[i]));
}
}
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.h b/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.h
index 0a188a0..1556b82 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.h
+++ b/aos/externals/WPILib/WPILib/networktables2/type/ArrayEntryType.h
@@ -16,8 +16,8 @@
class ArrayEntryType;
-#include "ArrayData.h"
-#include "ComplexEntryType.h"
+#include "networktables2/type/ArrayData.h"
+#include "networktables2/type/ComplexEntryType.h"
struct ArrayEntryData{
uint8_t length;
@@ -65,6 +65,13 @@
* @param value The value to delete.
*/
void deleteElement(EntryValue value);
+
+ /**
+ * Compares two elements of the type of the array
+ *
+ * @return true if the elements are equal
+ */
+ bool areElementsEqual(EntryValue v1, EntryValue v2);
/**
* See {@link NetworkTableEntryType}::sendValue
@@ -85,6 +92,9 @@
* See {@link NetworkTableEntryType}::deleteValue
*/
void deleteValue(EntryValue value);
+
+
+ bool areEqual(EntryValue v1, EntryValue v2);
/**
* See {@link ComplexEntryType}::internalizeValue
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/ComplexData.h b/aos/externals/WPILib/WPILib/networktables2/type/ComplexData.h
index 629fc35..54ef618 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/ComplexData.h
+++ b/aos/externals/WPILib/WPILib/networktables2/type/ComplexData.h
@@ -12,7 +12,7 @@
class ComplexData;
-//#include "ComplexEntryType.h" can't do this cause it causes order of definition issues
+//#include "networktables2/type/ComplexEntryType.h" can't do this cause it causes order of definition issues
class ComplexEntryType;
/**
@@ -35,6 +35,7 @@
* @return The type of this data structure.
*/
ComplexEntryType& GetType();
+ virtual ~ComplexData(){};
};
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.cpp b/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.cpp
index 1f3951c..93db397 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.cpp
+++ b/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.cpp
@@ -26,6 +26,9 @@
value.b = (is.readByte()!=0);
return value;
}
+bool DefaultEntryTypes::BOOLEAN_t::areEqual(EntryValue v1, EntryValue v2) {
+ return v1.b == v2.b;
+}
DefaultEntryTypes::DOUBLE_t::DOUBLE_t() : NetworkTableEntryType(DOUBLE_RAW_ID, "Double"){}
void DefaultEntryTypes::DOUBLE_t::sendValue(EntryValue eValue, DataIOStream& os) {
@@ -36,7 +39,7 @@
}
}
EntryValue DefaultEntryTypes::DOUBLE_t::readValue(DataIOStream& is) {
- uint64_t value;
+ uint64_t value = 0;
for(int i = 0; i<8; ++i){
value<<=8;
@@ -47,6 +50,9 @@
eValue.f = *reinterpret_cast<double*>(&value);
return eValue;
}
+bool DefaultEntryTypes::DOUBLE_t::areEqual(EntryValue v1, EntryValue v2) {
+ return v1.f == v2.f;
+}
DefaultEntryTypes::STRING_t::STRING_t() : NetworkTableEntryType(STRING_RAW_ID, "String"){}
void DefaultEntryTypes::STRING_t::sendValue(EntryValue value, DataIOStream& os) {
@@ -68,6 +74,11 @@
if(value.ptr!=NULL)
delete (std::string*)value.ptr;
}
+bool DefaultEntryTypes::STRING_t::areEqual(EntryValue v1, EntryValue v2) {
+ std::string* str1 = (std::string*)v1.ptr;
+ std::string* str2 = (std::string*)v2.ptr;
+ return str1->compare(*str2)==0;
+}
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.h b/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.h
index 677ffd1..576537b 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.h
+++ b/aos/externals/WPILib/WPILib/networktables2/type/DefaultEntryTypes.h
@@ -10,7 +10,7 @@
class DefaultEntryTypes;
-#include "NetworkTableEntryTypeManager.h"
+#include "networktables2/type/NetworkTableEntryTypeManager.h"
@@ -35,6 +35,8 @@
* See {@link NetworkTableEntryType}::readValue
*/
virtual EntryValue readValue(DataIOStream& is);
+
+ virtual bool areEqual(EntryValue v1, EntryValue v2);
};
/**
* a double floating point entry type
@@ -52,6 +54,8 @@
* See {@link NetworkTableEntryType}::sendValue
*/
virtual EntryValue readValue(DataIOStream& is);
+
+ virtual bool areEqual(EntryValue v1, EntryValue v2);
};
/**
* a string entry type
@@ -79,6 +83,8 @@
* See {@link NetworkTableEntryType}::deleteValue
*/
virtual void deleteValue(EntryValue value);
+
+ virtual bool areEqual(EntryValue v1, EntryValue v2);
};
public:
/**
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryType.h b/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryType.h
index b86914d..b6dc94e 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryType.h
+++ b/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryType.h
@@ -67,6 +67,16 @@
* @return A copy of the given value of this type.
*/
virtual EntryValue copyValue(EntryValue value);
+
+ /**
+ * Compares two values to determine if they are equal
+ * and should not push an update to other nodes
+ *
+ * @param v1
+ * @param v2
+ * @return true if the two values are equal
+ */
+ virtual bool areEqual(EntryValue v1, EntryValue v2) = 0;
/**
* Deletes a value of this type.
diff --git a/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryTypeManager.h b/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryTypeManager.h
index bbfce50..8269f8c 100644
--- a/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryTypeManager.h
+++ b/aos/externals/WPILib/WPILib/networktables2/type/NetworkTableEntryTypeManager.h
@@ -10,7 +10,7 @@
class NetworkTableEntryTypeManager;
-#include "NetworkTableEntryType.h"
+#include "networktables2/type/NetworkTableEntryType.h"
class NetworkTableEntryTypeManager
{
diff --git a/aos/externals/WPILib/WPILib/networktables2/util/EOFException.h b/aos/externals/WPILib/WPILib/networktables2/util/EOFException.h
index daa82d9..22e136e 100644
--- a/aos/externals/WPILib/WPILib/networktables2/util/EOFException.h
+++ b/aos/externals/WPILib/WPILib/networktables2/util/EOFException.h
@@ -8,7 +8,7 @@
#ifndef EOFEXCEPTION_H_
#define EOFEXCEPTION_H_
-#include "IOException.h"
+#include "networktables2/util/IOException.h"
/**
diff --git a/aos/externals/WPILib/WPILib/tables/IRemote.h b/aos/externals/WPILib/WPILib/tables/IRemote.h
index 78d3a47..ea5e98f 100644
--- a/aos/externals/WPILib/WPILib/tables/IRemote.h
+++ b/aos/externals/WPILib/WPILib/tables/IRemote.h
@@ -11,7 +11,7 @@
class IRemote;
-#include "IRemoteConnectionListener.h"
+#include "tables/IRemoteConnectionListener.h"
diff --git a/aos/externals/WPILib/WPILib/tables/IRemoteConnectionListener.h b/aos/externals/WPILib/WPILib/tables/IRemoteConnectionListener.h
index 438b3dd..cf7c583 100644
--- a/aos/externals/WPILib/WPILib/tables/IRemoteConnectionListener.h
+++ b/aos/externals/WPILib/WPILib/tables/IRemoteConnectionListener.h
@@ -11,7 +11,7 @@
class IRemoteConnectionListener;
-#include "IRemote.h"
+#include "tables/IRemote.h"
diff --git a/aos/externals/WPILib/WPILib/tables/ITable.h b/aos/externals/WPILib/WPILib/tables/ITable.h
index 29385be..93cb4b4 100644
--- a/aos/externals/WPILib/WPILib/tables/ITable.h
+++ b/aos/externals/WPILib/WPILib/tables/ITable.h
@@ -20,7 +20,7 @@
#include <string>
#include "networktables2/type/ComplexData.h"
-#include "ITableListener.h"
+#include "tables/ITableListener.h"
class ITable {
diff --git a/aos/externals/WPILib/WPILib/tables/ITableListener.h b/aos/externals/WPILib/WPILib/tables/ITableListener.h
index bb82462..af114c3 100644
--- a/aos/externals/WPILib/WPILib/tables/ITableListener.h
+++ b/aos/externals/WPILib/WPILib/tables/ITableListener.h
@@ -12,7 +12,7 @@
class ITableListener;
-#include "ITable.h"
+#include "tables/ITable.h"
@@ -25,6 +25,7 @@
*/
class ITableListener {
public:
+ virtual ~ITableListener(){};
/**
* Called when a key-value pair is changed in a {@link ITable}
* WARNING: If a new key-value is put in this method value changed will immediatly be called which could lead to recursive code
diff --git a/aos/externals/WPILib/WPILib/tables/ITableProvider.h b/aos/externals/WPILib/WPILib/tables/ITableProvider.h
index eb64106..1f979d3 100644
--- a/aos/externals/WPILib/WPILib/tables/ITableProvider.h
+++ b/aos/externals/WPILib/WPILib/tables/ITableProvider.h
@@ -21,6 +21,7 @@
*
*/
class ITableProvider {
+public:
/**
* Get a table by name
* @param name the name of the table