WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Utility.h File Reference

Contains global utility functions. More...

#include <stdint.h>
#include <string>

Go to the source code of this file.

Macros

#define wpi_assert(condition)   wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
 
#define wpi_assertWithMessage(condition, message)
 
#define wpi_assertEqual(a, b)   wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
 
#define wpi_assertEqualWithMessage(a, b, message)   wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
 
#define wpi_assertNotEqual(a, b)   wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
 
#define wpi_assertNotEqualWithMessage(a, b, message)
 

Functions

bool wpi_assert_impl (bool conditionValue, const char *conditionText, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName)
 Assert implementation. More...
 
bool wpi_assertEqual_impl (int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName)
 Assert equal implementation. More...
 
bool wpi_assertNotEqual_impl (int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName)
 Assert not equal implementation. More...
 
void wpi_suspendOnAssertEnabled (bool enabled)
 
uint16_t GetFPGAVersion ()
 Return the FPGA Version number. More...
 
uint32_t GetFPGARevision ()
 Return the FPGA Revision number. More...
 
uint64_t GetFPGATime ()
 Read the microsecond-resolution timer on the FPGA. More...
 
bool GetUserButton ()
 Get the state of the "USER" button on the RoboRIO. More...
 
std::string GetStackTrace (uint32_t offset)
 Get a stack trace, ignoring the first "offset" symbols. More...
 

Detailed Description

Contains global utility functions.

Macro Definition Documentation

#define wpi_assertNotEqualWithMessage (   a,
  b,
  message 
)
Value:
wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
__FUNCTION__)
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName)
Assert not equal implementation.
Definition: Utility.cpp:117
#define wpi_assertWithMessage (   condition,
  message 
)
Value:
wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
__FUNCTION__)
bool wpi_assert_impl(bool conditionValue, const char *conditionText, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName)
Assert implementation.
Definition: Utility.cpp:28

Function Documentation

uint32_t GetFPGARevision ( )

Return the FPGA Revision number.

The format of the revision is 3 numbers. The 12 most significant bits are the Major Revision. the next 8 bits are the Minor Revision. The 12 least significant bits are the Build Number.

Returns
FPGA Revision number.
uint64_t GetFPGATime ( )

Read the microsecond-resolution timer on the FPGA.

Returns
The current time in microseconds according to the FPGA (since FPGA reset).
uint16_t GetFPGAVersion ( )

Return the FPGA Version number.

For now, expect this to be competition year.

Returns
FPGA Version number.
std::string GetStackTrace ( uint32_t  offset)

Get a stack trace, ignoring the first "offset" symbols.

Parameters
offsetThe number of symbols at the top of the stack to ignore
bool GetUserButton ( )

Get the state of the "USER" button on the RoboRIO.

Returns
True if the button is currently pressed down
bool wpi_assert_impl ( bool  conditionValue,
const char *  conditionText,
const char *  message,
const char *  fileName,
uint32_t  lineNumber,
const char *  funcName 
)

Assert implementation.

This allows breakpoints to be set on an assert. The users don't call this, but instead use the wpi_assert macros in Utility.h.

bool wpi_assertEqual_impl ( int  valueA,
int  valueB,
const char *  valueAString,
const char *  valueBString,
const char *  message,
const char *  fileName,
uint32_t  lineNumber,
const char *  funcName 
)

Assert equal implementation.

This determines whether the two given integers are equal. If not, the value of each is printed along with an optional message string. The users don't call this, but instead use the wpi_assertEqual macros in Utility.h.

bool wpi_assertNotEqual_impl ( int  valueA,
int  valueB,
const char *  valueAString,
const char *  valueBString,
const char *  message,
const char *  fileName,
uint32_t  lineNumber,
const char *  funcName 
)

Assert not equal implementation.

This determines whether the two given integers are equal. If so, the value of each is printed along with an optional message string. The users don't call this, but instead use the wpi_assertNotEqual macros in Utility.h.