WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Utility.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
14 #include <stdint.h>
15 #include <string>
16 
17 #define wpi_assert(condition) \
18  wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
19 #define wpi_assertWithMessage(condition, message) \
20  wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
21  __FUNCTION__)
22 
23 #define wpi_assertEqual(a, b) \
24  wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
25 #define wpi_assertEqualWithMessage(a, b, message) \
26  wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
27 
28 #define wpi_assertNotEqual(a, b) \
29  wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
30 #define wpi_assertNotEqualWithMessage(a, b, message) \
31  wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
32  __FUNCTION__)
33 
34 bool wpi_assert_impl(bool conditionValue, const char *conditionText,
35  const char *message, const char *fileName,
36  uint32_t lineNumber, const char *funcName);
37 bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString,
38  const char *valueBString, const char *message,
39  const char *fileName, uint32_t lineNumber,
40  const char *funcName);
41 bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString,
42  const char *valueBString, const char *message,
43  const char *fileName, uint32_t lineNumber,
44  const char *funcName);
45 
46 void wpi_suspendOnAssertEnabled(bool enabled);
47 
48 uint16_t GetFPGAVersion();
49 uint32_t GetFPGARevision();
50 uint64_t GetFPGATime();
51 bool GetUserButton();
52 std::string GetStackTrace(uint32_t offset);
uint64_t GetFPGATime()
Read the microsecond-resolution timer on the FPGA.
Definition: Utility.cpp:161
uint16_t GetFPGAVersion()
Return the FPGA Version number.
Definition: Utility.cpp:133
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.
Definition: Utility.cpp:99
std::string GetStackTrace(uint32_t offset)
Get a stack trace, ignoring the first "offset" symbols.
Definition: Utility.cpp:208
uint32_t GetFPGARevision()
Return the FPGA Revision number.
Definition: Utility.cpp:148
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
bool GetUserButton()
Get the state of the "USER" button on the RoboRIO.
Definition: Utility.cpp:172
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