Squashed 'third_party/allwpilib_2019/' changes from 99e4f7dd2..c36bbcc9a
936627bd9 wpilibc: Remove direct CameraServer dependency (#1989)
8e333c0aa Use FPGA Time instead of wall clock time for odometry (#1996)
d4430b765 Gearsbot example: Use standard argument order (#1995)
75438ab2c Add RamseteCommand (#1951)
989df1b46 Bump Native Utils and OpenCV dependencies (#1993)
dbc33b61e Fix Timer usage in TrapezoidProfileCommand (#1992)
79f8c5644 Add TrapezoidProfileCommand (#1962)
9440edf2b Refactor TrajectoryGenerator (#1972)
73a30182c Add frc2::Timer (#1968)
36ea865ed Add toString for geometry and trajectory classes (#1991)
cbe05e7e8 Update ProfiledPIDController API (#1967)
d04eb3546 Deprecate old PID classes (#1964)
02264db69 Add JNI dependencies to myRobotCpp (#1980)
2a76c996e Use VID/PID detection for PS3Eye (#1977)
a3820bbdf Remove HAL_BaseInitialize (#1981)
a83fb4793 Update to 2020v5 image (#1983)
4b0ed910e Make SwerveDriveKinematics.toChassisSpeeds() public (#1976)
103c1b121 Remove DS caching from the HAL level (#1971)
6635ea75e Fix NPE in SendableRegistry.foreachLiveWindow() (#1974)
cfe23c5cd Fix grammar error in comment for configureButtonBindings (#1969)
4bde2654e Fix mac azure build (#1973)
4f034e6c1 generateTrajectory: default reversed param to false (#1953)
acf960f72 Sim GUI: Add option to disable outputs on DS disable
2d3dac99f Sim GUI: Handle low resolutions and scale default window positions
07c86e0cd Sim GUI: Support High DPI monitors
46ad95512 SimDeviceData: Add missing null check
5bce489b9 Add ProggyDotted font to imgui (both cmake and gradle)
55af553ac Simulation GUI: Map gamepad the same way as DS
c59f9cea5 CameraServer: Add VID/PID support for Linux USB devices (#1960)
3fc89c84d Make splinePointsFromSplines public (#1963)
2c5093797 Fix implicitly deleted move constructors (#1954)
f3ad927f4 Update Java SmartDashboard and LiveWindow to match C++
05c25deb7 Fix move handling of C++ Sendable in SmartDashboard and LiveWindow
d726591ce Fix Gazebo sim plugin build (#1959)
2ff694fa4 Unbreak gradle build when other compilers installed (#1958)
53816155b Improve command decorator names (#1945)
a38f183a9 Fix GenResources.cmake so it's usable in a submodule (#1956)
b3398dca3 Set gradlebase correctly for all examples (#1950)
2c311013d Add Aarch64Bionic platform detection (#1922)
c10f2003c Add generateTrajectory overload (#1944)
63cfa64fb Add getters for pose in odometry classes (#1943)
2402c2bad Fix C++ command group recursive constructor bug (#1941)
f4eedf597 Fix ConcurrentModificationException in CommandScheduler (#1938)
bb0b207d2 Fix array out of bounds exception caused by parallel race group (#1935)
7bd69e591 Fix typo in temperature (#1940)
ec9738245 Bump to 2020 v4 image (#1931)
46303a822 Add messaging to extension loading in the HAL (#1926)
d169d6be9 Set extract_static for Doxygen config so that static members show up (#1930)
4e183eb10 Bump to 2020 v3 image (#1929)
84c185803 LiveWindow: catch errors in callback/builder functions (#1921)
0e3b0f3da Remove deprecated free() calls (#1925)
7f839b87c Remove timeouts from azure builds (#1924)
45b766a5d Fix main thread ID being potentially incorrect for simulation (#1923)
56d782b16 Add secondary camera name for PS3Eye (#1920)
2b4894038 Add simulation GUI plugin
f97d16073 Add imgui build to cmake
55a844a3e HAL sim: Add encoder channel B access
10deba854 Remove sendables from SendableRegistry when close() is called (#1917)
a9f0e4668 Implement sim devices for ADXL345, ADXL362, ADXRS450, Ultrasonic
aa9064586 Add ability to associate other devices with a SimDevice
81c2c8a7d Add simulation generic device/value support
e8d6f8a2c Move mockdata/HAL_Value.h to hal/Value.h
1b266717a Add simulation module support to cmake build (#1906)
fb8f3bd06 Add testbench yaml file (#1915)
846d8def0 Update to 2020 v2 image (#1913)
d6ac6e512 Fix PortForwarder package declaration (#1912)
227157086 Fix PS3Eye exposure setting (#1911)
885744d7e Add myRobot C++ version to cmake build (#1907)
366091fa8 Document that ConditionalCommand requires all subsystems (#1909)
c58b072c8 Fix Drive usage reporting order (#1908)
762c88adb Update compiler versions in readme (#1905)
af8ce568d Add Ramsete unicycle controller (#1790)
b2c2934d0 Fix javadoc warnings about invalid usage of ">" (#1904)
cce26ec78 Replace CRLF line endings with LF (#1902)
cb54602d4 Add support for writing RTR CAN Frames to the CAN API (#1900)
9f740e590 Use OS for serial port instead of NI VISA (#1875)
b23baf611 Add ability to run robot main loop in a separate thread (#1895)
457f94ba2 Add trajectory generation using hermite splines (#1843)
fd612052f Update native utils to use new frchome directory (#1884)
8858ec55c Remove periodic can read call (#1868)
41efb8015 Update CANAPITypes.h (#1860)
c93be1b2d Remove LabVIEW HAL support (#1901)
680f8919e Remove eigen, units and libuv from doxygen generation (#1898)
c5812524f Bump GradleJNI plugin version (#1899)
971303da8 Add PortForwarder class (#1890)
50db77bf2 Fix wpiutil cmake eigen install source directory (#1891)
85d42c199 C++ PIDCommand: Add GetMeasurement() and UseOutput() (#1892)
2dfbb855d wpilibj: Fix SwerveDriveKinematics ctor parameter name (#1889)
471f375a3 Simplify Sendable interface (#1864)
1d8c4d016 Replace ::value and ::type with _v and _t suffixes (#1885)
a5650b943 Add Units Utility class for Java (#1829)
904479ad4 Deprecate GearTooth class for removal (#1878)
86b666bba Add equality comparator to geometry classes (#1882)
62f07c182 Make one-arg Rotation2d constructor implicit (#1883)
f405582f8 Add kinematics suite (#1787)
561cbbd14 Deprecate Filter class for removal (#1876)
84e2973aa Remove unused include from Filesystem.h (#1877)
f49859ebf Remove NI VISA headers, as they are now included in NI Libraries (#1879)
bc59db5e6 Rename DEBUG macro to DEBUG0 (#1871)
dd928b4cb Remove JNI logging (#1872)
3e0f7d099 Use units for new NotifierCommand (#1869)
5ffe15d5f Remove ability to build all combined artifacts (#1867)
516cbef2c Remove RoboRIO ifdef from simulation headers (#1859)
9b6ffc201 Replace SetOutputRange() with SetIntegratorRange()
ff8b8f0a8 Remove percent tolerance from PID controller
0ca8d667d Clean up AutoCloseable and other Java warnings (#1866)
7112add67 Watchdog: use units::second_t instead of double (#1863)
761bc3ef8 Change C++ WaitCommand to use units (#1865)
1fb301123 Add MathUtils.clamp() for Java (#1861)
eb3e0c9c9 Fix cmake Eigen include directory (#1862)
2250b7fbe Rename GearsBotNew example to GearsBot
c9f9feff1 Replace deprecated API usage in C++ examples
d6b9c7e14 CONTRIBUTING.md: Point to frc-docs instead of screensteps (#1858)
d10a1a797 Fix eigen build in vcpkg (#1856)
2bdb44325 Add frc2 includes to list of "other lib" regexes (#1855)
4b2b21d24 Replace outdated Java collections (#508)
8993ce5bf Move Eigen headers out of main include folder (#1854)
0f532a117 Add PWMSparkMax (#1751)
f7ad363d8 Add jni cross compile options for aarch64 (#1853)
9afea3340 Add support for aarch64 jetson bionic builds (#1844)
d787b5d60 Add more items to .gitignore (#1850)
5dd0d1b7d Use units in SPI
07ac711b3 Fix units deprecated warning in IterativeRobot
decfd858b Correctly report -1 for POV on disconnected joystick (#1852)
076ed7770 Add new C++ Command framework (#1785)
a0be07c37 Refactor HAL handle move construction/assignment (#1845)
558c38308 Add new Java Command framework (#1682)
1379735af Delete RobotState and SensorUtil constructors (#1847)
e3d86fee4 Move circular buffer class from wpilib to wpiutil (#1840)
4cd8a5667 TimedRobot.cpp: Fix deprecation warning (#1846)
b2861f894 Use 2020 artifacts and artifactory server (#1838)
98cc32703 Update to use artifactory to publish artifacts (#1833)
fa0640300 Move drive integration tests into wpilibj/src/test (#1836)
e716c36b8 Fix Nat.java generation to be incremental (#1831)
9fd2b5e3f Fix MSVC builds on cmake windows in vcpkg (#1835)
7e95010a2 Add compile-time EJML matrix wrapper to wpiutil (#1804)
3ebc5a6d3 Add ProfiledPIDController
fc98a79db Clean up PIDController interface in preparation for ProfiledPIDController
fdc098267 Fix compilation error in elevator trapezoid profile example (#1826)
a3dd84e85 Make XBoxController Button enum public (#1823)
a216b9e9e Add TrapezoidProfile example (#1814)
8f386f6bb wpilibc: Add unit-safety to C++ geometry classes (#1811)
c07ac2353 wpilibc: Add overloads for units (#1815)
f1d71da8a Move GetStackTrace and Demangle to wpiutil, add Windows support (#1819)
ef037457e Make LinearFilter copyable and moveable (#1789)
76930250c Remove objective-cpp support (#1816)
1c246418f Move TrapezoidProfileTest to trajectory folder (#1812)
95a54a0f2 Add java arcade drive example (#1810)
a4530243e HAL sim: Fix incorrectly setting dio port to initialized on cleanup (#1813)
09d00a622 Update Java examples to use new PIDController (#1809)
ba9b51742 Add missing Java examples (#841)
6411bd79c InterruptableSensorBase: Fix callback function deletion (#1807)
810e58ea8 I2C: Add tip about writeBulk() to transaction() (#1806)
607d6c148 Fix wpilibj integration tests jar name (#1808)
c9873e81b Remove PIDControllerRunner and mutex from new PIDController (#1795)
98d0706de Fix cscore build with OpenCV 4 (#1803)
fbe67c90c Make Sendable setters synchronous (#1799)
c67a488a0 Format SendableBuilderImpl javadocs (#1802)
8e93ce892 Fix PIDControllerRunner member destruction order (#1801)
c98ca7310 Add EJML dependency to wpiutil (#1769)
3b12276bc SendableBase: remove unnecessary synchronization (#1797)
e6d348f38 Fix missing default name in Java PIDController (#1792)
df12fc2a8 Java cleanups (#1776)
39561751f Update GradleVSCode version (#1786)
37d316aa0 Add C++20 std::math constants shim (#1788)
dd4310959 Deprecate frc/WPILib.h (#1779)
823174f30 Update native utils to 2020.0.4 (#1783)
37c695266 Squelch -Wdeprecated-copy for Eigen with GCC >= 9
04c9b000f Revert "Fix build of Eigen 3.3.7 with GCC 9"
ca3e71e21 wpiutil: Fix Process::Spawn() (#1778)
d946d5a2b Fix Eigen compilation errors and add tests (#1777)
8b1b9ac75 Fix build of Eigen 3.3.7 with GCC 9
2f680ba99 Add Eigen linear algebra library
a885db7d4 Make MotorEncoderTest use LinearFilter (#1775)
ee2410169 Add geometry classes (#1766)
48fe54271 Add HALSIM_SetSendError implementation (#1773)
dff58c87f Fix unused warning in release build (#1771)
dde61aad3 Remove TimerEventHandler typedef from Notifier class (#1767)
0f6ef80ab Add RobotState#IsEStopped and DriverStation#IsEStopped (#952)
e48886187 Move unit tests from integration test suite (#1170)
dffa1a5cb Make null checks more descriptive (#1688)
fe59d854d Notifier: add null check (#1684)
10731f3d6 Update uv Udp wrapper for latest features
89f7b72b6 Update libuv to 1.30.1 release
85f2f8740 wpiutil: Add unique_function (#1761)
73ec94078 Remove SampleRobot (#1658)
62be0392b Replace std::lock_guard and std::lock with std::scoped_lock (#1758)
24d31df55 Make sure move constructor is generated for TrapezoidProfile (#1757)
841ef5d73 Remove template types from lock RAII wrapper usages (#1756)
e582518ba Fix some move constructors (#1754)
8757bc471 Remove pre-C++17 shims (#1752)
ea9512977 Add replacement PIDController class (#1300)
9b798d228 Add TrapezoidProfile class (#1673)
804926fb5 Unconditionally skip athena builds for sim (#1748)
118e9d29d Add C++14 units library (#1749)
c705953d7 Add usage reporting to LinearFilter (#1750)
852d1b9ca Don't cross-build gazebo for raspbian (#1747)
eedb3a1ad Fix GCC 9 warnings (#1730)
60dce66a4 Remove wpi::ArrayRef std::initializer_list constructor (#1745)
9e19b29c3 Use base azure image for primary wpilib build (#1744)
299425071 Update jni library, fix cross builds of the jni symbol check (#1742)
a6b0e9b85 Only disable execution of cross compile google tests (#1741)
3c2093119 Use docker container to run wpiformat (#1740)
5fe2eebce Revert "Don't build halsim_gazebo on raspbian (#1737)" (#1743)
4b1b92bb7 Replace wpi::optional with C++17 std::optional (#1732)
0fbb0d989 Update to 2020 compilers (#1733)
2dc94e605 Disable google tests on cross compilers (#1738)
d9cb57a42 Don't build halsim_gazebo on raspbian (#1737)
f7cfdd7ce Replace crlf line endings with lf (#1731)
b6d5d90d9 Add JaCoCo Support (#1734)
c7ab2baa6 Add way to disable the jni check tasks from a property (#1736)
0c45c5b7e Fix skip athena and skip raspbian flags (#1735)
3dfb01d45 Update to new Native Utils (#1696)
30e936837 Clean up LinearDigitalFilter class (#782)
311e2de4c Remove deprecated Joystick constants (#1715)
c08fd6682 Update CAN manufacturer list (#1706)
258bba0c2 ErrorBase and WPIError improvements (#1727)
372ca4f45 cmake: Enable googletest unit tests (#1720)
223d47af0 HALSIM: support mocking of HAL_SendError() (#1728)
55cb683db Change compiler flags to C++17 (#1723)
ee8a33c56 wpiutil: SafeThread: Add thread id, support getting shared_ptr (#1722)
61426d08d wpiutil: Signal: make operator() const (#1721)
b630b63ef Remove functions in LiveWindow deprecated since 2018 (#1716)
1d0c05d4f Styleguide fixes for #1718 (#1719)
f07569df1 Fix newer GCC/clang compiler warnings (#1718)
0120f3124 C++ SPI: Fix SetClockRate to take int (#1717)
c2829ed98 Configure gradle to ignore unresolved headers (#1711)
221e66f46 Allow disabling static init of JNI libraries (#1672)
738852e11 cmake: Add cross toolchain files for Rio and Pi (#1710)
27b697b08 Remove frc directory include shims (#1714)
9e45373a7 Remove functions and classes deprecated for 2018 season (#1059)
eeb1025ac SPI: Report port as instance for usage reporting (#1704)
bc6f1e246 Windows compiler options improvements (#1709)
bb48ae391 cmake: Move example programs into folders (#1654)
221011494 Update for C++17 and fix MSVC warnings (#1694)
fb1239a2a Add raw sources and sinks to cscore (#1670)
7de947734 Add lambda overloads for interrupts (#1636)
90957aeea Move libuv to its own subfolder in build (#1661)
47aae502a Styleguide fixes (#1702)
0bff98b5e Correct DifferentialDrive::ArcadeDrive param docs (#1698)
b52e40b80 Allow widgets to be added by passing value suppliers (#1690)
4a00cd77b Add usage reporting for the Shuffleboard API (#1685)
e25e515f2 Publish artifacts on azure (#1678)
322ef9b96 Force Java 11, fix javadoc generation (#1695)
d42ef5df0 Fix Watchdog print formatting (#1693)
f432f65be Update copyright year in license to 2019 (#1524)
1726b77ac wpiutil: uv: Remove copy from SimpleBufferPool (#1680)
620bec9ca wpiutil: uv: Add LoopClosing status to Handle (#1647)
7cd6e2e7f UsbCamera: Solve race in windows initialization (#1638)
7732836bd Completely disable watchdog tests on mac (#1679)
698edfda9 Remove framework load, disable mac timeout test (#1676)
1c454b000 Add Shuffleboard calls to IterativeRobotBase in C++ (#1607)
f42905b32 Include missing headers in HAL.h (#1660)
bdc822fad Only generate passthrough URLs for RoboRIO (#1624)
d3affb16b Make failure of HAL_GetFPGATime() more descriptive (#1633)
2de3bf7f5 Update LLVM from stable upstream (#1653)
3cf4f38f5 Fix build on macos10.14.4 (#1648)
4e0c10f48 Fix CAN Clean using wrong ID (#1668)
3b0631324 Fix Gray to BGR conversion in CameraServer (#1665)
6cd1c73ef Fix GUID comparison creating weird symbol (#1659)
063bbab6f MavenArtifacts.md: update links to HTTPS (#1674)
aab4c494d Fix type in build.gradle (#1604)
bf46af260 Disable extraneous data warnings in libjpeg (#1630)
655763a9a Limit length of message sent to DS SendError call (#1618)
a095ec2d8 Fix linker errors with free functions in Threads.h (#1625)
12ab035aa Fix receive side of LabVIEW USB streams (#1621)
Change-Id: Ibd382e1a48925c200850cf90a8121e35c0fcffe3
git-subtree-dir: third_party/allwpilib_2019
git-subtree-split: c36bbcc9a9095489fc078229db4fba3ecd0f9b78
diff --git a/hal/src/main/native/athena/AnalogInput.cpp b/hal/src/main/native/athena/AnalogInput.cpp
index b11280d..859524e 100644
--- a/hal/src/main/native/athena/AnalogInput.cpp
+++ b/hal/src/main/native/athena/AnalogInput.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -75,6 +75,9 @@
return channel < kNumAnalogInputs && channel >= 0;
}
+void HAL_SetAnalogInputSimDevice(HAL_AnalogInputHandle handle,
+ HAL_SimDeviceHandle device) {}
+
void HAL_SetAnalogSampleRate(double samplesPerSecond, int32_t* status) {
// TODO: This will change when variable size scan lists are implemented.
// TODO: Need double comparison with epsilon.
@@ -149,7 +152,7 @@
readSelect.Channel = port->channel;
readSelect.Averaged = false;
- std::lock_guard<wpi::mutex> lock(analogRegisterWindowMutex);
+ std::scoped_lock lock(analogRegisterWindowMutex);
analogInputSystem->writeReadSelect(readSelect, status);
analogInputSystem->strobeLatchOutput(status);
return static_cast<int16_t>(analogInputSystem->readOutput(status));
@@ -166,7 +169,7 @@
readSelect.Channel = port->channel;
readSelect.Averaged = true;
- std::lock_guard<wpi::mutex> lock(analogRegisterWindowMutex);
+ std::scoped_lock lock(analogRegisterWindowMutex);
analogInputSystem->writeReadSelect(readSelect, status);
analogInputSystem->strobeLatchOutput(status);
return static_cast<int32_t>(analogInputSystem->readOutput(status));
diff --git a/hal/src/main/native/athena/AnalogInternal.cpp b/hal/src/main/native/athena/AnalogInternal.cpp
index 6e02def..03a246d 100644
--- a/hal/src/main/native/athena/AnalogInternal.cpp
+++ b/hal/src/main/native/athena/AnalogInternal.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -44,7 +44,7 @@
void initializeAnalog(int32_t* status) {
hal::init::CheckInit();
if (analogSystemInitialized) return;
- std::lock_guard<wpi::mutex> lock(analogRegisterWindowMutex);
+ std::scoped_lock lock(analogRegisterWindowMutex);
if (analogSystemInitialized) return;
analogInputSystem.reset(tAI::create(status));
analogOutputSystem.reset(tAO::create(status));
diff --git a/hal/src/main/native/athena/CANAPI.cpp b/hal/src/main/native/athena/CANAPI.cpp
index 01c06bd..44cdb58 100644
--- a/hal/src/main/native/athena/CANAPI.cpp
+++ b/hal/src/main/native/athena/CANAPI.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2018-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -68,6 +68,8 @@
return createdId;
}
+extern "C" {
+
HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer,
int32_t deviceId, HAL_CANDeviceType deviceType,
int32_t* status) {
@@ -91,12 +93,12 @@
void HAL_CleanCAN(HAL_CANHandle handle) {
auto data = canHandles->Free(handle);
- std::lock_guard<wpi::mutex> lock(data->mapMutex);
+ std::scoped_lock lock(data->mapMutex);
for (auto&& i : data->periodicSends) {
int32_t s = 0;
- HAL_CAN_SendMessage(i.first, nullptr, 0, HAL_CAN_SEND_PERIOD_STOP_REPEATING,
- &s);
+ auto id = CreateCANId(data.get(), i.first);
+ HAL_CAN_SendMessage(id, nullptr, 0, HAL_CAN_SEND_PERIOD_STOP_REPEATING, &s);
i.second = -1;
}
}
@@ -115,7 +117,7 @@
if (*status != 0) {
return;
}
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
+ std::scoped_lock lock(can->mapMutex);
can->periodicSends[apiId] = -1;
}
@@ -134,10 +136,31 @@
if (*status != 0) {
return;
}
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
+ std::scoped_lock lock(can->mapMutex);
can->periodicSends[apiId] = repeatMs;
}
+void HAL_WriteCANRTRFrame(HAL_CANHandle handle, int32_t length, int32_t apiId,
+ int32_t* status) {
+ auto can = canHandles->Get(handle);
+ if (!can) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+ auto id = CreateCANId(can.get(), apiId);
+ id |= HAL_CAN_IS_FRAME_REMOTE;
+ uint8_t data[8];
+ std::memset(data, 0, sizeof(data));
+
+ HAL_CAN_SendMessage(id, data, length, HAL_CAN_SEND_PERIOD_NO_REPEAT, status);
+
+ if (*status != 0) {
+ return;
+ }
+ std::scoped_lock lock(can->mapMutex);
+ can->periodicSends[apiId] = -1;
+}
+
void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
int32_t* status) {
auto can = canHandles->Get(handle);
@@ -153,7 +176,7 @@
if (*status != 0) {
return;
}
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
+ std::scoped_lock lock(can->mapMutex);
can->periodicSends[apiId] = -1;
}
@@ -172,7 +195,7 @@
HAL_CAN_ReceiveMessage(&messageId, 0x1FFFFFFF, data, &dataSize, &ts, status);
if (*status == 0) {
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
+ std::scoped_lock lock(can->mapMutex);
auto& msg = can->receives[messageId];
msg.length = dataSize;
msg.lastTimeStamp = ts;
@@ -197,7 +220,7 @@
uint32_t ts = 0;
HAL_CAN_ReceiveMessage(&messageId, 0x1FFFFFFF, data, &dataSize, &ts, status);
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
+ std::scoped_lock lock(can->mapMutex);
if (*status == 0) {
// fresh update
auto& msg = can->receives[messageId];
@@ -234,7 +257,7 @@
uint32_t ts = 0;
HAL_CAN_ReceiveMessage(&messageId, 0x1FFFFFFF, data, &dataSize, &ts, status);
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
+ std::scoped_lock lock(can->mapMutex);
if (*status == 0) {
// fresh update
auto& msg = can->receives[messageId];
@@ -262,65 +285,4 @@
}
}
}
-
-void HAL_ReadCANPeriodicPacket(HAL_CANHandle handle, int32_t apiId,
- uint8_t* data, int32_t* length,
- uint64_t* receivedTimestamp, int32_t timeoutMs,
- int32_t periodMs, int32_t* status) {
- auto can = canHandles->Get(handle);
- if (!can) {
- *status = HAL_HANDLE_ERROR;
- return;
- }
-
- uint32_t messageId = CreateCANId(can.get(), apiId);
-
- {
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
- auto i = can->receives.find(messageId);
- if (i != can->receives.end()) {
- // Found, check if new enough
- uint32_t now = GetPacketBaseTime();
- if (now - i->second.lastTimeStamp < static_cast<uint32_t>(periodMs)) {
- // Read the data from the stored message into the output
- std::memcpy(data, i->second.data, i->second.length);
- *length = i->second.length;
- *receivedTimestamp = i->second.lastTimeStamp;
- *status = 0;
- return;
- }
- }
- }
-
- uint8_t dataSize = 0;
- uint32_t ts = 0;
- HAL_CAN_ReceiveMessage(&messageId, 0x1FFFFFFF, data, &dataSize, &ts, status);
-
- std::lock_guard<wpi::mutex> lock(can->mapMutex);
- if (*status == 0) {
- // fresh update
- auto& msg = can->receives[messageId];
- msg.length = dataSize;
- *length = dataSize;
- msg.lastTimeStamp = ts;
- *receivedTimestamp = ts;
- // The NetComm call placed in data, copy into the msg
- std::memcpy(msg.data, data, dataSize);
- } else {
- auto i = can->receives.find(messageId);
- if (i != can->receives.end()) {
- // Found, check if new enough
- uint32_t now = GetPacketBaseTime();
- if (now - i->second.lastTimeStamp > static_cast<uint32_t>(timeoutMs)) {
- // Timeout, return bad status
- *status = HAL_CAN_TIMEOUT;
- return;
- }
- // Read the data from the stored message into the output
- std::memcpy(data, i->second.data, i->second.length);
- *length = i->second.length;
- *receivedTimestamp = i->second.lastTimeStamp;
- *status = 0;
- }
- }
-}
+} // extern "C"
diff --git a/hal/src/main/native/athena/DIO.cpp b/hal/src/main/native/athena/DIO.cpp
index 96eab2b..dc4631e 100644
--- a/hal/src/main/native/athena/DIO.cpp
+++ b/hal/src/main/native/athena/DIO.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -69,7 +69,7 @@
port->channel = static_cast<uint8_t>(channel);
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
tDIO::tOutputEnable outputEnable = digitalSystem->readOutputEnable(status);
@@ -143,7 +143,7 @@
}
int32_t status = 0;
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) {
// Unset the SPI flag
int32_t bitToUnset = 1 << remapSPIChannel(port->channel);
@@ -160,6 +160,9 @@
}
}
+void HAL_SetDIOSimDevice(HAL_DigitalHandle handle, HAL_SimDeviceHandle device) {
+}
+
HAL_DigitalPWMHandle HAL_AllocateDigitalPWM(int32_t* status) {
auto handle = digitalPWMHandles->Allocate();
if (handle == HAL_kInvalidHandle) {
@@ -205,7 +208,7 @@
double rawDutyCycle = 256.0 * dutyCycle;
if (rawDutyCycle > 255.5) rawDutyCycle = 255.5;
{
- std::lock_guard<wpi::mutex> lock(digitalPwmMutex);
+ std::scoped_lock lock(digitalPwmMutex);
uint16_t pwmPeriodPower = digitalSystem->readPWMPeriodPower(status);
if (pwmPeriodPower < 4) {
// The resolution of the duty cycle drops close to the highest
@@ -251,7 +254,7 @@
if (value != 0) value = 1;
}
{
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
tDIO::tDO currentDIO = digitalSystem->readDO(status);
if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) {
@@ -289,7 +292,7 @@
return;
}
{
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
tDIO::tOutputEnable currentDIO = digitalSystem->readOutputEnable(status);
if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) {
@@ -382,8 +385,8 @@
}
digitalSystem->writePulseLength(
- static_cast<uint8_t>(1.0e9 * pulseLength /
- (pwmSystem->readLoopTiming(status) * 25)),
+ static_cast<uint16_t>(1.0e9 * pulseLength /
+ (pwmSystem->readLoopTiming(status) * 25)),
status);
digitalSystem->writePulse(pulse, status);
}
@@ -421,7 +424,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) {
// Channels 10-15 are SPI channels, so subtract our MXP channels
digitalSystem->writeFilterSelectHdr(port->channel - kNumDigitalMXPChannels,
@@ -441,7 +444,7 @@
return 0;
}
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) {
// Channels 10-15 are SPI channels, so subtract our MXP channels
return digitalSystem->readFilterSelectHdr(
@@ -457,7 +460,7 @@
void HAL_SetFilterPeriod(int32_t filterIndex, int64_t value, int32_t* status) {
initializeDigital(status);
if (*status != 0) return;
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
digitalSystem->writeFilterPeriodHdr(filterIndex, value, status);
if (*status == 0) {
digitalSystem->writeFilterPeriodMXP(filterIndex, value, status);
@@ -470,7 +473,7 @@
uint32_t hdrPeriod = 0;
uint32_t mxpPeriod = 0;
{
- std::lock_guard<wpi::mutex> lock(digitalDIOMutex);
+ std::scoped_lock lock(digitalDIOMutex);
hdrPeriod = digitalSystem->readFilterPeriodHdr(filterIndex, status);
if (*status == 0) {
mxpPeriod = digitalSystem->readFilterPeriodMXP(filterIndex, status);
diff --git a/hal/src/main/native/athena/DigitalInternal.cpp b/hal/src/main/native/athena/DigitalInternal.cpp
index bdba75b..684d35a 100644
--- a/hal/src/main/native/athena/DigitalInternal.cpp
+++ b/hal/src/main/native/athena/DigitalInternal.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -74,7 +74,7 @@
// Initial check, as if it's true initialization has finished
if (initialized) return;
- std::lock_guard<wpi::mutex> lock(initializeMutex);
+ std::scoped_lock lock(initializeMutex);
// Second check in case another thread was waiting
if (initialized) return;
diff --git a/hal/src/main/native/athena/Encoder.cpp b/hal/src/main/native/athena/Encoder.cpp
index adf70ed..bf3a273 100644
--- a/hal/src/main/native/athena/Encoder.cpp
+++ b/hal/src/main/native/athena/Encoder.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -261,6 +261,9 @@
encoderHandles->Free(encoderHandle);
}
+void HAL_SetEncoderSimDevice(HAL_EncoderHandle handle,
+ HAL_SimDeviceHandle device) {}
+
int32_t HAL_GetEncoder(HAL_EncoderHandle encoderHandle, int32_t* status) {
auto encoder = encoderHandles->Get(encoderHandle);
if (encoder == nullptr) {
diff --git a/hal/src/main/native/athena/FRCDriverStation.cpp b/hal/src/main/native/athena/FRCDriverStation.cpp
index 5409ad0..23c874f 100644
--- a/hal/src/main/native/athena/FRCDriverStation.cpp
+++ b/hal/src/main/native/athena/FRCDriverStation.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -30,64 +30,9 @@
static constexpr int kJoystickPorts = 6;
-// Joystick User Data
-static std::unique_ptr<HAL_JoystickAxes[]> m_joystickAxes;
-static std::unique_ptr<HAL_JoystickPOVs[]> m_joystickPOVs;
-static std::unique_ptr<HAL_JoystickButtons[]> m_joystickButtons;
-static std::unique_ptr<HAL_JoystickDescriptor[]> m_joystickDescriptor;
-static std::unique_ptr<HAL_MatchInfo> m_matchInfo;
-
-// Joystick Cached Data
-static std::unique_ptr<HAL_JoystickAxes[]> m_joystickAxesCache;
-static std::unique_ptr<HAL_JoystickPOVs[]> m_joystickPOVsCache;
-static std::unique_ptr<HAL_JoystickButtons[]> m_joystickButtonsCache;
-static std::unique_ptr<HAL_JoystickDescriptor[]> m_joystickDescriptorCache;
-static std::unique_ptr<HAL_MatchInfo> m_matchInfoCache;
-
-static wpi::mutex m_cacheDataMutex;
-
-// Control word variables
-static HAL_ControlWord m_controlWordCache;
-static std::chrono::steady_clock::time_point m_lastControlWordUpdate;
-static wpi::mutex m_controlWordMutex;
-
// Message and Data variables
static wpi::mutex msgMutex;
-static void InitializeDriverStationCaches() {
- m_joystickAxes = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
- m_joystickPOVs = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
- m_joystickButtons = std::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
- m_joystickDescriptor =
- std::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
- m_matchInfo = std::make_unique<HAL_MatchInfo>();
- m_joystickAxesCache = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
- m_joystickPOVsCache = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
- m_joystickButtonsCache =
- std::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
- m_joystickDescriptorCache =
- std::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
- m_matchInfoCache = std::make_unique<HAL_MatchInfo>();
-
- // All joysticks should default to having zero axes, povs and buttons, so
- // uninitialized memory doesn't get sent to speed controllers.
- for (unsigned int i = 0; i < kJoystickPorts; i++) {
- m_joystickAxes[i].count = 0;
- m_joystickPOVs[i].count = 0;
- m_joystickButtons[i].count = 0;
- m_joystickDescriptor[i].isXbox = 0;
- m_joystickDescriptor[i].type = -1;
- m_joystickDescriptor[i].name[0] = '\0';
-
- m_joystickAxesCache[i].count = 0;
- m_joystickPOVsCache[i].count = 0;
- m_joystickButtonsCache[i].count = 0;
- m_joystickDescriptorCache[i].isXbox = 0;
- m_joystickDescriptorCache[i].type = -1;
- m_joystickDescriptorCache[i].name[0] = '\0';
- }
-}
-
static int32_t HAL_GetJoystickAxesInternal(int32_t joystickNum,
HAL_JoystickAxes* axes) {
HAL_JoystickAxesInt axesInt;
@@ -138,7 +83,7 @@
static int32_t HAL_GetJoystickDescriptorInternal(int32_t joystickNum,
HAL_JoystickDescriptor* desc) {
desc->isXbox = 0;
- desc->type = std::numeric_limits<uint8_t>::max();
+ desc->type = (std::numeric_limits<uint8_t>::max)();
desc->name[0] = '\0';
desc->axisCount =
HAL_kMaxJoystickAxes; /* set to the desc->axisTypes's capacity */
@@ -177,90 +122,18 @@
return status;
}
-static void UpdateDriverStationControlWord(bool force,
- HAL_ControlWord& controlWord) {
- auto now = std::chrono::steady_clock::now();
- std::lock_guard<wpi::mutex> lock(m_controlWordMutex);
- // Update every 50 ms or on force.
- if ((now - m_lastControlWordUpdate > std::chrono::milliseconds(50)) ||
- force) {
- HAL_GetControlWordInternal(&m_controlWordCache);
- m_lastControlWordUpdate = now;
- }
- controlWord = m_controlWordCache;
-}
-
-static void UpdateDriverStationDataCaches() {
- // Get the status of all of the joysticks, and save to the cache
- for (uint8_t stick = 0; stick < kJoystickPorts; stick++) {
- HAL_GetJoystickAxesInternal(stick, &m_joystickAxesCache[stick]);
- HAL_GetJoystickPOVsInternal(stick, &m_joystickPOVsCache[stick]);
- HAL_GetJoystickButtonsInternal(stick, &m_joystickButtonsCache[stick]);
- HAL_GetJoystickDescriptorInternal(stick, &m_joystickDescriptorCache[stick]);
- }
- // Grab match specific data
- HAL_GetMatchInfoInternal(m_matchInfoCache.get());
-
- // Force a control word update, to make sure the data is the newest.
- HAL_ControlWord controlWord;
- UpdateDriverStationControlWord(true, controlWord);
-
- {
- // Obtain a lock on the data, swap the cached data into the main data arrays
- std::lock_guard<wpi::mutex> lock(m_cacheDataMutex);
-
- m_joystickAxes.swap(m_joystickAxesCache);
- m_joystickPOVs.swap(m_joystickPOVsCache);
- m_joystickButtons.swap(m_joystickButtonsCache);
- m_joystickDescriptor.swap(m_joystickDescriptorCache);
- m_matchInfo.swap(m_matchInfoCache);
- }
-}
-
-class DriverStationThread : public wpi::SafeThread {
- public:
- void Main() {
- std::unique_lock<wpi::mutex> lock(m_mutex);
- while (m_active) {
- m_cond.wait(lock, [&] { return !m_active || m_notify; });
- if (!m_active) break;
- m_notify = false;
-
- lock.unlock();
- UpdateDriverStationDataCaches();
- lock.lock();
-
- // Notify all threads
- newDSDataAvailableCounter++;
- newDSDataAvailableCond.notify_all();
- }
-
- // Notify waiters on thread exit
- newDSDataAvailableCounter++;
- newDSDataAvailableCond.notify_all();
- }
-
- bool m_notify = false;
- wpi::condition_variable newDSDataAvailableCond;
- int newDSDataAvailableCounter{0};
-};
-
-class DriverStationThreadOwner
- : public wpi::SafeThreadOwner<DriverStationThread> {
- public:
- void Notify() {
- auto thr = GetThread();
- if (!thr) return;
- thr->m_notify = true;
- thr->m_cond.notify_one();
- }
-};
-
-static std::unique_ptr<DriverStationThreadOwner> dsThread = nullptr;
+static wpi::mutex* newDSDataAvailableMutex;
+static wpi::condition_variable* newDSDataAvailableCond;
+static int newDSDataAvailableCounter{0};
namespace hal {
namespace init {
-void InitializeFRCDriverStation() {}
+void InitializeFRCDriverStation() {
+ static wpi::mutex newMutex;
+ newDSDataAvailableMutex = &newMutex;
+ static wpi::condition_variable newCond;
+ newDSDataAvailableCond = &newCond;
+}
} // namespace init
} // namespace hal
@@ -272,7 +145,7 @@
// Avoid flooding console by keeping track of previous 5 error
// messages and only printing again if they're longer than 1 second old.
static constexpr int KEEP_MSGS = 5;
- std::lock_guard<wpi::mutex> lock(msgMutex);
+ std::scoped_lock lock(msgMutex);
static std::string prevMsg[KEEP_MSGS];
static std::chrono::time_point<std::chrono::steady_clock>
prevMsgTime[KEEP_MSGS];
@@ -292,8 +165,43 @@
}
int retval = 0;
if (i == KEEP_MSGS || (curTime - prevMsgTime[i]) >= std::chrono::seconds(1)) {
- retval = FRC_NetworkCommunication_sendError(isError, errorCode, isLVCode,
- details, location, callStack);
+ wpi::StringRef detailsRef{details};
+ wpi::StringRef locationRef{location};
+ wpi::StringRef callStackRef{callStack};
+
+ // 1 tag, 4 timestamp, 2 seqnum
+ // 2 numOccur, 4 error code, 1 flags, 6 strlen
+ // 1 extra needed for padding on Netcomm end.
+ size_t baseLength = 21;
+
+ if (baseLength + detailsRef.size() + locationRef.size() +
+ callStackRef.size() <=
+ 65536) {
+ // Pass through
+ retval = FRC_NetworkCommunication_sendError(isError, errorCode, isLVCode,
+ details, location, callStack);
+ } else if (baseLength + detailsRef.size() > 65536) {
+ // Details too long, cut both location and stack
+ auto newLen = 65536 - baseLength;
+ std::string newDetails{details, newLen};
+ char empty = '\0';
+ retval = FRC_NetworkCommunication_sendError(
+ isError, errorCode, isLVCode, newDetails.c_str(), &empty, &empty);
+ } else if (baseLength + detailsRef.size() + locationRef.size() > 65536) {
+ // Location too long, cut stack
+ auto newLen = 65536 - baseLength - detailsRef.size();
+ std::string newLocation{location, newLen};
+ char empty = '\0';
+ retval = FRC_NetworkCommunication_sendError(
+ isError, errorCode, isLVCode, details, newLocation.c_str(), &empty);
+ } else {
+ // Stack too long
+ auto newLen = 65536 - baseLength - detailsRef.size() - locationRef.size();
+ std::string newCallStack{callStack, newLen};
+ retval = FRC_NetworkCommunication_sendError(isError, errorCode, isLVCode,
+ details, location,
+ newCallStack.c_str());
+ }
if (printMsg) {
if (location && location[0] != '\0') {
wpi::errs() << (isError ? "Error" : "Warning") << " at " << location
@@ -322,41 +230,29 @@
}
int32_t HAL_GetControlWord(HAL_ControlWord* controlWord) {
- std::memset(controlWord, 0, sizeof(HAL_ControlWord));
- UpdateDriverStationControlWord(false, *controlWord);
- return 0;
+ return HAL_GetControlWordInternal(controlWord);
}
int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes) {
- std::unique_lock<wpi::mutex> lock(m_cacheDataMutex);
- *axes = m_joystickAxes[joystickNum];
- return 0;
+ return HAL_GetJoystickAxesInternal(joystickNum, axes);
}
int32_t HAL_GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs) {
- std::unique_lock<wpi::mutex> lock(m_cacheDataMutex);
- *povs = m_joystickPOVs[joystickNum];
- return 0;
+ return HAL_GetJoystickPOVsInternal(joystickNum, povs);
}
int32_t HAL_GetJoystickButtons(int32_t joystickNum,
HAL_JoystickButtons* buttons) {
- std::unique_lock<wpi::mutex> lock(m_cacheDataMutex);
- *buttons = m_joystickButtons[joystickNum];
- return 0;
+ return HAL_GetJoystickButtonsInternal(joystickNum, buttons);
}
int32_t HAL_GetJoystickDescriptor(int32_t joystickNum,
HAL_JoystickDescriptor* desc) {
- std::unique_lock<wpi::mutex> lock(m_cacheDataMutex);
- *desc = m_joystickDescriptor[joystickNum];
- return 0;
+ return HAL_GetJoystickDescriptorInternal(joystickNum, desc);
}
int32_t HAL_GetMatchInfo(HAL_MatchInfo* info) {
- std::unique_lock<wpi::mutex> lock(m_cacheDataMutex);
- *info = *m_matchInfo;
- return 0;
+ return HAL_GetMatchInfoInternal(info);
}
HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status) {
@@ -448,10 +344,8 @@
// 20ms rate occurs once every 2.7 years of DS connected runtime, so not
// worth the cycles to check.
thread_local int lastCount{-1};
- if (!dsThread) return false;
- auto thr = dsThread->GetThread();
- if (!thr) return false;
- int currentCount = thr->newDSDataAvailableCounter;
+ std::lock_guard lock{*newDSDataAvailableMutex};
+ int currentCount = newDSDataAvailableCounter;
if (lastCount == currentCount) return false;
lastCount = currentCount;
return true;
@@ -471,19 +365,16 @@
auto timeoutTime =
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
- if (!dsThread) return false;
- auto thr = dsThread->GetThread();
- if (!thr) return false;
- int currentCount = thr->newDSDataAvailableCounter;
- while (thr->newDSDataAvailableCounter == currentCount) {
+ std::unique_lock lock{*newDSDataAvailableMutex};
+ int currentCount = newDSDataAvailableCounter;
+ while (newDSDataAvailableCounter == currentCount) {
if (timeout > 0) {
- auto timedOut =
- thr->newDSDataAvailableCond.wait_until(thr.GetLock(), timeoutTime);
+ auto timedOut = newDSDataAvailableCond->wait_until(lock, timeoutTime);
if (timedOut == std::cv_status::timeout) {
return false;
}
} else {
- thr->newDSDataAvailableCond.wait(thr.GetLock());
+ newDSDataAvailableCond->wait(lock);
}
}
return true;
@@ -496,7 +387,9 @@
// Since we could get other values, require our specific handle
// to signal our threads
if (refNum != refNumber) return;
- dsThread->Notify();
+ // Notify all threads
+ newDSDataAvailableCounter++;
+ newDSDataAvailableCond->notify_all();
}
/*
@@ -510,15 +403,10 @@
// Initial check, as if it's true initialization has finished
if (initialized) return;
- std::lock_guard<wpi::mutex> lock(initializeMutex);
+ std::scoped_lock lock(initializeMutex);
// Second check in case another thread was waiting
if (initialized) return;
- InitializeDriverStationCaches();
-
- dsThread = std::make_unique<DriverStationThreadOwner>();
- dsThread->Start();
-
// Set up the occur function internally with NetComm
NetCommRPCProxy_SetOccurFuncPointer(newDataOccur);
// Set up our occur reference number
diff --git a/hal/src/main/native/athena/HAL.cpp b/hal/src/main/native/athena/HAL.cpp
index dbdb826..a9abde6 100644
--- a/hal/src/main/native/athena/HAL.cpp
+++ b/hal/src/main/native/athena/HAL.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -61,6 +61,7 @@
InitializeFRCDriverStation();
InitializeI2C();
InitialzeInterrupts();
+ InitializeMain();
InitializeNotifier();
InitializePCMInternal();
InitializePDP();
@@ -276,24 +277,6 @@
return !(watchdog->readStatus_PowerAlive(status));
}
-void HAL_BaseInitialize(int32_t* status) {
- static std::atomic_bool initialized{false};
- static wpi::mutex initializeMutex;
- // Initial check, as if it's true initialization has finished
- if (initialized) return;
-
- std::lock_guard<wpi::mutex> lock(initializeMutex);
- // Second check in case another thread was waiting
- if (initialized) return;
- // image 4; Fixes errors caused by multiple processes. Talk to NI about this
- nFPGA::nRoboRIO_FPGANamespace::g_currentTargetClass =
- nLoadOut::kTargetClass_RoboRIO;
-
- global.reset(tGlobal::create(status));
- watchdog.reset(tSysWatchdog::create(status));
- initialized = true;
-}
-
static bool killExistingProgram(int timeout, int mode) {
// Kill any previous robot programs
std::fstream fs;
@@ -341,7 +324,7 @@
// Initial check, as if it's true initialization has finished
if (initialized) return true;
- std::lock_guard<wpi::mutex> lock(initializeMutex);
+ std::scoped_lock lock(initializeMutex);
// Second check in case another thread was waiting
if (initialized) return true;
@@ -367,8 +350,14 @@
setNewDataSem(nullptr);
});
+ // image 4; Fixes errors caused by multiple processes. Talk to NI about this
+ nFPGA::nRoboRIO_FPGANamespace::g_currentTargetClass =
+ nLoadOut::kTargetClass_RoboRIO;
+
int32_t status = 0;
- HAL_BaseInitialize(&status);
+ global.reset(tGlobal::create(&status));
+ watchdog.reset(tSysWatchdog::create(&status));
+
if (status != 0) return false;
HAL_InitializeDriverStation();
@@ -379,8 +368,9 @@
uint64_t rv = HAL_GetFPGATime(&status);
if (status != 0) {
wpi::errs()
- << "Call to HAL_GetFPGATime failed."
- << "Initialization might have failed. Time will not be correct\n";
+ << "Call to HAL_GetFPGATime failed in wpi::Now() with status "
+ << status
+ << ". Initialization might have failed. Time will not be correct\n";
wpi::errs().flush();
return 0u;
}
diff --git a/hal/src/main/native/athena/HALInitializer.h b/hal/src/main/native/athena/HALInitializer.h
index 384fe58..fc38038 100644
--- a/hal/src/main/native/athena/HALInitializer.h
+++ b/hal/src/main/native/athena/HALInitializer.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -38,6 +38,7 @@
extern void InitializeHAL();
extern void InitializeI2C();
extern void InitialzeInterrupts();
+extern void InitializeMain();
extern void InitializeNotifier();
extern void InitializePCMInternal();
extern void InitializePDP();
diff --git a/hal/src/main/native/athena/I2C.cpp b/hal/src/main/native/athena/I2C.cpp
index 907906e..b72e25e 100644
--- a/hal/src/main/native/athena/I2C.cpp
+++ b/hal/src/main/native/athena/I2C.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -52,7 +52,7 @@
}
if (port == HAL_I2C_kOnboard) {
- std::lock_guard<wpi::mutex> lock(digitalI2COnBoardMutex);
+ std::scoped_lock lock(digitalI2COnBoardMutex);
i2COnboardObjCount++;
if (i2COnboardObjCount > 1) return;
int handle = open("/dev/i2c-2", O_RDWR);
@@ -62,7 +62,7 @@
}
i2COnBoardHandle = handle;
} else {
- std::lock_guard<wpi::mutex> lock(digitalI2CMXPMutex);
+ std::scoped_lock lock(digitalI2CMXPMutex);
i2CMXPObjCount++;
if (i2CMXPObjCount > 1) return;
if ((i2CMXPDigitalHandle1 = HAL_InitializeDIOPort(
@@ -108,10 +108,10 @@
rdwr.nmsgs = 2;
if (port == HAL_I2C_kOnboard) {
- std::lock_guard<wpi::mutex> lock(digitalI2COnBoardMutex);
+ std::scoped_lock lock(digitalI2COnBoardMutex);
return ioctl(i2COnBoardHandle, I2C_RDWR, &rdwr);
} else {
- std::lock_guard<wpi::mutex> lock(digitalI2CMXPMutex);
+ std::scoped_lock lock(digitalI2CMXPMutex);
return ioctl(i2CMXPHandle, I2C_RDWR, &rdwr);
}
}
@@ -134,10 +134,10 @@
rdwr.nmsgs = 1;
if (port == HAL_I2C_kOnboard) {
- std::lock_guard<wpi::mutex> lock(digitalI2COnBoardMutex);
+ std::scoped_lock lock(digitalI2COnBoardMutex);
return ioctl(i2COnBoardHandle, I2C_RDWR, &rdwr);
} else {
- std::lock_guard<wpi::mutex> lock(digitalI2CMXPMutex);
+ std::scoped_lock lock(digitalI2CMXPMutex);
return ioctl(i2CMXPHandle, I2C_RDWR, &rdwr);
}
}
@@ -160,10 +160,10 @@
rdwr.nmsgs = 1;
if (port == HAL_I2C_kOnboard) {
- std::lock_guard<wpi::mutex> lock(digitalI2COnBoardMutex);
+ std::scoped_lock lock(digitalI2COnBoardMutex);
return ioctl(i2COnBoardHandle, I2C_RDWR, &rdwr);
} else {
- std::lock_guard<wpi::mutex> lock(digitalI2CMXPMutex);
+ std::scoped_lock lock(digitalI2CMXPMutex);
return ioctl(i2CMXPHandle, I2C_RDWR, &rdwr);
}
}
@@ -175,12 +175,12 @@
}
if (port == HAL_I2C_kOnboard) {
- std::lock_guard<wpi::mutex> lock(digitalI2COnBoardMutex);
+ std::scoped_lock lock(digitalI2COnBoardMutex);
if (i2COnboardObjCount-- == 0) {
close(i2COnBoardHandle);
}
} else {
- std::lock_guard<wpi::mutex> lock(digitalI2CMXPMutex);
+ std::scoped_lock lock(digitalI2CMXPMutex);
if (i2CMXPObjCount-- == 0) {
close(i2CMXPHandle);
}
diff --git a/hal/src/main/native/athena/Interrupts.cpp b/hal/src/main/native/athena/Interrupts.cpp
index c661da4..b0b2071 100644
--- a/hal/src/main/native/athena/Interrupts.cpp
+++ b/hal/src/main/native/athena/Interrupts.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -26,7 +26,7 @@
class InterruptThread : public wpi::SafeThread {
public:
void Main() {
- std::unique_lock<wpi::mutex> lock(m_mutex);
+ std::unique_lock lock(m_mutex);
while (m_active) {
m_cond.wait(lock, [&] { return !m_active || m_notify; });
if (!m_active) break;
@@ -118,7 +118,7 @@
if (anInterrupt == nullptr) {
return nullptr;
}
- anInterrupt->manager->enable(status);
+ anInterrupt->manager->disable(status);
void* param = anInterrupt->param;
return param;
}
diff --git a/hal/src/main/native/athena/Notifier.cpp b/hal/src/main/native/athena/Notifier.cpp
index c457cd1..662b04e 100644
--- a/hal/src/main/native/athena/Notifier.cpp
+++ b/hal/src/main/native/athena/Notifier.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -53,7 +53,7 @@
~NotifierHandleContainer() {
ForEach([](HAL_NotifierHandle handle, Notifier* notifier) {
{
- std::lock_guard<wpi::mutex> lock(notifier->mutex);
+ std::scoped_lock lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = 0;
notifier->active = false;
@@ -66,7 +66,7 @@
static NotifierHandleContainer* notifierHandles;
static void alarmCallback(uint32_t, void*) {
- std::lock_guard<wpi::mutex> lock(notifierMutex);
+ std::scoped_lock lock(notifierMutex);
int32_t status = 0;
uint64_t currentTime = 0;
@@ -77,7 +77,7 @@
notifierHandles->ForEach([&](HAL_NotifierHandle handle, Notifier* notifier) {
if (notifier->triggerTime == UINT64_MAX) return;
if (currentTime == 0) currentTime = HAL_GetFPGATime(&status);
- std::unique_lock<wpi::mutex> lock(notifier->mutex);
+ std::unique_lock lock(notifier->mutex);
if (notifier->triggerTime < currentTime) {
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = currentTime;
@@ -119,7 +119,7 @@
std::atexit(cleanupNotifierAtExit);
if (notifierRefCount.fetch_add(1) == 0) {
- std::lock_guard<wpi::mutex> lock(notifierMutex);
+ std::scoped_lock lock(notifierMutex);
// create manager and alarm if not already created
if (!notifierManager) {
notifierManager = std::make_unique<tInterruptManager>(
@@ -144,7 +144,7 @@
if (!notifier) return;
{
- std::lock_guard<wpi::mutex> lock(notifier->mutex);
+ std::scoped_lock lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = 0;
notifier->active = false;
@@ -158,7 +158,7 @@
// Just in case HAL_StopNotifier() wasn't called...
{
- std::lock_guard<wpi::mutex> lock(notifier->mutex);
+ std::scoped_lock lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = 0;
notifier->active = false;
@@ -177,7 +177,7 @@
// if (notifierAlarm) notifierAlarm->writeEnable(false, status);
// if (notifierManager) notifierManager->disable(status);
- // std::lock_guard<wpi::mutex> lock(notifierMutex);
+ // std::scoped_lock lock(notifierMutex);
// notifierAlarm = nullptr;
// notifierManager = nullptr;
// closestTrigger = UINT64_MAX;
@@ -190,12 +190,12 @@
if (!notifier) return;
{
- std::lock_guard<wpi::mutex> lock(notifier->mutex);
+ std::scoped_lock lock(notifier->mutex);
notifier->triggerTime = triggerTime;
notifier->triggeredTime = UINT64_MAX;
}
- std::lock_guard<wpi::mutex> lock(notifierMutex);
+ std::scoped_lock lock(notifierMutex);
// Update alarm time if closer than current.
if (triggerTime < closestTrigger) {
bool wasActive = (closestTrigger != UINT64_MAX);
@@ -214,7 +214,7 @@
if (!notifier) return;
{
- std::lock_guard<wpi::mutex> lock(notifier->mutex);
+ std::scoped_lock lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
}
}
@@ -223,7 +223,7 @@
int32_t* status) {
auto notifier = notifierHandles->Get(notifierHandle);
if (!notifier) return 0;
- std::unique_lock<wpi::mutex> lock(notifier->mutex);
+ std::unique_lock lock(notifier->mutex);
notifier->cond.wait(lock, [&] {
return !notifier->active || notifier->triggeredTime != UINT64_MAX;
});
diff --git a/hal/src/main/native/athena/PDP.cpp b/hal/src/main/native/athena/PDP.cpp
index 22ea8c1..f27f5da 100644
--- a/hal/src/main/native/athena/PDP.cpp
+++ b/hal/src/main/native/athena/PDP.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -34,7 +34,6 @@
static constexpr int32_t Control1 = 0x70;
static constexpr int32_t TimeoutMs = 100;
-static constexpr int32_t StatusPeriodMs = 25;
/* encoder/decoders */
union PdpStatus1 {
@@ -130,7 +129,7 @@
return HAL_kInvalidHandle;
}
- std::lock_guard<wpi::mutex> lock(pdpHandleMutex);
+ std::scoped_lock lock(pdpHandleMutex);
if (pdpHandles[module] != HAL_kInvalidHandle) {
*status = 0;
@@ -173,9 +172,8 @@
int32_t length = 0;
uint64_t receivedTimestamp = 0;
- HAL_ReadCANPeriodicPacket(handle, Status3, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
return pdpStatus.bits.temp * 1.03250836957542 - 67.8564500484966;
}
@@ -185,9 +183,8 @@
int32_t length = 0;
uint64_t receivedTimestamp = 0;
- HAL_ReadCANPeriodicPacket(handle, Status3, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
return pdpStatus.bits.busVoltage * 0.05 + 4.0; /* 50mV per unit plus 4V. */
}
@@ -206,9 +203,8 @@
if (channel <= 5) {
PdpStatus1 pdpStatus;
- HAL_ReadCANPeriodicPacket(handle, Status1, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, Status1, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
switch (channel) {
case 0:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan1_h8) << 2) |
@@ -237,9 +233,8 @@
}
} else if (channel <= 11) {
PdpStatus2 pdpStatus;
- HAL_ReadCANPeriodicPacket(handle, Status2, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, Status2, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
switch (channel) {
case 6:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan7_h8) << 2) |
@@ -268,9 +263,8 @@
}
} else {
PdpStatus3 pdpStatus;
- HAL_ReadCANPeriodicPacket(handle, Status3, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
switch (channel) {
case 12:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan13_h8) << 2) |
@@ -300,9 +294,8 @@
int32_t length = 0;
uint64_t receivedTimestamp = 0;
- HAL_ReadCANPeriodicPacket(handle, StatusEnergy, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
uint32_t raw;
raw = pdpStatus.bits.TotalCurrent_125mAperunit_h8;
@@ -316,9 +309,8 @@
int32_t length = 0;
uint64_t receivedTimestamp = 0;
- HAL_ReadCANPeriodicPacket(handle, StatusEnergy, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
uint32_t raw;
raw = pdpStatus.bits.Power_125mWperunit_h4;
@@ -334,9 +326,8 @@
int32_t length = 0;
uint64_t receivedTimestamp = 0;
- HAL_ReadCANPeriodicPacket(handle, StatusEnergy, pdpStatus.data, &length,
- &receivedTimestamp, TimeoutMs, StatusPeriodMs,
- status);
+ HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
+ &receivedTimestamp, TimeoutMs, status);
uint32_t raw;
raw = pdpStatus.bits.Energy_125mWPerUnitXTmeas_h4;
diff --git a/hal/src/main/native/athena/PWM.cpp b/hal/src/main/native/athena/PWM.cpp
index 06b527c..a3b141c 100644
--- a/hal/src/main/native/athena/PWM.cpp
+++ b/hal/src/main/native/athena/PWM.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -266,11 +266,9 @@
DigitalPort* dPort = port.get();
- if (speed < -1.0) {
- speed = -1.0;
- } else if (speed > 1.0) {
- speed = 1.0;
- } else if (!std::isfinite(speed)) {
+ if (std::isfinite(speed)) {
+ speed = std::clamp(speed, -1.0, 1.0);
+ } else {
speed = 0.0;
}
diff --git a/hal/src/main/native/athena/Relay.cpp b/hal/src/main/native/athena/Relay.cpp
index 9f7d6c0..71880a8 100644
--- a/hal/src/main/native/athena/Relay.cpp
+++ b/hal/src/main/native/athena/Relay.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -100,7 +100,7 @@
*status = HAL_HANDLE_ERROR;
return;
}
- std::lock_guard<wpi::mutex> lock(digitalRelayMutex);
+ std::scoped_lock lock(digitalRelayMutex);
uint8_t relays = 0;
if (port->fwd) {
relays = relaySystem->readValue_Forward(status);
diff --git a/hal/src/main/native/athena/SPI.cpp b/hal/src/main/native/athena/SPI.cpp
index ddced41..bb0666a 100644
--- a/hal/src/main/native/athena/SPI.cpp
+++ b/hal/src/main/native/athena/SPI.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -55,7 +55,7 @@
// There are two SPI devices: one for ports 0-3 (onboard), the other for port
// 4 (MXP).
if (!spiAutoRunning) return false;
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
return (spiAutoPort >= 0 && spiAutoPort <= 3 && port >= 0 && port <= 3) ||
(spiAutoPort == 4 && port == 4);
}
@@ -253,7 +253,7 @@
xfer.rx_buf = (__u64)dataReceived;
xfer.len = size;
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
return ioctl(HAL_GetSPIHandle(port), SPI_IOC_MESSAGE(1), &xfer);
}
@@ -270,7 +270,7 @@
xfer.tx_buf = (__u64)dataToSend;
xfer.len = sendSize;
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
return ioctl(HAL_GetSPIHandle(port), SPI_IOC_MESSAGE(1), &xfer);
}
@@ -286,7 +286,7 @@
xfer.rx_buf = (__u64)buffer;
xfer.len = count;
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
return ioctl(HAL_GetSPIHandle(port), SPI_IOC_MESSAGE(1), &xfer);
}
@@ -299,7 +299,7 @@
HAL_FreeSPIAuto(port, &status);
{
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
close(HAL_GetSPIHandle(port));
}
@@ -335,7 +335,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
ioctl(HAL_GetSPIHandle(port), SPI_IOC_WR_MAX_SPEED_HZ, &speed);
}
@@ -350,7 +350,7 @@
mode |= (clkIdleHigh ? 2 : 0);
mode |= (sampleOnTrailing ? 1 : 0);
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
ioctl(HAL_GetSPIHandle(port), SPI_IOC_WR_MODE, &mode);
}
@@ -360,7 +360,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
if (port < 4) {
spiSystem->writeChipSelectActiveHigh_Hdr(
spiSystem->readChipSelectActiveHigh_Hdr(status) | (1 << port), status);
@@ -375,7 +375,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiApiMutexes[port]);
+ std::scoped_lock lock(spiApiMutexes[port]);
if (port < 4) {
spiSystem->writeChipSelectActiveHigh_Hdr(
spiSystem->readChipSelectActiveHigh_Hdr(status) & ~(1 << port), status);
@@ -389,7 +389,7 @@
return 0;
}
- std::lock_guard<wpi::mutex> lock(spiHandleMutexes[port]);
+ std::scoped_lock lock(spiHandleMutexes[port]);
switch (port) {
case 0:
return m_spiCS0Handle;
@@ -411,7 +411,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiHandleMutexes[port]);
+ std::scoped_lock lock(spiHandleMutexes[port]);
switch (port) {
case 0:
m_spiCS0Handle = handle;
@@ -439,7 +439,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (spiAutoPort != kSpiMaxHandles) {
*status = RESOURCE_IS_ALLOCATED;
@@ -470,7 +470,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
if (spiAutoPort != port) return;
spiAutoPort = kSpiMaxHandles;
@@ -487,7 +487,7 @@
}
void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t* status) {
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
@@ -510,7 +510,7 @@
HAL_AnalogTriggerType analogTriggerType,
HAL_Bool triggerRising, HAL_Bool triggerFalling,
int32_t* status) {
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
@@ -545,7 +545,7 @@
}
void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status) {
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
@@ -575,7 +575,7 @@
return;
}
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
@@ -594,7 +594,7 @@
}
void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t* status) {
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
@@ -607,7 +607,7 @@
int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint32_t* buffer,
int32_t numToRead, double timeout,
int32_t* status) {
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
@@ -621,7 +621,7 @@
}
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
- std::lock_guard<wpi::mutex> lock(spiAutoMutex);
+ std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
diff --git a/hal/src/main/native/athena/SerialPort.cpp b/hal/src/main/native/athena/SerialPort.cpp
index d2597a9..7ef9b70 100644
--- a/hal/src/main/native/athena/SerialPort.cpp
+++ b/hal/src/main/native/athena/SerialPort.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2019 FIRST. 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 the root directory of */
/* the project. */
@@ -7,168 +7,493 @@
#include "hal/SerialPort.h"
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include <cerrno>
+#include <chrono>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+#include <stdexcept>
#include <string>
+#include <thread>
-#include "HALInitializer.h"
#include "hal/cpp/SerialHelper.h"
-#include "visa/visa.h"
+#include "hal/handles/HandlesInternal.h"
+#include "hal/handles/IndexedHandleResource.h"
-static int32_t resourceManagerHandle{0};
-static HAL_SerialPort portHandles[4];
+namespace {
+struct SerialPort {
+ int portId;
+ struct termios tty;
+ int baudRate;
+
+ double timeout = 0;
+
+ bool termination = false;
+ char terminationChar = '\n';
+};
+} // namespace
+
+namespace hal {
+IndexedHandleResource<HAL_SerialPortHandle, SerialPort, 4,
+ HAL_HandleEnum::SerialPort>* serialPortHandles;
+} // namespace hal
namespace hal {
namespace init {
-void InitializeSerialPort() {}
+void InitializeSerialPort() {
+ static IndexedHandleResource<HAL_SerialPortHandle, SerialPort, 4,
+ HAL_HandleEnum::SerialPort>
+ spH;
+ serialPortHandles = &spH;
+}
} // namespace init
} // namespace hal
+using namespace hal;
+
extern "C" {
-
-void HAL_InitializeSerialPort(HAL_SerialPort port, int32_t* status) {
- hal::init::CheckInit();
- std::string portName;
-
- if (resourceManagerHandle == 0)
- viOpenDefaultRM(reinterpret_cast<ViSession*>(&resourceManagerHandle));
+HAL_SerialPortHandle HAL_InitializeSerialPort(HAL_SerialPort port,
+ int32_t* status) {
+ // hal::init::CheckInit();
hal::SerialHelper serialHelper;
- portName = serialHelper.GetVISASerialPortName(port, status);
+ std::string portName = serialHelper.GetOSSerialPortName(port, status);
if (*status < 0) {
+ return HAL_kInvalidHandle;
+ }
+
+ return HAL_InitializeSerialPortDirect(port, portName.c_str(), status);
+}
+HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
+ const char* portName,
+ int32_t* status) {
+ auto handle = serialPortHandles->Allocate(static_cast<int16_t>(port), status);
+
+ if (*status != 0) {
+ return HAL_kInvalidHandle;
+ }
+
+ auto serialPort = serialPortHandles->Get(handle);
+
+ if (serialPort == nullptr) {
+ *status = HAL_HANDLE_ERROR;
+ return HAL_kInvalidHandle;
+ }
+
+ serialPort->portId = open(portName, O_RDWR | O_NOCTTY);
+ if (serialPort->portId < 0) {
+ *status = errno;
+ serialPortHandles->Free(handle);
+ return HAL_kInvalidHandle;
+ }
+
+ std::memset(&serialPort->tty, 0, sizeof(serialPort->tty));
+
+ serialPort->baudRate = B9600;
+ cfsetospeed(&serialPort->tty, static_cast<speed_t>(serialPort->baudRate));
+ cfsetispeed(&serialPort->tty, static_cast<speed_t>(serialPort->baudRate));
+
+ serialPort->tty.c_cflag &= ~PARENB;
+ serialPort->tty.c_cflag &= ~CSTOPB;
+ serialPort->tty.c_cflag &= ~CSIZE;
+ serialPort->tty.c_cflag |= CS8;
+
+ serialPort->tty.c_cc[VMIN] = 0;
+ serialPort->tty.c_cc[VTIME] = 10;
+
+ serialPort->tty.c_cflag |= CREAD | CLOCAL;
+
+ serialPort->tty.c_lflag &= ~(ICANON | ECHO | ISIG);
+ serialPort->tty.c_iflag &= ~(IXON | IXOFF | IXANY);
+ /* Raw output mode, sends the raw and unprocessed data (send as it is).
+ * If it is in canonical mode and sending new line char then CR
+ * will be added as prefix and send as CR LF
+ */
+ serialPort->tty.c_oflag = ~OPOST;
+
+ tcflush(serialPort->portId, TCIOFLUSH);
+ if (tcsetattr(serialPort->portId, TCSANOW, &serialPort->tty) != 0) {
+ *status = errno;
+ close(serialPort->portId);
+ serialPortHandles->Free(handle);
+ return HAL_kInvalidHandle;
+ }
+ return handle;
+}
+
+void HAL_CloseSerial(HAL_SerialPortHandle handle, int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ serialPortHandles->Free(handle);
+
+ if (port) {
+ close(port->portId);
+ }
+}
+
+int HAL_GetSerialFD(HAL_SerialPortHandle handle, int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return -1;
+ }
+ return port->portId;
+}
+
+#define BAUDCASE(BAUD) \
+ case BAUD: \
+ port->baudRate = B##BAUD; \
+ break;
+
+void HAL_SetSerialBaudRate(HAL_SerialPortHandle handle, int32_t baud,
+ int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
return;
}
- *status = viOpen(resourceManagerHandle, const_cast<char*>(portName.c_str()),
- VI_NULL, VI_NULL,
- reinterpret_cast<ViSession*>(&portHandles[port]));
- if (*status > 0) *status = 0;
+ switch (baud) {
+ BAUDCASE(50)
+ BAUDCASE(75)
+ BAUDCASE(110)
+ BAUDCASE(134)
+ BAUDCASE(150)
+ BAUDCASE(200)
+ BAUDCASE(300)
+ BAUDCASE(600)
+ BAUDCASE(1200)
+ BAUDCASE(1800)
+ BAUDCASE(2400)
+ BAUDCASE(4800)
+ BAUDCASE(9600)
+ BAUDCASE(19200)
+ BAUDCASE(38400)
+ BAUDCASE(57600)
+ BAUDCASE(115200)
+ BAUDCASE(230400)
+ BAUDCASE(460800)
+ BAUDCASE(500000)
+ BAUDCASE(576000)
+ BAUDCASE(921600)
+ BAUDCASE(1000000)
+ BAUDCASE(1152000)
+ BAUDCASE(1500000)
+ BAUDCASE(2000000)
+ BAUDCASE(2500000)
+ BAUDCASE(3000000)
+ BAUDCASE(3500000)
+ BAUDCASE(4000000)
+ default:
+ *status = PARAMETER_OUT_OF_RANGE;
+ return;
+ }
+ int err = cfsetospeed(&port->tty, static_cast<speed_t>(port->baudRate));
+ if (err < 0) {
+ *status = errno;
+ return;
+ }
+ err = cfsetispeed(&port->tty, static_cast<speed_t>(port->baudRate));
+ if (err < 0) {
+ *status = errno;
+ return;
+ }
+ err = tcsetattr(port->portId, TCSANOW, &port->tty);
+ if (err < 0) {
+ *status = errno;
+ }
}
-void HAL_InitializeSerialPortDirect(HAL_SerialPort port, const char* portName,
- int32_t* status) {
- *status = viOpen(resourceManagerHandle, const_cast<char*>(portName), VI_NULL,
- VI_NULL, reinterpret_cast<ViSession*>(&portHandles[port]));
- if (*status > 0) *status = 0;
-}
-
-void HAL_SetSerialBaudRate(HAL_SerialPort port, int32_t baud, int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_ASRL_BAUD, baud);
- if (*status > 0) *status = 0;
-}
-
-void HAL_SetSerialDataBits(HAL_SerialPort port, int32_t bits, int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_ASRL_DATA_BITS, bits);
- if (*status > 0) *status = 0;
-}
-
-void HAL_SetSerialParity(HAL_SerialPort port, int32_t parity, int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_ASRL_PARITY, parity);
- if (*status > 0) *status = 0;
-}
-
-void HAL_SetSerialStopBits(HAL_SerialPort port, int32_t stopBits,
+void HAL_SetSerialDataBits(HAL_SerialPortHandle handle, int32_t bits,
int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_ASRL_STOP_BITS, stopBits);
- if (*status > 0) *status = 0;
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+
+ int bitFlag = -1;
+ switch (bits) {
+ case 5:
+ bitFlag = CS5;
+ break;
+ case 6:
+ bitFlag = CS6;
+ break;
+ case 7:
+ bitFlag = CS7;
+ break;
+ case 8:
+ bitFlag = CS8;
+ break;
+ default:
+ *status = PARAMETER_OUT_OF_RANGE;
+ return;
+ }
+
+ port->tty.c_cflag &= ~CSIZE;
+ port->tty.c_cflag |= bitFlag;
+
+ int err = tcsetattr(port->portId, TCSANOW, &port->tty);
+ if (err < 0) {
+ *status = errno;
+ }
}
-void HAL_SetSerialWriteMode(HAL_SerialPort port, int32_t mode,
+void HAL_SetSerialParity(HAL_SerialPortHandle handle, int32_t parity,
+ int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+
+ switch (parity) {
+ case 0: // None
+ port->tty.c_cflag &= ~PARENB;
+ port->tty.c_cflag &= ~CMSPAR;
+ break;
+ case 1: // Odd
+ port->tty.c_cflag |= PARENB;
+ port->tty.c_cflag &= ~CMSPAR;
+ port->tty.c_cflag &= ~PARODD;
+ break;
+ case 2: // Even
+ port->tty.c_cflag |= PARENB;
+ port->tty.c_cflag &= ~CMSPAR;
+ port->tty.c_cflag |= PARODD;
+ break;
+ case 3: // Mark
+ port->tty.c_cflag |= PARENB;
+ port->tty.c_cflag |= CMSPAR;
+ port->tty.c_cflag |= PARODD;
+ break;
+ case 4: // Space
+ port->tty.c_cflag |= PARENB;
+ port->tty.c_cflag |= CMSPAR;
+ port->tty.c_cflag &= ~PARODD;
+ break;
+ default:
+ *status = PARAMETER_OUT_OF_RANGE;
+ return;
+ }
+
+ int err = tcsetattr(port->portId, TCSANOW, &port->tty);
+ if (err < 0) {
+ *status = errno;
+ }
+}
+
+void HAL_SetSerialStopBits(HAL_SerialPortHandle handle, int32_t stopBits,
+ int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+
+ switch (stopBits) {
+ case 10: // 1
+ port->tty.c_cflag &= ~CSTOPB;
+ break;
+ case 15: // 1.5
+ case 20: // 2
+ port->tty.c_cflag |= CSTOPB;
+ break;
+ default:
+ *status = PARAMETER_OUT_OF_RANGE;
+ return;
+ }
+
+ int err = tcsetattr(port->portId, TCSANOW, &port->tty);
+ if (err < 0) {
+ *status = errno;
+ }
+}
+
+void HAL_SetSerialWriteMode(HAL_SerialPortHandle handle, int32_t mode,
int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_WR_BUF_OPER_MODE, mode);
- if (*status > 0) *status = 0;
+ // This seems to be a no op on the NI serial port driver
}
-void HAL_SetSerialFlowControl(HAL_SerialPort port, int32_t flow,
+void HAL_SetSerialFlowControl(HAL_SerialPortHandle handle, int32_t flow,
int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_ASRL_FLOW_CNTRL, flow);
- if (*status > 0) *status = 0;
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+
+ switch (flow) {
+ case 0:
+ port->tty.c_cflag &= ~CRTSCTS;
+ break;
+ case 1:
+ port->tty.c_cflag &= ~CRTSCTS;
+ port->tty.c_iflag &= IXON | IXOFF;
+ break;
+ case 2:
+ port->tty.c_cflag |= CRTSCTS;
+ break;
+ default:
+ *status = PARAMETER_OUT_OF_RANGE;
+ return;
+ }
+
+ int err = tcsetattr(port->portId, TCSANOW, &port->tty);
+ if (err < 0) {
+ *status = errno;
+ }
}
-void HAL_SetSerialTimeout(HAL_SerialPort port, double timeout,
+void HAL_SetSerialTimeout(HAL_SerialPortHandle handle, double timeout,
int32_t* status) {
- *status = viSetAttribute(portHandles[port], VI_ATTR_TMO_VALUE,
- static_cast<uint32_t>(timeout * 1e3));
- if (*status > 0) *status = 0;
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+ port->timeout = timeout;
+ port->tty.c_cc[VTIME] = static_cast<int>(timeout * 10);
+ int err = tcsetattr(port->portId, TCSANOW, &port->tty);
+ if (err < 0) {
+ *status = errno;
+ }
}
-void HAL_EnableSerialTermination(HAL_SerialPort port, char terminator,
+void HAL_EnableSerialTermination(HAL_SerialPortHandle handle, char terminator,
int32_t* status) {
- viSetAttribute(portHandles[port], VI_ATTR_TERMCHAR_EN, VI_TRUE);
- viSetAttribute(portHandles[port], VI_ATTR_TERMCHAR, terminator);
- *status = viSetAttribute(portHandles[port], VI_ATTR_ASRL_END_IN,
- VI_ASRL_END_TERMCHAR);
- if (*status > 0) *status = 0;
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+ port->termination = true;
+ port->terminationChar = terminator;
}
-void HAL_DisableSerialTermination(HAL_SerialPort port, int32_t* status) {
- viSetAttribute(portHandles[port], VI_ATTR_TERMCHAR_EN, VI_FALSE);
- *status =
- viSetAttribute(portHandles[port], VI_ATTR_ASRL_END_IN, VI_ASRL_END_NONE);
- if (*status > 0) *status = 0;
-}
-
-void HAL_SetSerialReadBufferSize(HAL_SerialPort port, int32_t size,
- int32_t* status) {
- *status = viSetBuf(portHandles[port], VI_READ_BUF, size);
- if (*status > 0) *status = 0;
-}
-
-void HAL_SetSerialWriteBufferSize(HAL_SerialPort port, int32_t size,
+void HAL_DisableSerialTermination(HAL_SerialPortHandle handle,
int32_t* status) {
- *status = viSetBuf(portHandles[port], VI_WRITE_BUF, size);
- if (*status > 0) *status = 0;
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+ port->termination = false;
}
-int32_t HAL_GetSerialBytesReceived(HAL_SerialPort port, int32_t* status) {
- int32_t bytes = 0;
+void HAL_SetSerialReadBufferSize(HAL_SerialPortHandle handle, int32_t size,
+ int32_t* status) {
+ // NO OP currently
+}
- *status = viGetAttribute(portHandles[port], VI_ATTR_ASRL_AVAIL_NUM, &bytes);
- if (*status > 0) *status = 0;
+void HAL_SetSerialWriteBufferSize(HAL_SerialPortHandle handle, int32_t size,
+ int32_t* status) {
+ // NO OP currently
+}
+
+int32_t HAL_GetSerialBytesReceived(HAL_SerialPortHandle handle,
+ int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return -1;
+ }
+ int bytes = 0;
+ int err = ioctl(port->portId, FIONREAD, &bytes);
+ if (err < 0) {
+ *status = errno;
+ }
return bytes;
}
-int32_t HAL_ReadSerial(HAL_SerialPort port, char* buffer, int32_t count,
+int32_t HAL_ReadSerial(HAL_SerialPortHandle handle, char* buffer, int32_t count,
int32_t* status) {
- uint32_t retCount = 0;
+ // Don't do anything if 0 bytes were requested
+ if (count == 0) return 0;
- *status =
- viRead(portHandles[port], (ViPBuf)buffer, count, (ViPUInt32)&retCount);
-
- if (*status == VI_ERROR_IO || *status == VI_ERROR_ASRL_OVERRUN ||
- *status == VI_ERROR_ASRL_FRAMING || *status == VI_ERROR_ASRL_PARITY) {
- int32_t localStatus = 0;
- HAL_ClearSerial(port, &localStatus);
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return -1;
}
- if (*status == VI_ERROR_TMO || *status > 0) *status = 0;
- return static_cast<int32_t>(retCount);
+ int n = 0, loc = 0;
+ char buf = '\0';
+ std::memset(buffer, '\0', count);
+ *status = 0;
+
+ do {
+ n = read(port->portId, &buf, 1);
+ if (n == 1) {
+ buffer[loc] = buf;
+ loc++;
+ // If buffer is full, return
+ if (loc == count) {
+ return loc;
+ }
+ // If terminating, and termination was hit return;
+ if (port->termination && buf == port->terminationChar) {
+ return loc;
+ }
+ } else if (n == -1) {
+ // ERROR
+ *status = errno;
+ return loc;
+ } else {
+ // If nothing read, timeout
+ return loc;
+ }
+ } while (true);
}
-int32_t HAL_WriteSerial(HAL_SerialPort port, const char* buffer, int32_t count,
- int32_t* status) {
- uint32_t retCount = 0;
+int32_t HAL_WriteSerial(HAL_SerialPortHandle handle, const char* buffer,
+ int32_t count, int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return -1;
+ }
- *status =
- viWrite(portHandles[port], (ViPBuf)buffer, count, (ViPUInt32)&retCount);
-
- if (*status > 0) *status = 0;
- return static_cast<int32_t>(retCount);
+ int written = 0, spot = 0;
+ do {
+ written = write(port->portId, buffer + spot, count - spot);
+ if (written < 0) {
+ *status = errno;
+ return spot;
+ }
+ spot += written;
+ } while (spot < count);
+ return spot;
}
-void HAL_FlushSerial(HAL_SerialPort port, int32_t* status) {
- *status = viFlush(portHandles[port], VI_WRITE_BUF);
- if (*status > 0) *status = 0;
+void HAL_FlushSerial(HAL_SerialPortHandle handle, int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+ int err = tcdrain(port->portId);
+ if (err < 0) {
+ *status = errno;
+ }
}
-
-void HAL_ClearSerial(HAL_SerialPort port, int32_t* status) {
- *status = viClear(portHandles[port]);
- if (*status > 0) *status = 0;
+void HAL_ClearSerial(HAL_SerialPortHandle handle, int32_t* status) {
+ auto port = serialPortHandles->Get(handle);
+ if (!port) {
+ *status = HAL_HANDLE_ERROR;
+ return;
+ }
+ int err = tcflush(port->portId, TCIOFLUSH);
+ if (err < 0) {
+ *status = errno;
+ }
}
-
-void HAL_CloseSerial(HAL_SerialPort port, int32_t* status) {
- *status = viClose(portHandles[port]);
- if (*status > 0) *status = 0;
-}
-
} // extern "C"
diff --git a/hal/src/main/native/athena/SimDevice.cpp b/hal/src/main/native/athena/SimDevice.cpp
new file mode 100644
index 0000000..94a65d4
--- /dev/null
+++ b/hal/src/main/native/athena/SimDevice.cpp
@@ -0,0 +1,41 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) 2019 FIRST. 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 the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
+#include "hal/SimDevice.h"
+
+extern "C" {
+
+HAL_SimDeviceHandle HAL_CreateSimDevice(const char* name) { return 0; }
+
+void HAL_FreeSimDevice(HAL_SimDeviceHandle handle) {}
+
+HAL_SimValueHandle HAL_CreateSimValue(HAL_SimDeviceHandle device,
+ const char* name, HAL_Bool readonly,
+ const struct HAL_Value* initialValue) {
+ return 0;
+}
+
+HAL_SimValueHandle HAL_CreateSimValueEnum(HAL_SimDeviceHandle device,
+ const char* name, HAL_Bool readonly,
+ int32_t numOptions,
+ const char** options,
+ int32_t initialValue) {
+ return 0;
+}
+
+void HAL_GetSimValue(HAL_SimValueHandle handle, struct HAL_Value* value) {
+ value->type = HAL_UNASSIGNED;
+}
+
+void HAL_SetSimValue(HAL_SimValueHandle handle, const struct HAL_Value* value) {
+}
+
+hal::SimDevice::SimDevice(const char* name, int index) {}
+
+hal::SimDevice::SimDevice(const char* name, int index, int channel) {}
+
+} // extern "C"
diff --git a/hal/src/main/native/athena/cpp/SerialHelper.cpp b/hal/src/main/native/athena/cpp/SerialHelper.cpp
index 98b22db..e312e2a 100644
--- a/hal/src/main/native/athena/cpp/SerialHelper.cpp
+++ b/hal/src/main/native/athena/cpp/SerialHelper.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -14,8 +14,8 @@
#include <wpi/FileSystem.h>
#include <wpi/StringRef.h>
-#include "../visa/visa.h"
#include "hal/Errors.h"
+#include "visa/visa.h"
constexpr const char* OnboardResourceVISA = "ASRL1::INSTR";
constexpr const char* MxpResourceVISA = "ASRL2::INSTR";
@@ -275,7 +275,7 @@
int32_t SerialHelper::GetIndexForPort(HAL_SerialPort port, int32_t* status) {
// Hold lock whenever we're using the names array
- std::lock_guard<wpi::mutex> lock(m_nameMutex);
+ std::scoped_lock lock(m_nameMutex);
std::string portString = m_usbNames[port - 2];
diff --git a/hal/src/main/native/athena/ctre/CtreCanNode.cpp b/hal/src/main/native/athena/ctre/CtreCanNode.cpp
index bd3c9e8..440bebd 100644
--- a/hal/src/main/native/athena/ctre/CtreCanNode.cpp
+++ b/hal/src/main/native/athena/ctre/CtreCanNode.cpp
@@ -86,7 +86,7 @@
if(timeoutMs > 999)
timeoutMs = 999;
FRC_NetworkCommunication_CANSessionMux_receiveMessage(&arbId,kFullMessageIDMask,dataBytes,&len,&timeStamp,&status);
- std::lock_guard<wpi::mutex> lock(_lck);
+ std::scoped_lock lock(_lck);
if(status == 0){
/* fresh update */
rxEvent_t & r = _rxRxEvents[arbId]; /* lookup entry or make a default new one with all zeroes */
diff --git a/hal/src/main/native/athena/visa/visa.h b/hal/src/main/native/athena/visa/visa.h
deleted file mode 100644
index 3c6ad30..0000000
--- a/hal/src/main/native/athena/visa/visa.h
+++ /dev/null
@@ -1,1064 +0,0 @@
-/*---------------------------------------------------------------------------*/
-/* Distributed by IVI Foundation Inc. */
-/* Contains National Instruments extensions. */
-/* Do not modify the contents of this file. */
-/*---------------------------------------------------------------------------*/
-/* */
-/* Title : VISA.H */
-/* Date : 10-09-2006 */
-/* Purpose : Include file for the VISA Library 4.0 specification */
-/* */
-/*---------------------------------------------------------------------------*/
-/* When using NI-VISA extensions, you must link with the VISA library that */
-/* comes with NI-VISA. Currently, the extensions provided by NI-VISA are: */
-/* */
-/* PXI (Compact PCI eXtensions for Instrumentation) and PCI support. To use */
-/* this, you must define the macro NIVISA_PXI before including this header. */
-/* You must also create an INF file with the VISA Driver Development Wizard. */
-/* */
-/* A fast set of macros for viPeekXX/viPokeXX that guarantees binary */
-/* compatibility with other implementations of VISA. To use this, you must */
-/* define the macro NIVISA_PEEKPOKE before including this header. */
-/* */
-/* Support for USB devices that do not conform to a specific class. To use */
-/* this, you must define the macro NIVISA_USB before including this header. */
-/* You must also create an INF file with the VISA Driver Development Wizard. */
-/*---------------------------------------------------------------------------*/
-
-#ifndef __VISA_HEADER__
-#define __VISA_HEADER__
-
-#include <stdarg.h>
-
-#if !defined(__VISATYPE_HEADER__)
-#include "visatype.h"
-#endif
-
-#define VI_SPEC_VERSION (0x00400000UL)
-
-#if defined(__cplusplus) || defined(__cplusplus__)
- extern "C" {
-#endif
-
-#if defined(_CVI_)
-#pragma EnableLibraryRuntimeChecking
-#endif
-
-/*- VISA Types --------------------------------------------------------------*/
-
-typedef ViObject ViEvent;
-typedef ViEvent _VI_PTR ViPEvent;
-typedef ViObject ViFindList;
-typedef ViFindList _VI_PTR ViPFindList;
-
-#if defined(_VI_INT64_UINT64_DEFINED) && defined(_VISA_ENV_IS_64_BIT)
-typedef ViUInt64 ViBusAddress;
-typedef ViUInt64 ViBusSize;
-typedef ViUInt64 ViAttrState;
-#else
-typedef ViUInt32 ViBusAddress;
-typedef ViUInt32 ViBusSize;
-typedef ViUInt32 ViAttrState;
-#endif
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-typedef ViUInt64 ViBusAddress64;
-typedef ViBusAddress64 _VI_PTR ViPBusAddress64;
-#endif
-
-typedef ViUInt32 ViEventType;
-typedef ViEventType _VI_PTR ViPEventType;
-typedef ViEventType _VI_PTR ViAEventType;
-typedef void _VI_PTR ViPAttrState;
-typedef ViAttr _VI_PTR ViPAttr;
-typedef ViAttr _VI_PTR ViAAttr;
-
-typedef ViString ViKeyId;
-typedef ViPString ViPKeyId;
-typedef ViUInt32 ViJobId;
-typedef ViJobId _VI_PTR ViPJobId;
-typedef ViUInt32 ViAccessMode;
-typedef ViAccessMode _VI_PTR ViPAccessMode;
-typedef ViBusAddress _VI_PTR ViPBusAddress;
-typedef ViUInt32 ViEventFilter;
-
-typedef va_list ViVAList;
-
-typedef ViStatus (_VI_FUNCH _VI_PTR ViHndlr)
- (ViSession vi, ViEventType eventType, ViEvent event, ViAddr userHandle);
-
-/*- Resource Manager Functions and Operations -------------------------------*/
-
-ViStatus _VI_FUNC viOpenDefaultRM (ViPSession vi);
-ViStatus _VI_FUNC viFindRsrc (ViSession sesn, ViString expr, ViPFindList vi,
- ViPUInt32 retCnt, ViChar _VI_FAR desc[]);
-ViStatus _VI_FUNC viFindNext (ViFindList vi, ViChar _VI_FAR desc[]);
-ViStatus _VI_FUNC viParseRsrc (ViSession rmSesn, ViRsrc rsrcName,
- ViPUInt16 intfType, ViPUInt16 intfNum);
-ViStatus _VI_FUNC viParseRsrcEx (ViSession rmSesn, ViRsrc rsrcName, ViPUInt16 intfType,
- ViPUInt16 intfNum, ViChar _VI_FAR rsrcClass[],
- ViChar _VI_FAR expandedUnaliasedName[],
- ViChar _VI_FAR aliasIfExists[]);
-ViStatus _VI_FUNC viOpen (ViSession sesn, ViRsrc name, ViAccessMode mode,
- ViUInt32 timeout, ViPSession vi);
-
-/*- Resource Template Operations --------------------------------------------*/
-
-ViStatus _VI_FUNC viClose (ViObject vi);
-ViStatus _VI_FUNC viSetAttribute (ViObject vi, ViAttr attrName, ViAttrState attrValue);
-ViStatus _VI_FUNC viGetAttribute (ViObject vi, ViAttr attrName, void _VI_PTR attrValue);
-ViStatus _VI_FUNC viStatusDesc (ViObject vi, ViStatus status, ViChar _VI_FAR desc[]);
-ViStatus _VI_FUNC viTerminate (ViObject vi, ViUInt16 degree, ViJobId jobId);
-
-ViStatus _VI_FUNC viLock (ViSession vi, ViAccessMode lockType, ViUInt32 timeout,
- ViKeyId requestedKey, ViChar _VI_FAR accessKey[]);
-ViStatus _VI_FUNC viUnlock (ViSession vi);
-ViStatus _VI_FUNC viEnableEvent (ViSession vi, ViEventType eventType, ViUInt16 mechanism,
- ViEventFilter context);
-ViStatus _VI_FUNC viDisableEvent (ViSession vi, ViEventType eventType, ViUInt16 mechanism);
-ViStatus _VI_FUNC viDiscardEvents (ViSession vi, ViEventType eventType, ViUInt16 mechanism);
-ViStatus _VI_FUNC viWaitOnEvent (ViSession vi, ViEventType inEventType, ViUInt32 timeout,
- ViPEventType outEventType, ViPEvent outContext);
-ViStatus _VI_FUNC viInstallHandler(ViSession vi, ViEventType eventType, ViHndlr handler,
- ViAddr userHandle);
-ViStatus _VI_FUNC viUninstallHandler(ViSession vi, ViEventType eventType, ViHndlr handler,
- ViAddr userHandle);
-
-/*- Basic I/O Operations ----------------------------------------------------*/
-
-ViStatus _VI_FUNC viRead (ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt);
-ViStatus _VI_FUNC viReadAsync (ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPJobId jobId);
-ViStatus _VI_FUNC viReadToFile (ViSession vi, ViConstString filename, ViUInt32 cnt,
- ViPUInt32 retCnt);
-ViStatus _VI_FUNC viWrite (ViSession vi, ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt);
-ViStatus _VI_FUNC viWriteAsync (ViSession vi, ViBuf buf, ViUInt32 cnt, ViPJobId jobId);
-ViStatus _VI_FUNC viWriteFromFile (ViSession vi, ViConstString filename, ViUInt32 cnt,
- ViPUInt32 retCnt);
-ViStatus _VI_FUNC viAssertTrigger (ViSession vi, ViUInt16 protocol);
-ViStatus _VI_FUNC viReadSTB (ViSession vi, ViPUInt16 status);
-ViStatus _VI_FUNC viClear (ViSession vi);
-
-/*- Formatted and Buffered I/O Operations -----------------------------------*/
-
-ViStatus _VI_FUNC viSetBuf (ViSession vi, ViUInt16 mask, ViUInt32 size);
-ViStatus _VI_FUNC viFlush (ViSession vi, ViUInt16 mask);
-
-ViStatus _VI_FUNC viBufWrite (ViSession vi, ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt);
-ViStatus _VI_FUNC viBufRead (ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt);
-
-ViStatus _VI_FUNCC viPrintf (ViSession vi, ViString writeFmt, ...);
-ViStatus _VI_FUNC viVPrintf (ViSession vi, ViString writeFmt, ViVAList params);
-ViStatus _VI_FUNCC viSPrintf (ViSession vi, ViPBuf buf, ViString writeFmt, ...);
-ViStatus _VI_FUNC viVSPrintf (ViSession vi, ViPBuf buf, ViString writeFmt,
- ViVAList parms);
-
-ViStatus _VI_FUNCC viScanf (ViSession vi, ViString readFmt, ...);
-ViStatus _VI_FUNC viVScanf (ViSession vi, ViString readFmt, ViVAList params);
-ViStatus _VI_FUNCC viSScanf (ViSession vi, ViBuf buf, ViString readFmt, ...);
-ViStatus _VI_FUNC viVSScanf (ViSession vi, ViBuf buf, ViString readFmt,
- ViVAList parms);
-
-ViStatus _VI_FUNCC viQueryf (ViSession vi, ViString writeFmt, ViString readFmt, ...);
-ViStatus _VI_FUNC viVQueryf (ViSession vi, ViString writeFmt, ViString readFmt,
- ViVAList params);
-
-/*- Memory I/O Operations ---------------------------------------------------*/
-
-ViStatus _VI_FUNC viIn8 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViPUInt8 val8);
-ViStatus _VI_FUNC viOut8 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViUInt8 val8);
-ViStatus _VI_FUNC viIn16 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViPUInt16 val16);
-ViStatus _VI_FUNC viOut16 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViUInt16 val16);
-ViStatus _VI_FUNC viIn32 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViPUInt32 val32);
-ViStatus _VI_FUNC viOut32 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViUInt32 val32);
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-ViStatus _VI_FUNC viIn64 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViPUInt64 val64);
-ViStatus _VI_FUNC viOut64 (ViSession vi, ViUInt16 space,
- ViBusAddress offset, ViUInt64 val64);
-
-ViStatus _VI_FUNC viIn8Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViPUInt8 val8);
-ViStatus _VI_FUNC viOut8Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViUInt8 val8);
-ViStatus _VI_FUNC viIn16Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViPUInt16 val16);
-ViStatus _VI_FUNC viOut16Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViUInt16 val16);
-ViStatus _VI_FUNC viIn32Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViPUInt32 val32);
-ViStatus _VI_FUNC viOut32Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViUInt32 val32);
-ViStatus _VI_FUNC viIn64Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViPUInt64 val64);
-ViStatus _VI_FUNC viOut64Ex (ViSession vi, ViUInt16 space,
- ViBusAddress64 offset, ViUInt64 val64);
-#endif
-
-ViStatus _VI_FUNC viMoveIn8 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt8 buf8);
-ViStatus _VI_FUNC viMoveOut8 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt8 buf8);
-ViStatus _VI_FUNC viMoveIn16 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt16 buf16);
-ViStatus _VI_FUNC viMoveOut16 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt16 buf16);
-ViStatus _VI_FUNC viMoveIn32 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt32 buf32);
-ViStatus _VI_FUNC viMoveOut32 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt32 buf32);
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-ViStatus _VI_FUNC viMoveIn64 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt64 buf64);
-ViStatus _VI_FUNC viMoveOut64 (ViSession vi, ViUInt16 space, ViBusAddress offset,
- ViBusSize length, ViAUInt64 buf64);
-
-ViStatus _VI_FUNC viMoveIn8Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt8 buf8);
-ViStatus _VI_FUNC viMoveOut8Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt8 buf8);
-ViStatus _VI_FUNC viMoveIn16Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt16 buf16);
-ViStatus _VI_FUNC viMoveOut16Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt16 buf16);
-ViStatus _VI_FUNC viMoveIn32Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt32 buf32);
-ViStatus _VI_FUNC viMoveOut32Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt32 buf32);
-ViStatus _VI_FUNC viMoveIn64Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt64 buf64);
-ViStatus _VI_FUNC viMoveOut64Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset,
- ViBusSize length, ViAUInt64 buf64);
-#endif
-
-ViStatus _VI_FUNC viMove (ViSession vi, ViUInt16 srcSpace, ViBusAddress srcOffset,
- ViUInt16 srcWidth, ViUInt16 destSpace,
- ViBusAddress destOffset, ViUInt16 destWidth,
- ViBusSize srcLength);
-ViStatus _VI_FUNC viMoveAsync (ViSession vi, ViUInt16 srcSpace, ViBusAddress srcOffset,
- ViUInt16 srcWidth, ViUInt16 destSpace,
- ViBusAddress destOffset, ViUInt16 destWidth,
- ViBusSize srcLength, ViPJobId jobId);
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-ViStatus _VI_FUNC viMoveEx (ViSession vi, ViUInt16 srcSpace, ViBusAddress64 srcOffset,
- ViUInt16 srcWidth, ViUInt16 destSpace,
- ViBusAddress64 destOffset, ViUInt16 destWidth,
- ViBusSize srcLength);
-ViStatus _VI_FUNC viMoveAsyncEx (ViSession vi, ViUInt16 srcSpace, ViBusAddress64 srcOffset,
- ViUInt16 srcWidth, ViUInt16 destSpace,
- ViBusAddress64 destOffset, ViUInt16 destWidth,
- ViBusSize srcLength, ViPJobId jobId);
-#endif
-
-ViStatus _VI_FUNC viMapAddress (ViSession vi, ViUInt16 mapSpace, ViBusAddress mapOffset,
- ViBusSize mapSize, ViBoolean access,
- ViAddr suggested, ViPAddr address);
-ViStatus _VI_FUNC viUnmapAddress (ViSession vi);
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-ViStatus _VI_FUNC viMapAddressEx (ViSession vi, ViUInt16 mapSpace, ViBusAddress64 mapOffset,
- ViBusSize mapSize, ViBoolean access,
- ViAddr suggested, ViPAddr address);
-#endif
-
-void _VI_FUNC viPeek8 (ViSession vi, ViAddr address, ViPUInt8 val8);
-void _VI_FUNC viPoke8 (ViSession vi, ViAddr address, ViUInt8 val8);
-void _VI_FUNC viPeek16 (ViSession vi, ViAddr address, ViPUInt16 val16);
-void _VI_FUNC viPoke16 (ViSession vi, ViAddr address, ViUInt16 val16);
-void _VI_FUNC viPeek32 (ViSession vi, ViAddr address, ViPUInt32 val32);
-void _VI_FUNC viPoke32 (ViSession vi, ViAddr address, ViUInt32 val32);
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-void _VI_FUNC viPeek64 (ViSession vi, ViAddr address, ViPUInt64 val64);
-void _VI_FUNC viPoke64 (ViSession vi, ViAddr address, ViUInt64 val64);
-#endif
-
-/*- Shared Memory Operations ------------------------------------------------*/
-
-ViStatus _VI_FUNC viMemAlloc (ViSession vi, ViBusSize size, ViPBusAddress offset);
-ViStatus _VI_FUNC viMemFree (ViSession vi, ViBusAddress offset);
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-ViStatus _VI_FUNC viMemAllocEx (ViSession vi, ViBusSize size, ViPBusAddress64 offset);
-ViStatus _VI_FUNC viMemFreeEx (ViSession vi, ViBusAddress64 offset);
-#endif
-
-/*- Interface Specific Operations -------------------------------------------*/
-
-ViStatus _VI_FUNC viGpibControlREN(ViSession vi, ViUInt16 mode);
-ViStatus _VI_FUNC viGpibControlATN(ViSession vi, ViUInt16 mode);
-ViStatus _VI_FUNC viGpibSendIFC (ViSession vi);
-ViStatus _VI_FUNC viGpibCommand (ViSession vi, ViBuf cmd, ViUInt32 cnt, ViPUInt32 retCnt);
-ViStatus _VI_FUNC viGpibPassControl(ViSession vi, ViUInt16 primAddr, ViUInt16 secAddr);
-
-ViStatus _VI_FUNC viVxiCommandQuery(ViSession vi, ViUInt16 mode, ViUInt32 cmd,
- ViPUInt32 response);
-ViStatus _VI_FUNC viAssertUtilSignal(ViSession vi, ViUInt16 line);
-ViStatus _VI_FUNC viAssertIntrSignal(ViSession vi, ViInt16 mode, ViUInt32 statusID);
-ViStatus _VI_FUNC viMapTrigger (ViSession vi, ViInt16 trigSrc, ViInt16 trigDest,
- ViUInt16 mode);
-ViStatus _VI_FUNC viUnmapTrigger (ViSession vi, ViInt16 trigSrc, ViInt16 trigDest);
-ViStatus _VI_FUNC viUsbControlOut (ViSession vi, ViInt16 bmRequestType, ViInt16 bRequest,
- ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength,
- ViBuf buf);
-ViStatus _VI_FUNC viUsbControlIn (ViSession vi, ViInt16 bmRequestType, ViInt16 bRequest,
- ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength,
- ViPBuf buf, ViPUInt16 retCnt);
-
-/*- Attributes (platform independent size) ----------------------------------*/
-
-#define VI_ATTR_RSRC_CLASS (0xBFFF0001UL)
-#define VI_ATTR_RSRC_NAME (0xBFFF0002UL)
-#define VI_ATTR_RSRC_IMPL_VERSION (0x3FFF0003UL)
-#define VI_ATTR_RSRC_LOCK_STATE (0x3FFF0004UL)
-#define VI_ATTR_MAX_QUEUE_LENGTH (0x3FFF0005UL)
-#define VI_ATTR_USER_DATA_32 (0x3FFF0007UL)
-#define VI_ATTR_FDC_CHNL (0x3FFF000DUL)
-#define VI_ATTR_FDC_MODE (0x3FFF000FUL)
-#define VI_ATTR_FDC_GEN_SIGNAL_EN (0x3FFF0011UL)
-#define VI_ATTR_FDC_USE_PAIR (0x3FFF0013UL)
-#define VI_ATTR_SEND_END_EN (0x3FFF0016UL)
-#define VI_ATTR_TERMCHAR (0x3FFF0018UL)
-#define VI_ATTR_TMO_VALUE (0x3FFF001AUL)
-#define VI_ATTR_GPIB_READDR_EN (0x3FFF001BUL)
-#define VI_ATTR_IO_PROT (0x3FFF001CUL)
-#define VI_ATTR_DMA_ALLOW_EN (0x3FFF001EUL)
-#define VI_ATTR_ASRL_BAUD (0x3FFF0021UL)
-#define VI_ATTR_ASRL_DATA_BITS (0x3FFF0022UL)
-#define VI_ATTR_ASRL_PARITY (0x3FFF0023UL)
-#define VI_ATTR_ASRL_STOP_BITS (0x3FFF0024UL)
-#define VI_ATTR_ASRL_FLOW_CNTRL (0x3FFF0025UL)
-#define VI_ATTR_RD_BUF_OPER_MODE (0x3FFF002AUL)
-#define VI_ATTR_RD_BUF_SIZE (0x3FFF002BUL)
-#define VI_ATTR_WR_BUF_OPER_MODE (0x3FFF002DUL)
-#define VI_ATTR_WR_BUF_SIZE (0x3FFF002EUL)
-#define VI_ATTR_SUPPRESS_END_EN (0x3FFF0036UL)
-#define VI_ATTR_TERMCHAR_EN (0x3FFF0038UL)
-#define VI_ATTR_DEST_ACCESS_PRIV (0x3FFF0039UL)
-#define VI_ATTR_DEST_BYTE_ORDER (0x3FFF003AUL)
-#define VI_ATTR_SRC_ACCESS_PRIV (0x3FFF003CUL)
-#define VI_ATTR_SRC_BYTE_ORDER (0x3FFF003DUL)
-#define VI_ATTR_SRC_INCREMENT (0x3FFF0040UL)
-#define VI_ATTR_DEST_INCREMENT (0x3FFF0041UL)
-#define VI_ATTR_WIN_ACCESS_PRIV (0x3FFF0045UL)
-#define VI_ATTR_WIN_BYTE_ORDER (0x3FFF0047UL)
-#define VI_ATTR_GPIB_ATN_STATE (0x3FFF0057UL)
-#define VI_ATTR_GPIB_ADDR_STATE (0x3FFF005CUL)
-#define VI_ATTR_GPIB_CIC_STATE (0x3FFF005EUL)
-#define VI_ATTR_GPIB_NDAC_STATE (0x3FFF0062UL)
-#define VI_ATTR_GPIB_SRQ_STATE (0x3FFF0067UL)
-#define VI_ATTR_GPIB_SYS_CNTRL_STATE (0x3FFF0068UL)
-#define VI_ATTR_GPIB_HS488_CBL_LEN (0x3FFF0069UL)
-#define VI_ATTR_CMDR_LA (0x3FFF006BUL)
-#define VI_ATTR_VXI_DEV_CLASS (0x3FFF006CUL)
-#define VI_ATTR_MAINFRAME_LA (0x3FFF0070UL)
-#define VI_ATTR_MANF_NAME (0xBFFF0072UL)
-#define VI_ATTR_MODEL_NAME (0xBFFF0077UL)
-#define VI_ATTR_VXI_VME_INTR_STATUS (0x3FFF008BUL)
-#define VI_ATTR_VXI_TRIG_STATUS (0x3FFF008DUL)
-#define VI_ATTR_VXI_VME_SYSFAIL_STATE (0x3FFF0094UL)
-#define VI_ATTR_WIN_BASE_ADDR_32 (0x3FFF0098UL)
-#define VI_ATTR_WIN_SIZE_32 (0x3FFF009AUL)
-#define VI_ATTR_ASRL_AVAIL_NUM (0x3FFF00ACUL)
-#define VI_ATTR_MEM_BASE_32 (0x3FFF00ADUL)
-#define VI_ATTR_ASRL_CTS_STATE (0x3FFF00AEUL)
-#define VI_ATTR_ASRL_DCD_STATE (0x3FFF00AFUL)
-#define VI_ATTR_ASRL_DSR_STATE (0x3FFF00B1UL)
-#define VI_ATTR_ASRL_DTR_STATE (0x3FFF00B2UL)
-#define VI_ATTR_ASRL_END_IN (0x3FFF00B3UL)
-#define VI_ATTR_ASRL_END_OUT (0x3FFF00B4UL)
-#define VI_ATTR_ASRL_REPLACE_CHAR (0x3FFF00BEUL)
-#define VI_ATTR_ASRL_RI_STATE (0x3FFF00BFUL)
-#define VI_ATTR_ASRL_RTS_STATE (0x3FFF00C0UL)
-#define VI_ATTR_ASRL_XON_CHAR (0x3FFF00C1UL)
-#define VI_ATTR_ASRL_XOFF_CHAR (0x3FFF00C2UL)
-#define VI_ATTR_WIN_ACCESS (0x3FFF00C3UL)
-#define VI_ATTR_RM_SESSION (0x3FFF00C4UL)
-#define VI_ATTR_VXI_LA (0x3FFF00D5UL)
-#define VI_ATTR_MANF_ID (0x3FFF00D9UL)
-#define VI_ATTR_MEM_SIZE_32 (0x3FFF00DDUL)
-#define VI_ATTR_MEM_SPACE (0x3FFF00DEUL)
-#define VI_ATTR_MODEL_CODE (0x3FFF00DFUL)
-#define VI_ATTR_SLOT (0x3FFF00E8UL)
-#define VI_ATTR_INTF_INST_NAME (0xBFFF00E9UL)
-#define VI_ATTR_IMMEDIATE_SERV (0x3FFF0100UL)
-#define VI_ATTR_INTF_PARENT_NUM (0x3FFF0101UL)
-#define VI_ATTR_RSRC_SPEC_VERSION (0x3FFF0170UL)
-#define VI_ATTR_INTF_TYPE (0x3FFF0171UL)
-#define VI_ATTR_GPIB_PRIMARY_ADDR (0x3FFF0172UL)
-#define VI_ATTR_GPIB_SECONDARY_ADDR (0x3FFF0173UL)
-#define VI_ATTR_RSRC_MANF_NAME (0xBFFF0174UL)
-#define VI_ATTR_RSRC_MANF_ID (0x3FFF0175UL)
-#define VI_ATTR_INTF_NUM (0x3FFF0176UL)
-#define VI_ATTR_TRIG_ID (0x3FFF0177UL)
-#define VI_ATTR_GPIB_REN_STATE (0x3FFF0181UL)
-#define VI_ATTR_GPIB_UNADDR_EN (0x3FFF0184UL)
-#define VI_ATTR_DEV_STATUS_BYTE (0x3FFF0189UL)
-#define VI_ATTR_FILE_APPEND_EN (0x3FFF0192UL)
-#define VI_ATTR_VXI_TRIG_SUPPORT (0x3FFF0194UL)
-#define VI_ATTR_TCPIP_ADDR (0xBFFF0195UL)
-#define VI_ATTR_TCPIP_HOSTNAME (0xBFFF0196UL)
-#define VI_ATTR_TCPIP_PORT (0x3FFF0197UL)
-#define VI_ATTR_TCPIP_DEVICE_NAME (0xBFFF0199UL)
-#define VI_ATTR_TCPIP_NODELAY (0x3FFF019AUL)
-#define VI_ATTR_TCPIP_KEEPALIVE (0x3FFF019BUL)
-#define VI_ATTR_4882_COMPLIANT (0x3FFF019FUL)
-#define VI_ATTR_USB_SERIAL_NUM (0xBFFF01A0UL)
-#define VI_ATTR_USB_INTFC_NUM (0x3FFF01A1UL)
-#define VI_ATTR_USB_PROTOCOL (0x3FFF01A7UL)
-#define VI_ATTR_USB_MAX_INTR_SIZE (0x3FFF01AFUL)
-#define VI_ATTR_PXI_DEV_NUM (0x3FFF0201UL)
-#define VI_ATTR_PXI_FUNC_NUM (0x3FFF0202UL)
-#define VI_ATTR_PXI_BUS_NUM (0x3FFF0205UL)
-#define VI_ATTR_PXI_CHASSIS (0x3FFF0206UL)
-#define VI_ATTR_PXI_SLOTPATH (0xBFFF0207UL)
-#define VI_ATTR_PXI_SLOT_LBUS_LEFT (0x3FFF0208UL)
-#define VI_ATTR_PXI_SLOT_LBUS_RIGHT (0x3FFF0209UL)
-#define VI_ATTR_PXI_TRIG_BUS (0x3FFF020AUL)
-#define VI_ATTR_PXI_STAR_TRIG_BUS (0x3FFF020BUL)
-#define VI_ATTR_PXI_STAR_TRIG_LINE (0x3FFF020CUL)
-#define VI_ATTR_PXI_MEM_TYPE_BAR0 (0x3FFF0211UL)
-#define VI_ATTR_PXI_MEM_TYPE_BAR1 (0x3FFF0212UL)
-#define VI_ATTR_PXI_MEM_TYPE_BAR2 (0x3FFF0213UL)
-#define VI_ATTR_PXI_MEM_TYPE_BAR3 (0x3FFF0214UL)
-#define VI_ATTR_PXI_MEM_TYPE_BAR4 (0x3FFF0215UL)
-#define VI_ATTR_PXI_MEM_TYPE_BAR5 (0x3FFF0216UL)
-#define VI_ATTR_PXI_MEM_BASE_BAR0 (0x3FFF0221UL)
-#define VI_ATTR_PXI_MEM_BASE_BAR1 (0x3FFF0222UL)
-#define VI_ATTR_PXI_MEM_BASE_BAR2 (0x3FFF0223UL)
-#define VI_ATTR_PXI_MEM_BASE_BAR3 (0x3FFF0224UL)
-#define VI_ATTR_PXI_MEM_BASE_BAR4 (0x3FFF0225UL)
-#define VI_ATTR_PXI_MEM_BASE_BAR5 (0x3FFF0226UL)
-#define VI_ATTR_PXI_MEM_SIZE_BAR0 (0x3FFF0231UL)
-#define VI_ATTR_PXI_MEM_SIZE_BAR1 (0x3FFF0232UL)
-#define VI_ATTR_PXI_MEM_SIZE_BAR2 (0x3FFF0233UL)
-#define VI_ATTR_PXI_MEM_SIZE_BAR3 (0x3FFF0234UL)
-#define VI_ATTR_PXI_MEM_SIZE_BAR4 (0x3FFF0235UL)
-#define VI_ATTR_PXI_MEM_SIZE_BAR5 (0x3FFF0236UL)
-#define VI_ATTR_PXI_IS_EXPRESS (0x3FFF0240UL)
-#define VI_ATTR_PXI_SLOT_LWIDTH (0x3FFF0241UL)
-#define VI_ATTR_PXI_MAX_LWIDTH (0x3FFF0242UL)
-#define VI_ATTR_PXI_ACTUAL_LWIDTH (0x3FFF0243UL)
-#define VI_ATTR_PXI_DSTAR_BUS (0x3FFF0244UL)
-#define VI_ATTR_PXI_DSTAR_SET (0x3FFF0245UL)
-
-#define VI_ATTR_JOB_ID (0x3FFF4006UL)
-#define VI_ATTR_EVENT_TYPE (0x3FFF4010UL)
-#define VI_ATTR_SIGP_STATUS_ID (0x3FFF4011UL)
-#define VI_ATTR_RECV_TRIG_ID (0x3FFF4012UL)
-#define VI_ATTR_INTR_STATUS_ID (0x3FFF4023UL)
-#define VI_ATTR_STATUS (0x3FFF4025UL)
-#define VI_ATTR_RET_COUNT_32 (0x3FFF4026UL)
-#define VI_ATTR_BUFFER (0x3FFF4027UL)
-#define VI_ATTR_RECV_INTR_LEVEL (0x3FFF4041UL)
-#define VI_ATTR_OPER_NAME (0xBFFF4042UL)
-#define VI_ATTR_GPIB_RECV_CIC_STATE (0x3FFF4193UL)
-#define VI_ATTR_RECV_TCPIP_ADDR (0xBFFF4198UL)
-#define VI_ATTR_USB_RECV_INTR_SIZE (0x3FFF41B0UL)
-#define VI_ATTR_USB_RECV_INTR_DATA (0xBFFF41B1UL)
-
-/*- Attributes (platform dependent size) ------------------------------------*/
-
-#if defined(_VI_INT64_UINT64_DEFINED) && defined(_VISA_ENV_IS_64_BIT)
-#define VI_ATTR_USER_DATA_64 (0x3FFF000AUL)
-#define VI_ATTR_RET_COUNT_64 (0x3FFF4028UL)
-#define VI_ATTR_USER_DATA (VI_ATTR_USER_DATA_64)
-#define VI_ATTR_RET_COUNT (VI_ATTR_RET_COUNT_64)
-#else
-#define VI_ATTR_USER_DATA (VI_ATTR_USER_DATA_32)
-#define VI_ATTR_RET_COUNT (VI_ATTR_RET_COUNT_32)
-#endif
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-#define VI_ATTR_WIN_BASE_ADDR_64 (0x3FFF009BUL)
-#define VI_ATTR_WIN_SIZE_64 (0x3FFF009CUL)
-#define VI_ATTR_MEM_BASE_64 (0x3FFF00D0UL)
-#define VI_ATTR_MEM_SIZE_64 (0x3FFF00D1UL)
-#endif
-#if defined(_VI_INT64_UINT64_DEFINED) && defined(_VISA_ENV_IS_64_BIT)
-#define VI_ATTR_WIN_BASE_ADDR (VI_ATTR_WIN_BASE_ADDR_64)
-#define VI_ATTR_WIN_SIZE (VI_ATTR_WIN_SIZE_64)
-#define VI_ATTR_MEM_BASE (VI_ATTR_MEM_BASE_64)
-#define VI_ATTR_MEM_SIZE (VI_ATTR_MEM_SIZE_64)
-#else
-#define VI_ATTR_WIN_BASE_ADDR (VI_ATTR_WIN_BASE_ADDR_32)
-#define VI_ATTR_WIN_SIZE (VI_ATTR_WIN_SIZE_32)
-#define VI_ATTR_MEM_BASE (VI_ATTR_MEM_BASE_32)
-#define VI_ATTR_MEM_SIZE (VI_ATTR_MEM_SIZE_32)
-#endif
-
-/*- Event Types -------------------------------------------------------------*/
-
-#define VI_EVENT_IO_COMPLETION (0x3FFF2009UL)
-#define VI_EVENT_TRIG (0xBFFF200AUL)
-#define VI_EVENT_SERVICE_REQ (0x3FFF200BUL)
-#define VI_EVENT_CLEAR (0x3FFF200DUL)
-#define VI_EVENT_EXCEPTION (0xBFFF200EUL)
-#define VI_EVENT_GPIB_CIC (0x3FFF2012UL)
-#define VI_EVENT_GPIB_TALK (0x3FFF2013UL)
-#define VI_EVENT_GPIB_LISTEN (0x3FFF2014UL)
-#define VI_EVENT_VXI_VME_SYSFAIL (0x3FFF201DUL)
-#define VI_EVENT_VXI_VME_SYSRESET (0x3FFF201EUL)
-#define VI_EVENT_VXI_SIGP (0x3FFF2020UL)
-#define VI_EVENT_VXI_VME_INTR (0xBFFF2021UL)
-#define VI_EVENT_PXI_INTR (0x3FFF2022UL)
-#define VI_EVENT_TCPIP_CONNECT (0x3FFF2036UL)
-#define VI_EVENT_USB_INTR (0x3FFF2037UL)
-
-#define VI_ALL_ENABLED_EVENTS (0x3FFF7FFFUL)
-
-/*- Completion and Error Codes ----------------------------------------------*/
-
-#define VI_SUCCESS_EVENT_EN (0x3FFF0002L) /* 3FFF0002, 1073676290 */
-#define VI_SUCCESS_EVENT_DIS (0x3FFF0003L) /* 3FFF0003, 1073676291 */
-#define VI_SUCCESS_QUEUE_EMPTY (0x3FFF0004L) /* 3FFF0004, 1073676292 */
-#define VI_SUCCESS_TERM_CHAR (0x3FFF0005L) /* 3FFF0005, 1073676293 */
-#define VI_SUCCESS_MAX_CNT (0x3FFF0006L) /* 3FFF0006, 1073676294 */
-#define VI_SUCCESS_DEV_NPRESENT (0x3FFF007DL) /* 3FFF007D, 1073676413 */
-#define VI_SUCCESS_TRIG_MAPPED (0x3FFF007EL) /* 3FFF007E, 1073676414 */
-#define VI_SUCCESS_QUEUE_NEMPTY (0x3FFF0080L) /* 3FFF0080, 1073676416 */
-#define VI_SUCCESS_NCHAIN (0x3FFF0098L) /* 3FFF0098, 1073676440 */
-#define VI_SUCCESS_NESTED_SHARED (0x3FFF0099L) /* 3FFF0099, 1073676441 */
-#define VI_SUCCESS_NESTED_EXCLUSIVE (0x3FFF009AL) /* 3FFF009A, 1073676442 */
-#define VI_SUCCESS_SYNC (0x3FFF009BL) /* 3FFF009B, 1073676443 */
-
-#define VI_WARN_QUEUE_OVERFLOW (0x3FFF000CL) /* 3FFF000C, 1073676300 */
-#define VI_WARN_CONFIG_NLOADED (0x3FFF0077L) /* 3FFF0077, 1073676407 */
-#define VI_WARN_NULL_OBJECT (0x3FFF0082L) /* 3FFF0082, 1073676418 */
-#define VI_WARN_NSUP_ATTR_STATE (0x3FFF0084L) /* 3FFF0084, 1073676420 */
-#define VI_WARN_UNKNOWN_STATUS (0x3FFF0085L) /* 3FFF0085, 1073676421 */
-#define VI_WARN_NSUP_BUF (0x3FFF0088L) /* 3FFF0088, 1073676424 */
-#define VI_WARN_EXT_FUNC_NIMPL (0x3FFF00A9L) /* 3FFF00A9, 1073676457 */
-
-#define VI_ERROR_SYSTEM_ERROR (_VI_ERROR+0x3FFF0000L) /* BFFF0000, -1073807360 */
-#define VI_ERROR_INV_OBJECT (_VI_ERROR+0x3FFF000EL) /* BFFF000E, -1073807346 */
-#define VI_ERROR_RSRC_LOCKED (_VI_ERROR+0x3FFF000FL) /* BFFF000F, -1073807345 */
-#define VI_ERROR_INV_EXPR (_VI_ERROR+0x3FFF0010L) /* BFFF0010, -1073807344 */
-#define VI_ERROR_RSRC_NFOUND (_VI_ERROR+0x3FFF0011L) /* BFFF0011, -1073807343 */
-#define VI_ERROR_INV_RSRC_NAME (_VI_ERROR+0x3FFF0012L) /* BFFF0012, -1073807342 */
-#define VI_ERROR_INV_ACC_MODE (_VI_ERROR+0x3FFF0013L) /* BFFF0013, -1073807341 */
-#define VI_ERROR_TMO (_VI_ERROR+0x3FFF0015L) /* BFFF0015, -1073807339 */
-#define VI_ERROR_CLOSING_FAILED (_VI_ERROR+0x3FFF0016L) /* BFFF0016, -1073807338 */
-#define VI_ERROR_INV_DEGREE (_VI_ERROR+0x3FFF001BL) /* BFFF001B, -1073807333 */
-#define VI_ERROR_INV_JOB_ID (_VI_ERROR+0x3FFF001CL) /* BFFF001C, -1073807332 */
-#define VI_ERROR_NSUP_ATTR (_VI_ERROR+0x3FFF001DL) /* BFFF001D, -1073807331 */
-#define VI_ERROR_NSUP_ATTR_STATE (_VI_ERROR+0x3FFF001EL) /* BFFF001E, -1073807330 */
-#define VI_ERROR_ATTR_READONLY (_VI_ERROR+0x3FFF001FL) /* BFFF001F, -1073807329 */
-#define VI_ERROR_INV_LOCK_TYPE (_VI_ERROR+0x3FFF0020L) /* BFFF0020, -1073807328 */
-#define VI_ERROR_INV_ACCESS_KEY (_VI_ERROR+0x3FFF0021L) /* BFFF0021, -1073807327 */
-#define VI_ERROR_INV_EVENT (_VI_ERROR+0x3FFF0026L) /* BFFF0026, -1073807322 */
-#define VI_ERROR_INV_MECH (_VI_ERROR+0x3FFF0027L) /* BFFF0027, -1073807321 */
-#define VI_ERROR_HNDLR_NINSTALLED (_VI_ERROR+0x3FFF0028L) /* BFFF0028, -1073807320 */
-#define VI_ERROR_INV_HNDLR_REF (_VI_ERROR+0x3FFF0029L) /* BFFF0029, -1073807319 */
-#define VI_ERROR_INV_CONTEXT (_VI_ERROR+0x3FFF002AL) /* BFFF002A, -1073807318 */
-#define VI_ERROR_QUEUE_OVERFLOW (_VI_ERROR+0x3FFF002DL) /* BFFF002D, -1073807315 */
-#define VI_ERROR_NENABLED (_VI_ERROR+0x3FFF002FL) /* BFFF002F, -1073807313 */
-#define VI_ERROR_ABORT (_VI_ERROR+0x3FFF0030L) /* BFFF0030, -1073807312 */
-#define VI_ERROR_RAW_WR_PROT_VIOL (_VI_ERROR+0x3FFF0034L) /* BFFF0034, -1073807308 */
-#define VI_ERROR_RAW_RD_PROT_VIOL (_VI_ERROR+0x3FFF0035L) /* BFFF0035, -1073807307 */
-#define VI_ERROR_OUTP_PROT_VIOL (_VI_ERROR+0x3FFF0036L) /* BFFF0036, -1073807306 */
-#define VI_ERROR_INP_PROT_VIOL (_VI_ERROR+0x3FFF0037L) /* BFFF0037, -1073807305 */
-#define VI_ERROR_BERR (_VI_ERROR+0x3FFF0038L) /* BFFF0038, -1073807304 */
-#define VI_ERROR_IN_PROGRESS (_VI_ERROR+0x3FFF0039L) /* BFFF0039, -1073807303 */
-#define VI_ERROR_INV_SETUP (_VI_ERROR+0x3FFF003AL) /* BFFF003A, -1073807302 */
-#define VI_ERROR_QUEUE_ERROR (_VI_ERROR+0x3FFF003BL) /* BFFF003B, -1073807301 */
-#define VI_ERROR_ALLOC (_VI_ERROR+0x3FFF003CL) /* BFFF003C, -1073807300 */
-#define VI_ERROR_INV_MASK (_VI_ERROR+0x3FFF003DL) /* BFFF003D, -1073807299 */
-#define VI_ERROR_IO (_VI_ERROR+0x3FFF003EL) /* BFFF003E, -1073807298 */
-#define VI_ERROR_INV_FMT (_VI_ERROR+0x3FFF003FL) /* BFFF003F, -1073807297 */
-#define VI_ERROR_NSUP_FMT (_VI_ERROR+0x3FFF0041L) /* BFFF0041, -1073807295 */
-#define VI_ERROR_LINE_IN_USE (_VI_ERROR+0x3FFF0042L) /* BFFF0042, -1073807294 */
-#define VI_ERROR_NSUP_MODE (_VI_ERROR+0x3FFF0046L) /* BFFF0046, -1073807290 */
-#define VI_ERROR_SRQ_NOCCURRED (_VI_ERROR+0x3FFF004AL) /* BFFF004A, -1073807286 */
-#define VI_ERROR_INV_SPACE (_VI_ERROR+0x3FFF004EL) /* BFFF004E, -1073807282 */
-#define VI_ERROR_INV_OFFSET (_VI_ERROR+0x3FFF0051L) /* BFFF0051, -1073807279 */
-#define VI_ERROR_INV_WIDTH (_VI_ERROR+0x3FFF0052L) /* BFFF0052, -1073807278 */
-#define VI_ERROR_NSUP_OFFSET (_VI_ERROR+0x3FFF0054L) /* BFFF0054, -1073807276 */
-#define VI_ERROR_NSUP_VAR_WIDTH (_VI_ERROR+0x3FFF0055L) /* BFFF0055, -1073807275 */
-#define VI_ERROR_WINDOW_NMAPPED (_VI_ERROR+0x3FFF0057L) /* BFFF0057, -1073807273 */
-#define VI_ERROR_RESP_PENDING (_VI_ERROR+0x3FFF0059L) /* BFFF0059, -1073807271 */
-#define VI_ERROR_NLISTENERS (_VI_ERROR+0x3FFF005FL) /* BFFF005F, -1073807265 */
-#define VI_ERROR_NCIC (_VI_ERROR+0x3FFF0060L) /* BFFF0060, -1073807264 */
-#define VI_ERROR_NSYS_CNTLR (_VI_ERROR+0x3FFF0061L) /* BFFF0061, -1073807263 */
-#define VI_ERROR_NSUP_OPER (_VI_ERROR+0x3FFF0067L) /* BFFF0067, -1073807257 */
-#define VI_ERROR_INTR_PENDING (_VI_ERROR+0x3FFF0068L) /* BFFF0068, -1073807256 */
-#define VI_ERROR_ASRL_PARITY (_VI_ERROR+0x3FFF006AL) /* BFFF006A, -1073807254 */
-#define VI_ERROR_ASRL_FRAMING (_VI_ERROR+0x3FFF006BL) /* BFFF006B, -1073807253 */
-#define VI_ERROR_ASRL_OVERRUN (_VI_ERROR+0x3FFF006CL) /* BFFF006C, -1073807252 */
-#define VI_ERROR_TRIG_NMAPPED (_VI_ERROR+0x3FFF006EL) /* BFFF006E, -1073807250 */
-#define VI_ERROR_NSUP_ALIGN_OFFSET (_VI_ERROR+0x3FFF0070L) /* BFFF0070, -1073807248 */
-#define VI_ERROR_USER_BUF (_VI_ERROR+0x3FFF0071L) /* BFFF0071, -1073807247 */
-#define VI_ERROR_RSRC_BUSY (_VI_ERROR+0x3FFF0072L) /* BFFF0072, -1073807246 */
-#define VI_ERROR_NSUP_WIDTH (_VI_ERROR+0x3FFF0076L) /* BFFF0076, -1073807242 */
-#define VI_ERROR_INV_PARAMETER (_VI_ERROR+0x3FFF0078L) /* BFFF0078, -1073807240 */
-#define VI_ERROR_INV_PROT (_VI_ERROR+0x3FFF0079L) /* BFFF0079, -1073807239 */
-#define VI_ERROR_INV_SIZE (_VI_ERROR+0x3FFF007BL) /* BFFF007B, -1073807237 */
-#define VI_ERROR_WINDOW_MAPPED (_VI_ERROR+0x3FFF0080L) /* BFFF0080, -1073807232 */
-#define VI_ERROR_NIMPL_OPER (_VI_ERROR+0x3FFF0081L) /* BFFF0081, -1073807231 */
-#define VI_ERROR_INV_LENGTH (_VI_ERROR+0x3FFF0083L) /* BFFF0083, -1073807229 */
-#define VI_ERROR_INV_MODE (_VI_ERROR+0x3FFF0091L) /* BFFF0091, -1073807215 */
-#define VI_ERROR_SESN_NLOCKED (_VI_ERROR+0x3FFF009CL) /* BFFF009C, -1073807204 */
-#define VI_ERROR_MEM_NSHARED (_VI_ERROR+0x3FFF009DL) /* BFFF009D, -1073807203 */
-#define VI_ERROR_LIBRARY_NFOUND (_VI_ERROR+0x3FFF009EL) /* BFFF009E, -1073807202 */
-#define VI_ERROR_NSUP_INTR (_VI_ERROR+0x3FFF009FL) /* BFFF009F, -1073807201 */
-#define VI_ERROR_INV_LINE (_VI_ERROR+0x3FFF00A0L) /* BFFF00A0, -1073807200 */
-#define VI_ERROR_FILE_ACCESS (_VI_ERROR+0x3FFF00A1L) /* BFFF00A1, -1073807199 */
-#define VI_ERROR_FILE_IO (_VI_ERROR+0x3FFF00A2L) /* BFFF00A2, -1073807198 */
-#define VI_ERROR_NSUP_LINE (_VI_ERROR+0x3FFF00A3L) /* BFFF00A3, -1073807197 */
-#define VI_ERROR_NSUP_MECH (_VI_ERROR+0x3FFF00A4L) /* BFFF00A4, -1073807196 */
-#define VI_ERROR_INTF_NUM_NCONFIG (_VI_ERROR+0x3FFF00A5L) /* BFFF00A5, -1073807195 */
-#define VI_ERROR_CONN_LOST (_VI_ERROR+0x3FFF00A6L) /* BFFF00A6, -1073807194 */
-#define VI_ERROR_MACHINE_NAVAIL (_VI_ERROR+0x3FFF00A7L) /* BFFF00A7, -1073807193 */
-#define VI_ERROR_NPERMISSION (_VI_ERROR+0x3FFF00A8L) /* BFFF00A8, -1073807192 */
-
-/*- Other VISA Definitions --------------------------------------------------*/
-
-#define VI_VERSION_MAJOR(ver) ((((ViVersion)ver) & 0xFFF00000UL) >> 20)
-#define VI_VERSION_MINOR(ver) ((((ViVersion)ver) & 0x000FFF00UL) >> 8)
-#define VI_VERSION_SUBMINOR(ver) ((((ViVersion)ver) & 0x000000FFUL) )
-
-#define VI_FIND_BUFLEN (256)
-
-#define VI_INTF_GPIB (1)
-#define VI_INTF_VXI (2)
-#define VI_INTF_GPIB_VXI (3)
-#define VI_INTF_ASRL (4)
-#define VI_INTF_PXI (5)
-#define VI_INTF_TCPIP (6)
-#define VI_INTF_USB (7)
-
-#define VI_PROT_NORMAL (1)
-#define VI_PROT_FDC (2)
-#define VI_PROT_HS488 (3)
-#define VI_PROT_4882_STRS (4)
-#define VI_PROT_USBTMC_VENDOR (5)
-
-#define VI_FDC_NORMAL (1)
-#define VI_FDC_STREAM (2)
-
-#define VI_LOCAL_SPACE (0)
-#define VI_A16_SPACE (1)
-#define VI_A24_SPACE (2)
-#define VI_A32_SPACE (3)
-#define VI_A64_SPACE (4)
-#define VI_PXI_ALLOC_SPACE (9)
-#define VI_PXI_CFG_SPACE (10)
-#define VI_PXI_BAR0_SPACE (11)
-#define VI_PXI_BAR1_SPACE (12)
-#define VI_PXI_BAR2_SPACE (13)
-#define VI_PXI_BAR3_SPACE (14)
-#define VI_PXI_BAR4_SPACE (15)
-#define VI_PXI_BAR5_SPACE (16)
-#define VI_OPAQUE_SPACE (0xFFFF)
-
-#define VI_UNKNOWN_LA (-1)
-#define VI_UNKNOWN_SLOT (-1)
-#define VI_UNKNOWN_LEVEL (-1)
-#define VI_UNKNOWN_CHASSIS (-1)
-
-#define VI_QUEUE (1)
-#define VI_HNDLR (2)
-#define VI_SUSPEND_HNDLR (4)
-#define VI_ALL_MECH (0xFFFF)
-
-#define VI_ANY_HNDLR (0)
-
-#define VI_TRIG_ALL (-2)
-#define VI_TRIG_SW (-1)
-#define VI_TRIG_TTL0 (0)
-#define VI_TRIG_TTL1 (1)
-#define VI_TRIG_TTL2 (2)
-#define VI_TRIG_TTL3 (3)
-#define VI_TRIG_TTL4 (4)
-#define VI_TRIG_TTL5 (5)
-#define VI_TRIG_TTL6 (6)
-#define VI_TRIG_TTL7 (7)
-#define VI_TRIG_ECL0 (8)
-#define VI_TRIG_ECL1 (9)
-#define VI_TRIG_PANEL_IN (27)
-#define VI_TRIG_PANEL_OUT (28)
-
-#define VI_TRIG_PROT_DEFAULT (0)
-#define VI_TRIG_PROT_ON (1)
-#define VI_TRIG_PROT_OFF (2)
-#define VI_TRIG_PROT_SYNC (5)
-#define VI_TRIG_PROT_RESERVE (6)
-#define VI_TRIG_PROT_UNRESERVE (7)
-
-#define VI_READ_BUF (1)
-#define VI_WRITE_BUF (2)
-#define VI_READ_BUF_DISCARD (4)
-#define VI_WRITE_BUF_DISCARD (8)
-#define VI_IO_IN_BUF (16)
-#define VI_IO_OUT_BUF (32)
-#define VI_IO_IN_BUF_DISCARD (64)
-#define VI_IO_OUT_BUF_DISCARD (128)
-
-#define VI_FLUSH_ON_ACCESS (1)
-#define VI_FLUSH_WHEN_FULL (2)
-#define VI_FLUSH_DISABLE (3)
-
-#define VI_NMAPPED (1)
-#define VI_USE_OPERS (2)
-#define VI_DEREF_ADDR (3)
-#define VI_DEREF_ADDR_BYTE_SWAP (4)
-
-#define VI_TMO_IMMEDIATE (0L)
-#define VI_TMO_INFINITE (0xFFFFFFFFUL)
-
-#define VI_NO_LOCK (0)
-#define VI_EXCLUSIVE_LOCK (1)
-#define VI_SHARED_LOCK (2)
-#define VI_LOAD_CONFIG (4)
-
-#define VI_NO_SEC_ADDR (0xFFFF)
-
-#define VI_ASRL_PAR_NONE (0)
-#define VI_ASRL_PAR_ODD (1)
-#define VI_ASRL_PAR_EVEN (2)
-#define VI_ASRL_PAR_MARK (3)
-#define VI_ASRL_PAR_SPACE (4)
-
-#define VI_ASRL_STOP_ONE (10)
-#define VI_ASRL_STOP_ONE5 (15)
-#define VI_ASRL_STOP_TWO (20)
-
-#define VI_ASRL_FLOW_NONE (0)
-#define VI_ASRL_FLOW_XON_XOFF (1)
-#define VI_ASRL_FLOW_RTS_CTS (2)
-#define VI_ASRL_FLOW_DTR_DSR (4)
-
-#define VI_ASRL_END_NONE (0)
-#define VI_ASRL_END_LAST_BIT (1)
-#define VI_ASRL_END_TERMCHAR (2)
-#define VI_ASRL_END_BREAK (3)
-
-#define VI_STATE_ASSERTED (1)
-#define VI_STATE_UNASSERTED (0)
-#define VI_STATE_UNKNOWN (-1)
-
-#define VI_BIG_ENDIAN (0)
-#define VI_LITTLE_ENDIAN (1)
-
-#define VI_DATA_PRIV (0)
-#define VI_DATA_NPRIV (1)
-#define VI_PROG_PRIV (2)
-#define VI_PROG_NPRIV (3)
-#define VI_BLCK_PRIV (4)
-#define VI_BLCK_NPRIV (5)
-#define VI_D64_PRIV (6)
-#define VI_D64_NPRIV (7)
-
-#define VI_WIDTH_8 (1)
-#define VI_WIDTH_16 (2)
-#define VI_WIDTH_32 (4)
-#define VI_WIDTH_64 (8)
-
-#define VI_GPIB_REN_DEASSERT (0)
-#define VI_GPIB_REN_ASSERT (1)
-#define VI_GPIB_REN_DEASSERT_GTL (2)
-#define VI_GPIB_REN_ASSERT_ADDRESS (3)
-#define VI_GPIB_REN_ASSERT_LLO (4)
-#define VI_GPIB_REN_ASSERT_ADDRESS_LLO (5)
-#define VI_GPIB_REN_ADDRESS_GTL (6)
-
-#define VI_GPIB_ATN_DEASSERT (0)
-#define VI_GPIB_ATN_ASSERT (1)
-#define VI_GPIB_ATN_DEASSERT_HANDSHAKE (2)
-#define VI_GPIB_ATN_ASSERT_IMMEDIATE (3)
-
-#define VI_GPIB_HS488_DISABLED (0)
-#define VI_GPIB_HS488_NIMPL (-1)
-
-#define VI_GPIB_UNADDRESSED (0)
-#define VI_GPIB_TALKER (1)
-#define VI_GPIB_LISTENER (2)
-
-#define VI_VXI_CMD16 (0x0200)
-#define VI_VXI_CMD16_RESP16 (0x0202)
-#define VI_VXI_RESP16 (0x0002)
-#define VI_VXI_CMD32 (0x0400)
-#define VI_VXI_CMD32_RESP16 (0x0402)
-#define VI_VXI_CMD32_RESP32 (0x0404)
-#define VI_VXI_RESP32 (0x0004)
-
-#define VI_ASSERT_SIGNAL (-1)
-#define VI_ASSERT_USE_ASSIGNED (0)
-#define VI_ASSERT_IRQ1 (1)
-#define VI_ASSERT_IRQ2 (2)
-#define VI_ASSERT_IRQ3 (3)
-#define VI_ASSERT_IRQ4 (4)
-#define VI_ASSERT_IRQ5 (5)
-#define VI_ASSERT_IRQ6 (6)
-#define VI_ASSERT_IRQ7 (7)
-
-#define VI_UTIL_ASSERT_SYSRESET (1)
-#define VI_UTIL_ASSERT_SYSFAIL (2)
-#define VI_UTIL_DEASSERT_SYSFAIL (3)
-
-#define VI_VXI_CLASS_MEMORY (0)
-#define VI_VXI_CLASS_EXTENDED (1)
-#define VI_VXI_CLASS_MESSAGE (2)
-#define VI_VXI_CLASS_REGISTER (3)
-#define VI_VXI_CLASS_OTHER (4)
-
-#define VI_PXI_ADDR_NONE (0)
-#define VI_PXI_ADDR_MEM (1)
-#define VI_PXI_ADDR_IO (2)
-#define VI_PXI_ADDR_CFG (3)
-
-#define VI_TRIG_UNKNOWN (-1)
-
-#define VI_PXI_LBUS_UNKNOWN (-1)
-#define VI_PXI_LBUS_NONE (0)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_0 (1000)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_1 (1001)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_2 (1002)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_3 (1003)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_4 (1004)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_5 (1005)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_6 (1006)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_7 (1007)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_8 (1008)
-#define VI_PXI_LBUS_STAR_TRIG_BUS_9 (1009)
-#define VI_PXI_STAR_TRIG_CONTROLLER (1413)
-
-/*- Backward Compatibility Macros -------------------------------------------*/
-
-#define viGetDefaultRM(vi) viOpenDefaultRM(vi)
-#define VI_ERROR_INV_SESSION (VI_ERROR_INV_OBJECT)
-#define VI_INFINITE (VI_TMO_INFINITE)
-#define VI_NORMAL (VI_PROT_NORMAL)
-#define VI_FDC (VI_PROT_FDC)
-#define VI_HS488 (VI_PROT_HS488)
-#define VI_ASRL488 (VI_PROT_4882_STRS)
-#define VI_ASRL_IN_BUF (VI_IO_IN_BUF)
-#define VI_ASRL_OUT_BUF (VI_IO_OUT_BUF)
-#define VI_ASRL_IN_BUF_DISCARD (VI_IO_IN_BUF_DISCARD)
-#define VI_ASRL_OUT_BUF_DISCARD (VI_IO_OUT_BUF_DISCARD)
-
-/*- National Instruments ----------------------------------------------------*/
-
-#define VI_INTF_RIO (8)
-#define VI_INTF_FIREWIRE (9)
-
-#define VI_ATTR_SYNC_MXI_ALLOW_EN (0x3FFF0161UL) /* ViBoolean, read/write */
-
-/* This is for VXI SERVANT resources */
-
-#define VI_EVENT_VXI_DEV_CMD (0xBFFF200FUL)
-#define VI_ATTR_VXI_DEV_CMD_TYPE (0x3FFF4037UL) /* ViInt16, read-only */
-#define VI_ATTR_VXI_DEV_CMD_VALUE (0x3FFF4038UL) /* ViUInt32, read-only */
-
-#define VI_VXI_DEV_CMD_TYPE_16 (16)
-#define VI_VXI_DEV_CMD_TYPE_32 (32)
-
-ViStatus _VI_FUNC viVxiServantResponse(ViSession vi, ViInt16 mode, ViUInt32 resp);
-/* mode values include VI_VXI_RESP16, VI_VXI_RESP32, and the next 2 values */
-#define VI_VXI_RESP_NONE (0)
-#define VI_VXI_RESP_PROT_ERROR (-1)
-
-/* This allows extended Serial support on Win32 and on NI ENET Serial products */
-
-#define VI_ATTR_ASRL_DISCARD_NULL (0x3FFF00B0UL)
-#define VI_ATTR_ASRL_CONNECTED (0x3FFF01BBUL)
-#define VI_ATTR_ASRL_BREAK_STATE (0x3FFF01BCUL)
-#define VI_ATTR_ASRL_BREAK_LEN (0x3FFF01BDUL)
-#define VI_ATTR_ASRL_ALLOW_TRANSMIT (0x3FFF01BEUL)
-#define VI_ATTR_ASRL_WIRE_MODE (0x3FFF01BFUL)
-
-#define VI_ASRL_WIRE_485_4 (0)
-#define VI_ASRL_WIRE_485_2_DTR_ECHO (1)
-#define VI_ASRL_WIRE_485_2_DTR_CTRL (2)
-#define VI_ASRL_WIRE_485_2_AUTO (3)
-#define VI_ASRL_WIRE_232_DTE (128)
-#define VI_ASRL_WIRE_232_DCE (129)
-#define VI_ASRL_WIRE_232_AUTO (130)
-
-#define VI_EVENT_ASRL_BREAK (0x3FFF2023UL)
-#define VI_EVENT_ASRL_CTS (0x3FFF2029UL)
-#define VI_EVENT_ASRL_DSR (0x3FFF202AUL)
-#define VI_EVENT_ASRL_DCD (0x3FFF202CUL)
-#define VI_EVENT_ASRL_RI (0x3FFF202EUL)
-#define VI_EVENT_ASRL_CHAR (0x3FFF2035UL)
-#define VI_EVENT_ASRL_TERMCHAR (0x3FFF2024UL)
-
-/* This is for fast viPeek/viPoke macros */
-
-#if defined(NIVISA_PEEKPOKE)
-
-#if defined(NIVISA_PEEKPOKE_SUPP)
-#undef NIVISA_PEEKPOKE_SUPP
-#endif
-
-#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_)
-/* This macro is supported for all Win32 compilers, including CVI. */
-#define NIVISA_PEEKPOKE_SUPP
-#elif (defined(_WINDOWS) || defined(_Windows)) && !defined(_CVI_) && !defined(_NI_mswin16_)
-/* This macro is supported for Borland and Microsoft compilers on Win16, but not CVI. */
-#define NIVISA_PEEKPOKE_SUPP
-#elif defined(_CVI_) && defined(_NI_sparc_)
-/* This macro is supported for Solaris 1 and 2, from CVI only. */
-#define NIVISA_PEEKPOKE_SUPP
-#else
-/* This macro is not supported on other platforms. */
-#endif
-
-#if defined(NIVISA_PEEKPOKE_SUPP)
-
-extern ViBoolean NI_viImplVISA1;
-ViStatus _VI_FUNC NI_viOpenDefaultRM (ViPSession vi);
-#define viOpenDefaultRM(vi) NI_viOpenDefaultRM(vi)
-
-#define viPeek8(vi,addr,val) \
- { \
- if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \
- { \
- do (*((ViPUInt8)(val)) = *((volatile ViUInt8 _VI_PTR)(addr))); \
- while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \
- } \
- else \
- { \
- (viPeek8)((vi),(addr),(val)); \
- } \
- }
-
-#define viPoke8(vi,addr,val) \
- { \
- if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \
- { \
- do (*((volatile ViUInt8 _VI_PTR)(addr)) = ((ViUInt8)(val))); \
- while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \
- } \
- else \
- { \
- (viPoke8)((vi),(addr),(val)); \
- } \
- }
-
-#define viPeek16(vi,addr,val) \
- { \
- if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \
- { \
- do (*((ViPUInt16)(val)) = *((volatile ViUInt16 _VI_PTR)(addr))); \
- while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \
- } \
- else \
- { \
- (viPeek16)((vi),(addr),(val)); \
- } \
- }
-
-#define viPoke16(vi,addr,val) \
- { \
- if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \
- { \
- do (*((volatile ViUInt16 _VI_PTR)(addr)) = ((ViUInt16)(val))); \
- while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \
- } \
- else \
- { \
- (viPoke16)((vi),(addr),(val)); \
- } \
- }
-
-#define viPeek32(vi,addr,val) \
- { \
- if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \
- { \
- do (*((ViPUInt32)(val)) = *((volatile ViUInt32 _VI_PTR)(addr))); \
- while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \
- } \
- else \
- { \
- (viPeek32)((vi),(addr),(val)); \
- } \
- }
-
-#define viPoke32(vi,addr,val) \
- { \
- if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \
- { \
- do (*((volatile ViUInt32 _VI_PTR)(addr)) = ((ViUInt32)(val))); \
- while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \
- } \
- else \
- { \
- (viPoke32)((vi),(addr),(val)); \
- } \
- }
-
-#endif
-
-#endif
-
-#if defined(NIVISA_PXI) || defined(PXISAVISA_PXI)
-
-#if 0
-/* The following 2 attributes were incorrectly implemented in earlier
- versions of NI-VISA. You should now query VI_ATTR_MANF_ID or
- VI_ATTR_MODEL_CODE. Those attributes contain sub-vendor information
- when it exists. To get both the actual primary and subvendor codes
- from the device, you should call viIn16 using VI_PXI_CFG_SPACE. */
-#define VI_ATTR_PXI_SUB_MANF_ID (0x3FFF0203UL)
-#define VI_ATTR_PXI_SUB_MODEL_CODE (0x3FFF0204UL)
-#endif
-
-#define VI_ATTR_PXI_SRC_TRIG_BUS (0x3FFF020DUL)
-#define VI_ATTR_PXI_DEST_TRIG_BUS (0x3FFF020EUL)
-
-#define VI_ATTR_PXI_RECV_INTR_SEQ (0x3FFF4240UL)
-#define VI_ATTR_PXI_RECV_INTR_DATA (0x3FFF4241UL)
-
-#endif
-
-#if defined(NIVISA_USB)
-
-#define VI_ATTR_USB_BULK_OUT_PIPE (0x3FFF01A2UL)
-#define VI_ATTR_USB_BULK_IN_PIPE (0x3FFF01A3UL)
-#define VI_ATTR_USB_INTR_IN_PIPE (0x3FFF01A4UL)
-#define VI_ATTR_USB_CLASS (0x3FFF01A5UL)
-#define VI_ATTR_USB_SUBCLASS (0x3FFF01A6UL)
-#define VI_ATTR_USB_ALT_SETTING (0x3FFF01A8UL)
-#define VI_ATTR_USB_END_IN (0x3FFF01A9UL)
-#define VI_ATTR_USB_NUM_INTFCS (0x3FFF01AAUL)
-#define VI_ATTR_USB_NUM_PIPES (0x3FFF01ABUL)
-#define VI_ATTR_USB_BULK_OUT_STATUS (0x3FFF01ACUL)
-#define VI_ATTR_USB_BULK_IN_STATUS (0x3FFF01ADUL)
-#define VI_ATTR_USB_INTR_IN_STATUS (0x3FFF01AEUL)
-#define VI_ATTR_USB_CTRL_PIPE (0x3FFF01B0UL)
-
-#define VI_USB_PIPE_STATE_UNKNOWN (-1)
-#define VI_USB_PIPE_READY (0)
-#define VI_USB_PIPE_STALLED (1)
-
-#define VI_USB_END_NONE (0)
-#define VI_USB_END_SHORT (4)
-#define VI_USB_END_SHORT_OR_COUNT (5)
-
-#endif
-
-#define VI_ATTR_FIREWIRE_DEST_UPPER_OFFSET (0x3FFF01F0UL)
-#define VI_ATTR_FIREWIRE_SRC_UPPER_OFFSET (0x3FFF01F1UL)
-#define VI_ATTR_FIREWIRE_WIN_UPPER_OFFSET (0x3FFF01F2UL)
-#define VI_ATTR_FIREWIRE_VENDOR_ID (0x3FFF01F3UL)
-#define VI_ATTR_FIREWIRE_LOWER_CHIP_ID (0x3FFF01F4UL)
-#define VI_ATTR_FIREWIRE_UPPER_CHIP_ID (0x3FFF01F5UL)
-
-#define VI_FIREWIRE_DFLT_SPACE (5)
-
-#if defined(__cplusplus) || defined(__cplusplus__)
- }
-#endif
-
-#endif
-
-/*- The End -----------------------------------------------------------------*/
diff --git a/hal/src/main/native/athena/visa/visatype.h b/hal/src/main/native/athena/visa/visatype.h
deleted file mode 100644
index ef089dd..0000000
--- a/hal/src/main/native/athena/visa/visatype.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/*---------------------------------------------------------------------------*/
-/* Distributed by IVI Foundation Inc. */
-/* */
-/* Do not modify the contents of this file. */
-/*---------------------------------------------------------------------------*/
-/* */
-/* Title : VISATYPE.H */
-/* Date : 04-14-2006 */
-/* Purpose : Fundamental VISA data types and macro definitions */
-/* */
-/*---------------------------------------------------------------------------*/
-
-#ifndef __VISATYPE_HEADER__
-#define __VISATYPE_HEADER__
-
-#if defined(_WIN64)
-#define _VI_FAR
-#define _VI_FUNC __fastcall
-#define _VI_FUNCC __fastcall
-#define _VI_FUNCH __fastcall
-#define _VI_SIGNED signed
-#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_)
-#define _VI_FAR
-#define _VI_FUNC __stdcall
-#define _VI_FUNCC __cdecl
-#define _VI_FUNCH __stdcall
-#define _VI_SIGNED signed
-#elif defined(_CVI_) && defined(_NI_i386_)
-#define _VI_FAR
-#define _VI_FUNC _pascal
-#define _VI_FUNCC
-#define _VI_FUNCH _pascal
-#define _VI_SIGNED signed
-#elif (defined(_WINDOWS) || defined(_Windows)) && !defined(_NI_mswin16_)
-#define _VI_FAR _far
-#define _VI_FUNC _far _pascal _export
-#define _VI_FUNCC _far _cdecl _export
-#define _VI_FUNCH _far _pascal
-#define _VI_SIGNED signed
-#elif (defined(hpux) || defined(__hpux)) && (defined(__cplusplus) || defined(__cplusplus__))
-#define _VI_FAR
-#define _VI_FUNC
-#define _VI_FUNCC
-#define _VI_FUNCH
-#define _VI_SIGNED
-#else
-#define _VI_FAR
-#define _VI_FUNC
-#define _VI_FUNCC
-#define _VI_FUNCH
-#define _VI_SIGNED signed
-#endif
-
-#define _VI_ERROR (-2147483647L-1) /* 0x80000000 */
-#define _VI_PTR _VI_FAR *
-
-/*- VISA Types --------------------------------------------------------------*/
-
-#ifndef _VI_INT64_UINT64_DEFINED
-#if defined(_WIN64) || ((defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_))
-#if (defined(_MSC_VER) && (_MSC_VER >= 1200)) || (defined(_CVI_) && (_CVI_ >= 700)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
-typedef unsigned __int64 ViUInt64;
-typedef _VI_SIGNED __int64 ViInt64;
-#define _VI_INT64_UINT64_DEFINED
-#if defined(_WIN64)
-#define _VISA_ENV_IS_64_BIT
-#else
-/* This is a 32-bit OS, not a 64-bit OS */
-#endif
-#endif
-#elif defined(__GNUC__) && (__GNUC__ >= 3)
-#include <limits.h>
-#include <sys/types.h>
-typedef u_int64_t ViUInt64;
-typedef int64_t ViInt64;
-#define _VI_INT64_UINT64_DEFINED
-#if defined(LONG_MAX) && (LONG_MAX > 0x7FFFFFFFL)
-#define _VISA_ENV_IS_64_BIT
-#else
-/* This is a 32-bit OS, not a 64-bit OS */
-#endif
-#else
-/* This platform does not support 64-bit types */
-#endif
-#endif
-
-#if defined(_VI_INT64_UINT64_DEFINED)
-typedef ViUInt64 _VI_PTR ViPUInt64;
-typedef ViUInt64 _VI_PTR ViAUInt64;
-typedef ViInt64 _VI_PTR ViPInt64;
-typedef ViInt64 _VI_PTR ViAInt64;
-#endif
-
-#if defined(LONG_MAX) && (LONG_MAX > 0x7FFFFFFFL)
-typedef unsigned int ViUInt32;
-typedef _VI_SIGNED int ViInt32;
-#else
-typedef unsigned long ViUInt32;
-typedef _VI_SIGNED long ViInt32;
-#endif
-
-typedef ViUInt32 _VI_PTR ViPUInt32;
-typedef ViUInt32 _VI_PTR ViAUInt32;
-typedef ViInt32 _VI_PTR ViPInt32;
-typedef ViInt32 _VI_PTR ViAInt32;
-
-typedef unsigned short ViUInt16;
-typedef ViUInt16 _VI_PTR ViPUInt16;
-typedef ViUInt16 _VI_PTR ViAUInt16;
-
-typedef _VI_SIGNED short ViInt16;
-typedef ViInt16 _VI_PTR ViPInt16;
-typedef ViInt16 _VI_PTR ViAInt16;
-
-typedef unsigned char ViUInt8;
-typedef ViUInt8 _VI_PTR ViPUInt8;
-typedef ViUInt8 _VI_PTR ViAUInt8;
-
-typedef _VI_SIGNED char ViInt8;
-typedef ViInt8 _VI_PTR ViPInt8;
-typedef ViInt8 _VI_PTR ViAInt8;
-
-typedef char ViChar;
-typedef ViChar _VI_PTR ViPChar;
-typedef ViChar _VI_PTR ViAChar;
-
-typedef unsigned char ViByte;
-typedef ViByte _VI_PTR ViPByte;
-typedef ViByte _VI_PTR ViAByte;
-
-typedef void _VI_PTR ViAddr;
-typedef ViAddr _VI_PTR ViPAddr;
-typedef ViAddr _VI_PTR ViAAddr;
-
-typedef float ViReal32;
-typedef ViReal32 _VI_PTR ViPReal32;
-typedef ViReal32 _VI_PTR ViAReal32;
-
-typedef double ViReal64;
-typedef ViReal64 _VI_PTR ViPReal64;
-typedef ViReal64 _VI_PTR ViAReal64;
-
-typedef ViPByte ViBuf;
-typedef ViPByte ViPBuf;
-typedef ViPByte _VI_PTR ViABuf;
-
-typedef ViPChar ViString;
-typedef ViPChar ViPString;
-typedef ViPChar _VI_PTR ViAString;
-
-typedef ViString ViRsrc;
-typedef ViString ViPRsrc;
-typedef ViString _VI_PTR ViARsrc;
-
-typedef ViUInt16 ViBoolean;
-typedef ViBoolean _VI_PTR ViPBoolean;
-typedef ViBoolean _VI_PTR ViABoolean;
-
-typedef ViInt32 ViStatus;
-typedef ViStatus _VI_PTR ViPStatus;
-typedef ViStatus _VI_PTR ViAStatus;
-
-typedef ViUInt32 ViVersion;
-typedef ViVersion _VI_PTR ViPVersion;
-typedef ViVersion _VI_PTR ViAVersion;
-
-typedef ViUInt32 ViObject;
-typedef ViObject _VI_PTR ViPObject;
-typedef ViObject _VI_PTR ViAObject;
-
-typedef ViObject ViSession;
-typedef ViSession _VI_PTR ViPSession;
-typedef ViSession _VI_PTR ViASession;
-
-typedef ViUInt32 ViAttr;
-
-#ifndef _VI_CONST_STRING_DEFINED
-typedef const ViChar * ViConstString;
-#define _VI_CONST_STRING_DEFINED
-#endif
-
-/*- Completion and Error Codes ----------------------------------------------*/
-
-#define VI_SUCCESS (0L)
-
-/*- Other VISA Definitions --------------------------------------------------*/
-
-#define VI_NULL (0)
-
-#define VI_TRUE (1)
-#define VI_FALSE (0)
-
-/*- Backward Compatibility Macros -------------------------------------------*/
-
-#define VISAFN _VI_FUNC
-#define ViPtr _VI_PTR
-
-#endif
-
-/*- The End -----------------------------------------------------------------*/
-