From f7146d423087adcf9d8372a07c14db52eaaacf17 Mon Sep 17 00:00:00 2001 From: charris Date: Mon, 6 Jan 2014 10:12:21 -0500 Subject: [PATCH] JNI for java Normal vs recursive mutex HAL delineation --- .../edu.wpi.first.wpilib.plugins.java/pom.xml | 48 +- .../resources/java-zip/ant/build.properties | 7 +- eclipse-plugins/pom.xml | 2 +- hal/Athena/pom.xml | 1 + hal/Athena/src/main/native/Analog.cpp | 2 +- hal/Athena/src/main/native/Digital.cpp | 20 +- hal/Athena/src/main/native/HAL.cpp | 76 + .../native/NetworkCommunication/FRCComm.h | 2 + hal/Athena/src/main/native/Semaphore.cpp | 76 +- .../src/main/native/cpp/Synchronized.cpp | 6 +- hal/Azalea/pom.xml | 1 + hal/include/pom.xml | 1 + hal/include/src/main/include/HAL/HAL.h | 238 +- hal/include/src/main/include/HAL/Semaphore.h | 11 +- .../src/main/include/HAL/cpp/Synchronized.h | 4 +- hal/pom.xml | 7 - maven-utilities/athena/cpp-executable/pom.xml | 2 +- maven-utilities/athena/library-jar/pom.xml | 2 +- maven-utilities/athena/pom.xml | 2 +- maven-utilities/athena/shared-library/pom.xml | 2 +- maven-utilities/athena/static-library/pom.xml | 2 +- maven-utilities/include/pom.xml | 2 +- maven-utilities/pom.xml | 2 +- networktables/cpp/Athena/pom.xml | 1 + networktables/cpp/parent/pom.xml | 2 +- networktables/cpp/pom.xml | 2 +- networktables/java/Athena/pom.xml | 2 + networktables/java/Azalea/pom.xml | 2 + networktables/java/dist-old/pom.xml | 2 +- networktables/java/pom.xml | 2 +- networktables/pom.xml | 2 +- ni-libraries/parent/pom.xml | 2 +- ni-libraries/pom.xml | 2 +- wpilibc/src/main/include/Dashboard.h | 4 +- wpilibc/src/main/include/DriverStation.h | 4 +- .../main/include/DriverStationEnhancedIO.h | 6 +- wpilibc/src/main/include/RobotBase.h | 2 +- wpilibc/src/main/native/ADXL345_SPI.cpp | 4 +- wpilibc/src/main/native/Accelerometer.cpp | 4 +- wpilibc/src/main/native/AnalogChannel.cpp | 4 +- wpilibc/src/main/native/AnalogTrigger.cpp | 4 +- .../src/main/native/AnalogTriggerOutput.cpp | 4 +- wpilibc/src/main/native/CANJaguar.cpp | 14 +- .../src/main/native/Commands/Scheduler.cpp | 16 +- wpilibc/src/main/native/Compressor.cpp | 4 +- wpilibc/src/main/native/Counter.cpp | 4 +- wpilibc/src/main/native/Dashboard.cpp | 6 +- wpilibc/src/main/native/DigitalInput.cpp | 4 +- wpilibc/src/main/native/DigitalOutput.cpp | 4 +- wpilibc/src/main/native/DoubleSolenoid.cpp | 6 +- wpilibc/src/main/native/DriverStation.cpp | 48 +- .../main/native/DriverStationEnhancedIO.cpp | 41 +- wpilibc/src/main/native/DriverStationLCD.cpp | 14 +- wpilibc/src/main/native/Encoder.cpp | 4 +- wpilibc/src/main/native/Error.cpp | 4 +- wpilibc/src/main/native/ErrorBase.cpp | 2 +- wpilibc/src/main/native/Gyro.cpp | 4 +- .../src/main/native/HiTechnicColorSensor.cpp | 4 +- wpilibc/src/main/native/HiTechnicCompass.cpp | 4 +- wpilibc/src/main/native/I2C.cpp | 8 +- wpilibc/src/main/native/IterativeRobot.cpp | 12 +- wpilibc/src/main/native/Jaguar.cpp | 4 +- wpilibc/src/main/native/Joystick.cpp | 4 +- wpilibc/src/main/native/Kinect.cpp | 22 +- wpilibc/src/main/native/KinectStick.cpp | 10 +- wpilibc/src/main/native/Notifier.cpp | 6 +- wpilibc/src/main/native/PIDController.cpp | 8 +- wpilibc/src/main/native/PWM.cpp | 4 +- wpilibc/src/main/native/Preferences.cpp | 18 +- wpilibc/src/main/native/Relay.cpp | 6 +- wpilibc/src/main/native/RobotBase.cpp | 10 +- wpilibc/src/main/native/RobotDrive.cpp | 12 +- wpilibc/src/main/native/SPI.cpp | 4 +- wpilibc/src/main/native/SerialPort.cpp | 4 +- wpilibc/src/main/native/Servo.cpp | 4 +- wpilibc/src/main/native/SimpleRobot.cpp | 4 +- .../native/SmartDashboard/SmartDashboard.cpp | 2 +- wpilibc/src/main/native/Solenoid.cpp | 4 +- wpilibc/src/main/native/Talon.cpp | 4 +- wpilibc/src/main/native/Task.cpp | 4 +- wpilibc/src/main/native/Timer.cpp | 2 +- wpilibc/src/main/native/Ultrasonic.cpp | 10 +- wpilibc/src/main/native/Utility.cpp | 6 +- wpilibc/src/main/native/Victor.cpp | 4 +- .../edu/wpi/first/wpilibj/ADXL345_I2C.java | 4 +- .../edu/wpi/first/wpilibj/Accelerometer.java | 2 +- .../edu/wpi/first/wpilibj/AnalogChannel.java | 188 +- .../edu/wpi/first/wpilibj/AnalogModule.java | 125 +- .../edu/wpi/first/wpilibj/AnalogTrigger.java | 25 +- .../first/wpilibj/AnalogTriggerOutput.java | 7 +- .../java/edu/wpi/first/wpilibj/CANJaguar.java | 230 +- .../edu/wpi/first/wpilibj/Compressor.java | 2 +- .../java/edu/wpi/first/wpilibj/Counter.java | 210 +- .../java/edu/wpi/first/wpilibj/Dashboard.java | 2 +- .../edu/wpi/first/wpilibj/DigitalInput.java | 50 +- .../edu/wpi/first/wpilibj/DigitalModule.java | 332 ++- .../edu/wpi/first/wpilibj/DigitalOutput.java | 100 +- .../edu/wpi/first/wpilibj/DigitalSource.java | 37 +- .../edu/wpi/first/wpilibj/DoubleSolenoid.java | 50 +- .../edu/wpi/first/wpilibj/DriverStation.java | 54 +- .../wpi/first/wpilibj/DriverStationLCD.java | 10 +- .../java/edu/wpi/first/wpilibj/Encoder.java | 123 +- .../java/edu/wpi/first/wpilibj/GearTooth.java | 2 +- .../main/java/edu/wpi/first/wpilibj/Gyro.java | 2 +- .../first/wpilibj/HiTechnicColorSensor.java | 2 +- .../wpi/first/wpilibj/HiTechnicCompass.java | 2 +- .../main/java/edu/wpi/first/wpilibj/I2C.java | 7 +- .../wpilibj/InterruptableSensorBase.java | 23 +- .../edu/wpi/first/wpilibj/IterativeRobot.java | 16 +- .../java/edu/wpi/first/wpilibj/Jaguar.java | 2 +- .../java/edu/wpi/first/wpilibj/Joystick.java | 2 +- .../java/edu/wpi/first/wpilibj/Module.java | 10 +- .../edu/wpi/first/wpilibj/PIDController.java | 4 +- .../main/java/edu/wpi/first/wpilibj/PWM.java | 6 +- .../edu/wpi/first/wpilibj/Preferences.java | 2 +- .../java/edu/wpi/first/wpilibj/Relay.java | 5 +- .../java/edu/wpi/first/wpilibj/Resource.java | 1 + .../java/edu/wpi/first/wpilibj/RobotBase.java | 129 +- .../edu/wpi/first/wpilibj/RobotDrive.java | 4 +- .../edu/wpi/first/wpilibj/SensorBase.java | 23 +- .../java/edu/wpi/first/wpilibj/Servo.java | 2 +- .../edu/wpi/first/wpilibj/SimpleRobot.java | 4 +- .../java/edu/wpi/first/wpilibj/Solenoid.java | 59 +- .../edu/wpi/first/wpilibj/SolenoidBase.java | 54 +- .../java/edu/wpi/first/wpilibj/Talon.java | 2 +- .../edu/wpi/first/wpilibj/Ultrasonic.java | 2 +- .../java/edu/wpi/first/wpilibj/Utility.java | 29 +- .../java/edu/wpi/first/wpilibj/Victor.java | 2 +- .../wpi/first/wpilibj/command/Scheduler.java | 4 +- .../communication/FRCCommonControlData.java | 330 ++- .../wpilibj/communication/UsageReporting.java | 2 +- .../edu/wpi/first/wpilibj/hal/HALLibrary.java | 2452 +++-------------- .../edu/wpi/first/wpilibj/hal/HALUtil.java | 64 +- .../edu/wpi/first/wpilibj/hal/JNIWrapper.java | 6 +- 134 files changed, 2377 insertions(+), 3358 deletions(-) diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml index 52d378c8fe..3f480ad7ed 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml @@ -18,16 +18,16 @@ - + - + WPILib Repository @@ -92,28 +92,28 @@ ${java-zip}/lib - edu.wpi.first.wpilib - WPILibJ + edu.wpi.first.wpilibj + wpilibJavaFinal 0.1.0-SNAPSHOT jar WPILib.jar ${java-zip}/lib - + + edu.wpi.first.wpilib.networktables.java @@ -124,8 +124,8 @@ NetworkTables-sources.jar - edu.wpi.first.wpilib - WPILibJ + edu.wpi.first.wpilibj + wpilibJava 0.1.0-SNAPSHOT sources ${java-zip}/lib @@ -134,8 +134,8 @@ - edu.wpi.first.wpilib - WPILibJ + edu.wpi.first.wpilibj + wpilibJava 0.1.0-SNAPSHOT javadoc ${java-zip}/javadoc-jar @@ -230,23 +230,23 @@ jar - edu.wpi.first.wpilib - WPILibJ + edu.wpi.first.wpilibj + wpilibJavaFinal 0.1.0-SNAPSHOT jar - + + @@ -256,16 +256,16 @@ sources - edu.wpi.first.wpilib - WPILibJ + edu.wpi.first.wpilibj + wpilibJava 0.1.0-SNAPSHOT sources - edu.wpi.first.wpilib - WPILibJ + edu.wpi.first.wpilibj + wpilibJava 0.1.0-SNAPSHOT javadoc diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties index 9d39d2a1fd..e1ad10d1c7 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties @@ -12,9 +12,10 @@ wpilib.jar=${wpilib.lib}/WPILib.jar wpilib.sources=${wpilib.lib}/WPILib-sources.jar networktables.jar=${wpilib.lib}/NetworkTables.jar networktables.sources=${wpilib.lib}/NetworkTables-sources.jar -jna.jar=${wpilib.lib}/jna-4.0.0.jar -jnaerator.jar=${wpilib.lib}/jnaerator-runtime.jar -classpath=${wpilib.jar}:${networktables.jar}:${jna.jar}:${jnaerator.jar} +#jna.jar=${wpilib.lib}/jna-4.0.0.jar +#jnaerator.jar=${wpilib.lib}/jnaerator-runtime.jar +#classpath=${wpilib.jar}:${networktables.jar}:${jna.jar}:${jnaerator.jar} +classpath=${wpilib.jar}:${networktables.jar} # Ant support wpilib.ant.dir=${wpilib}/ant diff --git a/eclipse-plugins/pom.xml b/eclipse-plugins/pom.xml index f8cd527202..03b10ff6b3 100644 --- a/eclipse-plugins/pom.xml +++ b/eclipse-plugins/pom.xml @@ -24,7 +24,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + 0.18.1 diff --git a/hal/Athena/pom.xml b/hal/Athena/pom.xml index 9d63e1e81a..51dc45acc5 100644 --- a/hal/Athena/pom.xml +++ b/hal/Athena/pom.xml @@ -10,6 +10,7 @@ edu.wpi.first.wpilib.templates.athena static-library 0.1.0-SNAPSHOT + ../../maven-utilities/athena/static-library diff --git a/hal/Athena/src/main/native/Analog.cpp b/hal/Athena/src/main/native/Analog.cpp index a406ea4a19..b23c2b1a3d 100644 --- a/hal/Athena/src/main/native/Analog.cpp +++ b/hal/Athena/src/main/native/Analog.cpp @@ -44,7 +44,7 @@ bool analogSystemInitialized = false; */ void initializeAnalog(int32_t *status) { if (analogSystemInitialized) return; - analogRegisterWindowSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + analogRegisterWindowSemaphore = initializeMutexRecursive(); analogSystem = tAI::create(status); setAnalogNumChannelsToActivate(kAnalogPins); setAnalogSampleRate(kDefaultSampleRate, status); diff --git a/hal/Athena/src/main/native/Digital.cpp b/hal/Athena/src/main/native/Digital.cpp index 7e44729300..da7c2e8b7a 100644 --- a/hal/Athena/src/main/native/Digital.cpp +++ b/hal/Athena/src/main/native/Digital.cpp @@ -67,15 +67,15 @@ void initializeDigital(int32_t *status) { if (digitalSystemsInitialized) return; // Create a semaphore to protect changes to the digital output values - digitalDIOSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + digitalDIOSemaphore = initializeMutexRecursive(); // Create a semaphore to protect changes to the relay values - digitalRelaySemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + digitalRelaySemaphore = initializeMutexRecursive(); // Create a semaphore to protect changes to the DO PWM config - digitalPwmSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + digitalPwmSemaphore = initializeMutexRecursive(); - digitalI2CSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + digitalI2CSemaphore = initializeMutexRecursive(); Resource::CreateResourceObject(&DIOChannels, tDIO::kNumSystems * kDigitalPins); Resource::CreateResourceObject(&DO_PWMGenerators, tDIO::kNumPWMDutyCycleElements); @@ -420,9 +420,9 @@ bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status) { uint32_t bitToSet = 1 << (remapDigitalChannel(port->port.pin - 1, status)); tDIO::tOutputEnable outputEnable = digitalSystem->readOutputEnable(status); if (input) { - outputEnable.value = outputEnable.value & (~bitToSet); // clear the bit for read + outputEnable.Headers = outputEnable.Headers & (~bitToSet); // clear the bit for read } else { - outputEnable.value = outputEnable.value | bitToSet; // set the bit for write + outputEnable.Headers = outputEnable.Headers | bitToSet; // set the bit for write } digitalSystem->writeOutputEnable(outputEnable, status); } @@ -497,7 +497,7 @@ bool getDIODirection(void* digital_port_pointer, int32_t *status) { //AND it against the currentOutputEnable //if it == 0, then return false //else return true - return ((currentOutputEnable.value >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; + return ((currentOutputEnable.Headers >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; } /** @@ -510,7 +510,7 @@ bool getDIODirection(void* digital_port_pointer, int32_t *status) { void pulse(void* digital_port_pointer, double pulseLength, int32_t *status) { DigitalPort* port = (DigitalPort*) digital_port_pointer; tDIO::tPulse pulse; - pulse.value = 1 << remapDigitalChannel(port->port.pin - 1, status); + pulse.Headers = 1 << remapDigitalChannel(port->port.pin - 1, status); digitalSystem->writePulseLength((uint8_t)(1.0e9 * pulseLength / (pwmSystem->readLoopTiming(status) * 25)), status); digitalSystem->writePulse(pulse, status); } @@ -524,7 +524,7 @@ bool isPulsing(void* digital_port_pointer, int32_t *status) { DigitalPort* port = (DigitalPort*) digital_port_pointer; uint16_t mask = 1 << remapDigitalChannel(port->port.pin - 1, status); tDIO::tPulse pulseRegister = digitalSystem->readPulse(status); - return (pulseRegister.value & mask) != 0; + return (pulseRegister.Headers & mask) != 0; } /** @@ -543,7 +543,7 @@ bool isAnyPulsing(int32_t *status) { */ bool isAnyPulsingWithModule(uint8_t module, int32_t *status) { tDIO::tPulse pulseRegister = digitalSystem->readPulse(status); - return pulseRegister.value != 0; + return pulseRegister.Headers != 0; } diff --git a/hal/Athena/src/main/native/HAL.cpp b/hal/Athena/src/main/native/HAL.cpp index 09c38da936..0e9eb600b3 100644 --- a/hal/Athena/src/main/native/HAL.cpp +++ b/hal/Athena/src/main/native/HAL.cpp @@ -4,6 +4,8 @@ #include "Port.h" #include "HAL/Errors.h" #include "ChipObject.h" +#include "NetworkCommunication/FRCComm.h" +#include "NetworkCommunication/UsageReporting.h" // XXX: What to do with solenoids? const uint32_t solenoid_kNumDO7_0Elements = tSolenoid::kNumDO7_0Elements; const uint32_t dio_kNumSystems = tDIO::kNumSystems; @@ -107,6 +109,80 @@ int32_t getFPGALED(int32_t *status) { return 0; // XXX: Dummy value } +int HALSetErrorData(const char *errors, int errorsLength, int wait_ms) +{ + return setErrorData(errors, errorsLength, wait_ms); +} + +int HALSetUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms) +{ + return setUserDsLcdData(userDsLcdData, userDsLcdDataLength, wait_ms); +} + +int HALOverrideIOConfig(const char *ioConfig, int wait_ms) +{ + return overrideIOConfig(ioConfig, wait_ms); +} + +int HALGetDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms) +{ + return getDynamicControlData( type, dynamicData, maxLength, wait_ms); +} + +int HALGetCommonControlData(HALCommonControlData *data, int wait_ms) +{ + return getCommonControlData( (FRCCommonControlData*)data, wait_ms ); +} + +void HALSetNewDataSem(pthread_mutex_t * param) +{ + setNewDataSem(param); +} + +int HALSetStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber, + const char *userDataHigh, int userDataHighLength, + const char *userDataLow, int userDataLowLength, int wait_ms) +{ + return setStatusData(battery, dsDigitalOut, updateNumber, userDataHigh, userDataHighLength, userDataLow, userDataLowLength, wait_ms); +} + + +void HALNetworkCommunicationReserve() +{ + FRC_NetworkCommunication_Reserve(); +} + +void HALNetworkCommunicationObserveUserProgramStarting(void) +{ + FRC_NetworkCommunication_observeUserProgramStarting(); +} + +void HALNetworkCommunicationObserveUserProgramDisabled(void) +{ + FRC_NetworkCommunication_observeUserProgramDisabled(); +} + +void HALNetworkCommunicationObserveUserProgramAutonomous(void) +{ + FRC_NetworkCommunication_observeUserProgramAutonomous(); +} + +void HALNetworkCommunicationObserveUserProgramTeleop(void) +{ + FRC_NetworkCommunication_observeUserProgramTeleop(); +} + +void HALNetworkCommunicationObserveUserProgramTest(void) +{ + FRC_NetworkCommunication_observeUserProgramTest(); +} + +uint32_t HALReport(uint8_t resource, uint8_t instanceNumber, uint8_t context, const char *feature) +{ + return FRC_NetworkCommunication_nUsageReporting_report( resource, instanceNumber, context, feature); +} + + // TODO: HACKS void NumericArrayResize() {} void RTSetCleanupProc() {} diff --git a/hal/Athena/src/main/native/NetworkCommunication/FRCComm.h b/hal/Athena/src/main/native/NetworkCommunication/FRCComm.h index e971fac1a5..50a534bf2f 100644 --- a/hal/Athena/src/main/native/NetworkCommunication/FRCComm.h +++ b/hal/Athena/src/main/native/NetworkCommunication/FRCComm.h @@ -188,6 +188,8 @@ extern "C" { void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramAutonomous(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTeleop(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTest(void); + void EXPORT_FUNC FRC_NetworkCommunication_Reserve(); + }; #endif diff --git a/hal/Athena/src/main/native/Semaphore.cpp b/hal/Athena/src/main/native/Semaphore.cpp index 2cf2258216..5276d6df80 100644 --- a/hal/Athena/src/main/native/Semaphore.cpp +++ b/hal/Athena/src/main/native/Semaphore.cpp @@ -2,6 +2,14 @@ #include "HAL/Semaphore.h" #include "ChipObject.h" +#include "Log.h" + +// set the logging level +TLogLevel semaphoreLogLevel = logDEBUG; + +#define SEMAPHORE_LOG(level) \ + if (level > semaphoreLogLevel) ; \ + else Log().Get(level) // See: http://www.vxdev.com/docs/vx55man/vxworks/ref/semMLib.html const uint32_t SEMAPHORE_Q_FIFO= 0x01; // TODO: Support @@ -15,7 +23,8 @@ const int32_t SEMAPHORE_WAIT_FOREVER = -1; const uint32_t SEMAPHORE_EMPTY = 0; const uint32_t SEMAPHORE_FULL = 1; -MUTEX_ID initializeMutex(uint32_t flags) { +MUTEX_ID initializeMutexRecursive() +{ pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); @@ -25,38 +34,47 @@ MUTEX_ID initializeMutex(uint32_t flags) { return sem; } -void deleteMutex(MUTEX_ID sem) { - pthread_mutex_destroy(sem); - delete sem; +MUTEX_ID initializeMutexNormal() +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); + MUTEX_ID sem = new pthread_mutex_t(); + pthread_mutex_init(sem, &attr); + pthread_mutexattr_destroy(&attr); + return sem; +} + +void deleteMutex(MUTEX_ID sem) +{ + pthread_mutex_destroy(sem); + delete sem; } /** * Lock the semaphore, blocking until it's available. * @return 0 for success, -1 for error. If -1, the error will be in errno. */ -int8_t takeMutex(MUTEX_ID sem, int32_t timeout) { - if (timeout == SEMAPHORE_NO_WAIT) { - return pthread_mutex_trylock(sem); - } else if (timeout == SEMAPHORE_WAIT_FOREVER) { +int8_t takeMutex(MUTEX_ID sem) +{ return pthread_mutex_lock(sem); - } else { - // struct timespec test; - // return pthread_mutex_timedlock(sem, ); - return -1; // TODO: implement timed wait - } +} + +int8_t tryTakeMutex(MUTEX_ID sem) +{ + return pthread_mutex_trylock(sem); } /** * Unlock the semaphore. * @return 0 for success, -1 for error. If -1, the error will be in errno. */ -int8_t giveMutex(MUTEX_ID sem) { - // return semGive(sem); - // return sem_post(sem); - return pthread_mutex_unlock(sem); +int8_t giveMutex(MUTEX_ID sem) +{ + return pthread_mutex_unlock(sem); } -SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_value) { +SEMAPHORE_ID initializeSemaphore(uint32_t initial_value) { SEMAPHORE_ID sem = new sem_t; sem_init(sem, 0, initial_value); return sem; @@ -71,22 +89,22 @@ void deleteSemaphore(SEMAPHORE_ID sem) { * Lock the semaphore, blocking until it's available. * @return 0 for success, -1 for error. If -1, the error will be in errno. */ -int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout) { - if (timeout == SEMAPHORE_NO_WAIT) { - return sem_trywait(sem); - } else if (timeout == SEMAPHORE_WAIT_FOREVER) { +int8_t takeSemaphore(SEMAPHORE_ID sem) +{ return sem_wait(sem); - } else { - // return sem_timedwait(sem, ); - return -1; // TODO: implement timed wait - } +} + +int8_t tryTakeSemaphore(SEMAPHORE_ID sem) +{ + return sem_trywait(sem); } /** * Unlock the semaphore. * @return 0 for success, -1 for error. If -1, the error will be in errno. */ -int8_t giveSemaphore(SEMAPHORE_ID sem) { +int8_t giveSemaphore(SEMAPHORE_ID sem) +{ return sem_post(sem); } @@ -106,8 +124,8 @@ void deleteMultiWait(MULTIWAIT_ID sem) { } int8_t takeMultiWait(MULTIWAIT_ID sem, int32_t timeout) { - MUTEX_ID m = initializeMutex(NULL); - takeMutex(m, SEMAPHORE_WAIT_FOREVER); + MUTEX_ID m = initializeMutexNormal(); + takeMutex(m); int8_t val = pthread_cond_wait(sem, m); deleteMutex(m); return val; diff --git a/hal/Athena/src/main/native/cpp/Synchronized.cpp b/hal/Athena/src/main/native/cpp/Synchronized.cpp index c20d333a43..e4766130c4 100644 --- a/hal/Athena/src/main/native/cpp/Synchronized.cpp +++ b/hal/Athena/src/main/native/cpp/Synchronized.cpp @@ -19,21 +19,21 @@ Synchronized::Synchronized(MUTEX_ID semaphore) { m_mutex = semaphore; m_semaphore = NULL; - takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_mutex); } Synchronized::Synchronized(SEMAPHORE_ID semaphore) { m_mutex = NULL; m_semaphore = semaphore; - takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER); + takeSemaphore(m_semaphore); } Synchronized::Synchronized(ReentrantSemaphore& semaphore) { m_mutex = semaphore.m_semaphore; m_semaphore = NULL; - takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_mutex); } /** diff --git a/hal/Azalea/pom.xml b/hal/Azalea/pom.xml index 53c7648709..aa36af20a3 100644 --- a/hal/Azalea/pom.xml +++ b/hal/Azalea/pom.xml @@ -10,6 +10,7 @@ edu.wpi.first.wpilib.templates.azalea static-library 0.1.0-SNAPSHOT + ../../maven-utilities/azalea/static-library diff --git a/hal/include/pom.xml b/hal/include/pom.xml index 720e7de84b..4efa2ebdc8 100644 --- a/hal/include/pom.xml +++ b/hal/include/pom.xml @@ -10,6 +10,7 @@ edu.wpi.first.wpilib.templates include 0.1.0-SNAPSHOT + ../../maven-utilities/include diff --git a/hal/include/src/main/include/HAL/HAL.h b/hal/include/src/main/include/HAL/HAL.h index 39c4b345e2..11c0c12d57 100644 --- a/hal/include/src/main/include/HAL/HAL.h +++ b/hal/include/src/main/include/HAL/HAL.h @@ -25,6 +25,223 @@ #ifndef HAL_H #define HAL_H +#define HAL_IO_CONFIG_DATA_SIZE 32 +#define HAL_SYS_STATUS_DATA_SIZE 44 +#define HAL_USER_STATUS_DATA_SIZE (984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE) +#define HAL_USER_DS_LCD_DATA_SIZE 128 + + +#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17 +#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Header 19 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24 +#define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom 25 + +namespace HALUsageReporting +{ + typedef enum + { + kResourceType_Controller, + kResourceType_Module, + kResourceType_Language, + kResourceType_CANPlugin, + kResourceType_Accelerometer, + kResourceType_ADXL345, + kResourceType_AnalogChannel, + kResourceType_AnalogTrigger, + kResourceType_AnalogTriggerOutput, + kResourceType_CANJaguar, + kResourceType_Compressor, + kResourceType_Counter, + kResourceType_Dashboard, + kResourceType_DigitalInput, + kResourceType_DigitalOutput, + kResourceType_DriverStationCIO, + kResourceType_DriverStationEIO, + kResourceType_DriverStationLCD, + kResourceType_Encoder, + kResourceType_GearTooth, + kResourceType_Gyro, + kResourceType_I2C, + kResourceType_Framework, + kResourceType_Jaguar, + kResourceType_Joystick, + kResourceType_Kinect, + kResourceType_KinectStick, + kResourceType_PIDController, + kResourceType_Preferences, + kResourceType_PWM, + kResourceType_Relay, + kResourceType_RobotDrive, + kResourceType_SerialPort, + kResourceType_Servo, + kResourceType_Solenoid, + kResourceType_SPI, + kResourceType_Task, + kResourceType_Ultrasonic, + kResourceType_Victor, + kResourceType_Button, + kResourceType_Command, + kResourceType_AxisCamera, + kResourceType_PCVideoServer, + kResourceType_SmartDashboard, + kResourceType_Talon, + kResourceType_HiTechnicColorSensor, + kResourceType_HiTechnicAccel, + kResourceType_HiTechnicCompass, + kResourceType_SRF08, + } tResourceType; + + typedef enum + { + kLanguage_LabVIEW = 1, + kLanguage_CPlusPlus = 2, + kLanguage_Java = 3, + kLanguage_Python = 4, + + kCANPlugin_BlackJagBridge = 1, + kCANPlugin_2CAN = 2, + + kFramework_Iterative = 1, + kFramework_Simple = 2, + + kRobotDrive_ArcadeStandard = 1, + kRobotDrive_ArcadeButtonSpin = 2, + kRobotDrive_ArcadeRatioCurve = 3, + kRobotDrive_Tank = 4, + kRobotDrive_MecanumPolar = 5, + kRobotDrive_MecanumCartesian = 6, + + kDriverStationCIO_Analog = 1, + kDriverStationCIO_DigitalIn = 2, + kDriverStationCIO_DigitalOut = 3, + + kDriverStationEIO_Acceleration = 1, + kDriverStationEIO_AnalogIn = 2, + kDriverStationEIO_AnalogOut = 3, + kDriverStationEIO_Button = 4, + kDriverStationEIO_LED = 5, + kDriverStationEIO_DigitalIn = 6, + kDriverStationEIO_DigitalOut = 7, + kDriverStationEIO_FixedDigitalOut = 8, + kDriverStationEIO_PWM = 9, + kDriverStationEIO_Encoder = 10, + kDriverStationEIO_TouchSlider = 11, + + kADXL345_SPI = 1, + kADXL345_I2C = 2, + + kCommand_Scheduler = 1, + + kSmartDashboard_Instance = 1, + } tInstances; +} + +struct HALCommonControlData{ + uint16_t packetIndex; + union { + uint8_t control; +#ifndef __vxworks + struct { + uint8_t checkVersions :1; + uint8_t test :1; + uint8_t resync : 1; + uint8_t fmsAttached:1; + uint8_t autonomous : 1; + uint8_t enabled : 1; + uint8_t notEStop : 1; + uint8_t reset : 1; + }; +#else + struct { + uint8_t reset : 1; + uint8_t notEStop : 1; + uint8_t enabled : 1; + uint8_t autonomous : 1; + uint8_t fmsAttached:1; + uint8_t resync : 1; + uint8_t test :1; + uint8_t checkVersions :1; + }; +#endif + }; + uint8_t dsDigitalIn; + uint16_t teamID; + + char dsID_Alliance; + char dsID_Position; + + union { + int8_t stick0Axes[6]; + struct { + int8_t stick0Axis1; + int8_t stick0Axis2; + int8_t stick0Axis3; + int8_t stick0Axis4; + int8_t stick0Axis5; + int8_t stick0Axis6; + }; + }; + uint16_t stick0Buttons; // Left-most 4 bits are unused + + union { + int8_t stick1Axes[6]; + struct { + int8_t stick1Axis1; + int8_t stick1Axis2; + int8_t stick1Axis3; + int8_t stick1Axis4; + int8_t stick1Axis5; + int8_t stick1Axis6; + }; + }; + uint16_t stick1Buttons; // Left-most 4 bits are unused + + union { + int8_t stick2Axes[6]; + struct { + int8_t stick2Axis1; + int8_t stick2Axis2; + int8_t stick2Axis3; + int8_t stick2Axis4; + int8_t stick2Axis5; + int8_t stick2Axis6; + }; + }; + uint16_t stick2Buttons; // Left-most 4 bits are unused + + union { + int8_t stick3Axes[6]; + struct { + int8_t stick3Axis1; + int8_t stick3Axis2; + int8_t stick3Axis3; + int8_t stick3Axis4; + int8_t stick3Axis5; + int8_t stick3Axis6; + }; + }; + uint16_t stick3Buttons; // Left-most 4 bits are unused + + //Analog inputs are 10 bit right-justified + uint16_t analog1; + uint16_t analog2; + uint16_t analog3; + uint16_t analog4; + + uint64_t cRIOChecksum; + uint32_t FPGAChecksum0; + uint32_t FPGAChecksum1; + uint32_t FPGAChecksum2; + uint32_t FPGAChecksum3; + + char versionData[8]; +}; + inline float intToFloat(int value) { return *(float*) &value; @@ -50,11 +267,30 @@ extern "C" { void setFPGALED(uint32_t state, int32_t *status); int32_t getFPGALED(int32_t *status); + + int HALSetErrorData(const char *errors, int errorsLength, int wait_ms); + int HALSetUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms); + int HALOverrideIOConfig(const char *ioConfig, int wait_ms); + int HALGetDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms); + int HALGetCommonControlData(HALCommonControlData *data, int wait_ms); + void HALSetNewDataSem(pthread_mutex_t *); + int HALSetStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber, + const char *userDataHigh, int userDataHighLength, + const char *userDataLow, int userDataLowLength, int wait_ms); + + void HALNetworkCommunicationReserve(); + void HALNetworkCommunicationObserveUserProgramStarting(void); + void HALNetworkCommunicationObserveUserProgramDisabled(void); + void HALNetworkCommunicationObserveUserProgramAutonomous(void); + void HALNetworkCommunicationObserveUserProgramTeleop(void); + void HALNetworkCommunicationObserveUserProgramTest(void); + + uint32_t HALReport(uint8_t resource, uint8_t instanceNumber, uint8_t context = 0, const char *feature = NULL); } // TODO: HACKS for now... extern "C" { - void FRC_NetworkCommunication_Reserve(); + //void FRC_NetworkCommunication_Reserve(); void NumericArrayResize(); void RTSetCleanupProc(); diff --git a/hal/include/src/main/include/HAL/Semaphore.h b/hal/include/src/main/include/HAL/Semaphore.h index 1282827ec8..61494e8e79 100644 --- a/hal/include/src/main/include/HAL/Semaphore.h +++ b/hal/include/src/main/include/HAL/Semaphore.h @@ -32,14 +32,17 @@ extern "C" { extern const uint32_t SEMAPHORE_EMPTY; extern const uint32_t SEMAPHORE_FULL; - MUTEX_ID initializeMutex(uint32_t flags); + MUTEX_ID initializeMutexRecursive(); + MUTEX_ID initializeMutexNormal(); void deleteMutex(MUTEX_ID sem); - int8_t takeMutex(MUTEX_ID sem, int32_t timeout); + int8_t takeMutex(MUTEX_ID sem); + int8_t tryTakeMutex(MUTEX_ID sem); int8_t giveMutex(MUTEX_ID sem); - SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_value); + SEMAPHORE_ID initializeSemaphore(uint32_t initial_value); void deleteSemaphore(SEMAPHORE_ID sem); - int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout); + int8_t takeSemaphore(SEMAPHORE_ID sem); + int8_t tryTakeSemaphore(SEMAPHORE_ID sem); int8_t giveSemaphore(SEMAPHORE_ID sem); MULTIWAIT_ID initializeMultiWait(); diff --git a/hal/include/src/main/include/HAL/cpp/Synchronized.h b/hal/include/src/main/include/HAL/cpp/Synchronized.h index 768861ffff..d889e73d08 100644 --- a/hal/include/src/main/include/HAL/cpp/Synchronized.h +++ b/hal/include/src/main/include/HAL/cpp/Synchronized.h @@ -36,7 +36,7 @@ class ReentrantSemaphore { public: explicit ReentrantSemaphore() { - m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE); + m_semaphore = initializeMutexRecursive(); } ~ReentrantSemaphore() { deleteMutex(m_semaphore); @@ -47,7 +47,7 @@ public: * @return 0 for success, -1 for error. If -1, the error will be in errno. */ int take() { - return takeMutex(m_semaphore, SEMAPHORE_WAIT_FOREVER); + return takeMutex(m_semaphore); } /** diff --git a/hal/pom.xml b/hal/pom.xml index 33b56a79be..38d62e3442 100644 --- a/hal/pom.xml +++ b/hal/pom.xml @@ -11,10 +11,6 @@ include - - C:/Users/wpilibj-buildmaster/maven-repository - - jenkins @@ -32,9 +28,6 @@ Athena - AthenaJava - AthenaXX - AthenaXXJava diff --git a/maven-utilities/athena/cpp-executable/pom.xml b/maven-utilities/athena/cpp-executable/pom.xml index b527679efa..bf4e6aeb38 100644 --- a/maven-utilities/athena/cpp-executable/pom.xml +++ b/maven-utilities/athena/cpp-executable/pom.xml @@ -10,7 +10,7 @@ UTF-8 UTF-8 - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/maven-utilities/athena/library-jar/pom.xml b/maven-utilities/athena/library-jar/pom.xml index 82dd3ac640..5a828b29bc 100644 --- a/maven-utilities/athena/library-jar/pom.xml +++ b/maven-utilities/athena/library-jar/pom.xml @@ -10,7 +10,7 @@ UTF-8 UTF-8 - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/maven-utilities/athena/pom.xml b/maven-utilities/athena/pom.xml index 689748d388..ef42499ff1 100644 --- a/maven-utilities/athena/pom.xml +++ b/maven-utilities/athena/pom.xml @@ -15,7 +15,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/maven-utilities/athena/shared-library/pom.xml b/maven-utilities/athena/shared-library/pom.xml index 9ce400dfe9..7aa2b61a3a 100644 --- a/maven-utilities/athena/shared-library/pom.xml +++ b/maven-utilities/athena/shared-library/pom.xml @@ -10,7 +10,7 @@ UTF-8 UTF-8 - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/maven-utilities/athena/static-library/pom.xml b/maven-utilities/athena/static-library/pom.xml index d95d1fd2d0..20b7c2dcf5 100644 --- a/maven-utilities/athena/static-library/pom.xml +++ b/maven-utilities/athena/static-library/pom.xml @@ -10,7 +10,7 @@ UTF-8 UTF-8 - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/maven-utilities/include/pom.xml b/maven-utilities/include/pom.xml index 0d53f1ed3f..7c52421795 100644 --- a/maven-utilities/include/pom.xml +++ b/maven-utilities/include/pom.xml @@ -10,7 +10,7 @@ UTF-8 UTF-8 - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/maven-utilities/pom.xml b/maven-utilities/pom.xml index abdd5ee17b..8ad8371bfb 100644 --- a/maven-utilities/pom.xml +++ b/maven-utilities/pom.xml @@ -14,7 +14,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/networktables/cpp/Athena/pom.xml b/networktables/cpp/Athena/pom.xml index 884e91d90d..b2edaab052 100644 --- a/networktables/cpp/Athena/pom.xml +++ b/networktables/cpp/Athena/pom.xml @@ -10,6 +10,7 @@ edu.wpi.first.wpilib.templates.athena static-library 0.1.0-SNAPSHOT + ../../maven-utilities/athena/static-library diff --git a/networktables/cpp/parent/pom.xml b/networktables/cpp/parent/pom.xml index f0e8ea9d46..d4687bd51b 100644 --- a/networktables/cpp/parent/pom.xml +++ b/networktables/cpp/parent/pom.xml @@ -38,7 +38,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/networktables/cpp/pom.xml b/networktables/cpp/pom.xml index 2dec8637b7..ccac2f6eab 100644 --- a/networktables/cpp/pom.xml +++ b/networktables/cpp/pom.xml @@ -12,7 +12,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/networktables/java/Athena/pom.xml b/networktables/java/Athena/pom.xml index b1ae8010c2..ddcea8e55f 100644 --- a/networktables/java/Athena/pom.xml +++ b/networktables/java/Athena/pom.xml @@ -10,6 +10,7 @@ edu.wpi.first.wpilib.templates.athena library-jar 0.1.0-SNAPSHOT + ../../../maven-utilities/athena/library-jar @@ -56,6 +57,7 @@ org.codehaus.mojo build-helper-maven-plugin + 1.8 add-source diff --git a/networktables/java/Azalea/pom.xml b/networktables/java/Azalea/pom.xml index 7c5ab6843f..33bf65fadf 100644 --- a/networktables/java/Azalea/pom.xml +++ b/networktables/java/Azalea/pom.xml @@ -11,6 +11,7 @@ edu.wpi.first.wpilib.templates.azalea library-jar 0.1.0-SNAPSHOT + ../../../maven-utilities/azalea/library-jar @@ -41,6 +42,7 @@ org.codehaus.mojo build-helper-maven-plugin + 1.8 add-source diff --git a/networktables/java/dist-old/pom.xml b/networktables/java/dist-old/pom.xml index 99222790d3..44b0e4e37e 100644 --- a/networktables/java/dist-old/pom.xml +++ b/networktables/java/dist-old/pom.xml @@ -158,7 +158,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/networktables/java/pom.xml b/networktables/java/pom.xml index 05ecec94c4..78d18e2f3b 100644 --- a/networktables/java/pom.xml +++ b/networktables/java/pom.xml @@ -8,7 +8,7 @@ 0.1.0-SNAPSHOT - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/networktables/pom.xml b/networktables/pom.xml index f4b9ef9dc5..3313f9b407 100644 --- a/networktables/pom.xml +++ b/networktables/pom.xml @@ -13,7 +13,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/ni-libraries/parent/pom.xml b/ni-libraries/parent/pom.xml index bda2d47322..8087b04e89 100644 --- a/ni-libraries/parent/pom.xml +++ b/ni-libraries/parent/pom.xml @@ -10,7 +10,7 @@ UTF-8 UTF-8 - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/ni-libraries/pom.xml b/ni-libraries/pom.xml index b3704d4165..05942735c2 100644 --- a/ni-libraries/pom.xml +++ b/ni-libraries/pom.xml @@ -21,7 +21,7 @@ - C:/Users/wpilibj-buildmaster/maven-repository + diff --git a/wpilibc/src/main/include/Dashboard.h b/wpilibc/src/main/include/Dashboard.h index e3777e33f1..e893c80574 100644 --- a/wpilibc/src/main/include/Dashboard.h +++ b/wpilibc/src/main/include/Dashboard.h @@ -8,7 +8,7 @@ #define __DASHBOARD_H__ #include "DashboardBase.h" -#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/FRCComm.h" #include #include #include "HAL/HAL.h" @@ -50,7 +50,7 @@ public: void GetStatusBuffer(char** userStatusData, int32_t* userStatusDataSize); void Flush() {} private: - static const int32_t kMaxDashboardDataSize = USER_STATUS_DATA_SIZE - sizeof(uint32_t) * 3 - sizeof(uint8_t); // 13 bytes needed for 3 size parameters and the sequence number + static const int32_t kMaxDashboardDataSize = HAL_USER_STATUS_DATA_SIZE - sizeof(uint32_t) * 3 - sizeof(uint8_t); // 13 bytes needed for 3 size parameters and the sequence number // Usage Guidelines... DISALLOW_COPY_AND_ASSIGN(Dashboard); diff --git a/wpilibc/src/main/include/DriverStation.h b/wpilibc/src/main/include/DriverStation.h index d135b220d2..d716c634ba 100644 --- a/wpilibc/src/main/include/DriverStation.h +++ b/wpilibc/src/main/include/DriverStation.h @@ -12,7 +12,7 @@ #include "SensorBase.h" #include "Task.h" -struct FRCCommonControlData; +struct HALCommonControlData; class AnalogChannel; /** @@ -109,7 +109,7 @@ private: void Run(); - struct FRCCommonControlData *m_controlData; + struct HALCommonControlData *m_controlData; uint8_t m_digitalOut; AnalogChannel *m_batteryChannel; MUTEX_ID m_statusDataSemaphore; diff --git a/wpilibc/src/main/include/DriverStationEnhancedIO.h b/wpilibc/src/main/include/DriverStationEnhancedIO.h index 73f0340653..a7222e7c96 100644 --- a/wpilibc/src/main/include/DriverStationEnhancedIO.h +++ b/wpilibc/src/main/include/DriverStationEnhancedIO.h @@ -8,7 +8,7 @@ #define __DRIVER_STATION_ENHANCED_IO_H__ #include "ErrorBase.h" -#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/FRCComm.h" #include #include #include "HAL/HAL.h" @@ -91,8 +91,8 @@ class DriverStationEnhancedIO : public ErrorBase enum tBlockID { - kInputBlockID = kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input, - kOutputBlockID = kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output, + kInputBlockID = HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input, + kOutputBlockID = HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output, }; enum tStatusFlags {kStatusValid = 0x01, kStatusConfigChanged = 0x02, kForceEnhancedMode = 0x04}; diff --git a/wpilibc/src/main/include/RobotBase.h b/wpilibc/src/main/include/RobotBase.h index fbdc270766..ff181a2270 100644 --- a/wpilibc/src/main/include/RobotBase.h +++ b/wpilibc/src/main/include/RobotBase.h @@ -33,7 +33,7 @@ class DriverStation; #define START_ROBOT_CLASS(_ClassName_) \ int main() \ { \ - FRC_NetworkCommunication_Reserve(); \ + HALNetworkCommunicationReserve(); \ RobotBase* robot = new _ClassName_(); \ robot->StartCompetition(); \ return 0; \ diff --git a/wpilibc/src/main/native/ADXL345_SPI.cpp b/wpilibc/src/main/native/ADXL345_SPI.cpp index 1e7f0eaba2..26569f1101 100644 --- a/wpilibc/src/main/native/ADXL345_SPI.cpp +++ b/wpilibc/src/main/native/ADXL345_SPI.cpp @@ -7,7 +7,7 @@ #include "ADXL345_SPI.h" #include "DigitalInput.h" #include "DigitalOutput.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "SPI.h" const uint8_t ADXL345_SPI::kPowerCtlRegister; @@ -109,7 +109,7 @@ void ADXL345_SPI::Init(DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *mi m_spi->SetBitsPerWord(24); m_spi->ApplyConfig(); - nUsageReporting::report(nUsageReporting::kResourceType_ADXL345, nUsageReporting::kADXL345_SPI); + HALReport(HALUsageReporting::kResourceType_ADXL345, HALUsageReporting::kADXL345_SPI); } } diff --git a/wpilibc/src/main/native/Accelerometer.cpp b/wpilibc/src/main/native/Accelerometer.cpp index 94bf6fab6a..2ad1affbcd 100644 --- a/wpilibc/src/main/native/Accelerometer.cpp +++ b/wpilibc/src/main/native/Accelerometer.cpp @@ -6,7 +6,7 @@ #include "Accelerometer.h" #include "AnalogModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -18,7 +18,7 @@ void Accelerometer::InitAccelerometer() m_table = NULL; m_voltsPerG = 1.0; m_zeroGVoltage = 2.5; - nUsageReporting::report(nUsageReporting::kResourceType_Accelerometer, m_analogChannel->GetChannel(), m_analogChannel->GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_Accelerometer, m_analogChannel->GetChannel(), m_analogChannel->GetModuleNumber() - 1); LiveWindow::GetInstance()->AddSensor("Accelerometer", m_analogChannel->GetModuleNumber(), m_analogChannel->GetChannel(), this); } diff --git a/wpilibc/src/main/native/AnalogChannel.cpp b/wpilibc/src/main/native/AnalogChannel.cpp index 0b6ef70955..bc9ea05f0b 100644 --- a/wpilibc/src/main/native/AnalogChannel.cpp +++ b/wpilibc/src/main/native/AnalogChannel.cpp @@ -6,7 +6,7 @@ #include "AnalogChannel.h" #include "AnalogModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -53,7 +53,7 @@ void AnalogChannel::InitChannel(uint8_t moduleNumber, uint32_t channel) wpi_setErrorWithContext(status, getHALErrorMessage(status)); LiveWindow::GetInstance()->AddSensor("AnalogChannel",channel, GetModuleNumber(), this); - nUsageReporting::report(nUsageReporting::kResourceType_AnalogChannel, channel, GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_AnalogChannel, channel, GetModuleNumber() - 1); } /** diff --git a/wpilibc/src/main/native/AnalogTrigger.cpp b/wpilibc/src/main/native/AnalogTrigger.cpp index f35421d3ac..86034d93d2 100644 --- a/wpilibc/src/main/native/AnalogTrigger.cpp +++ b/wpilibc/src/main/native/AnalogTrigger.cpp @@ -8,7 +8,7 @@ #include "AnalogChannel.h" #include "AnalogModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" @@ -25,7 +25,7 @@ void AnalogTrigger::InitTrigger(uint8_t moduleNumber, uint32_t channel) wpi_setErrorWithContext(status, getHALErrorMessage(status)); m_index = index; - nUsageReporting::report(nUsageReporting::kResourceType_AnalogTrigger, channel, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_AnalogTrigger, channel, moduleNumber - 1); } /** diff --git a/wpilibc/src/main/native/AnalogTriggerOutput.cpp b/wpilibc/src/main/native/AnalogTriggerOutput.cpp index 8198382fac..056e09b536 100644 --- a/wpilibc/src/main/native/AnalogTriggerOutput.cpp +++ b/wpilibc/src/main/native/AnalogTriggerOutput.cpp @@ -6,7 +6,7 @@ #include "AnalogTriggerOutput.h" #include "AnalogTrigger.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" /** @@ -22,7 +22,7 @@ AnalogTriggerOutput::AnalogTriggerOutput(AnalogTrigger *trigger, AnalogTriggerTy : m_trigger (trigger) , m_outputType (outputType) { - nUsageReporting::report(nUsageReporting::kResourceType_AnalogTriggerOutput, trigger->GetIndex(), outputType); + HALReport(HALUsageReporting::kResourceType_AnalogTriggerOutput, trigger->GetIndex(), outputType); } AnalogTriggerOutput::~AnalogTriggerOutput() diff --git a/wpilibc/src/main/native/CANJaguar.cpp b/wpilibc/src/main/native/CANJaguar.cpp index dbdf76be51..fc209b47d3 100644 --- a/wpilibc/src/main/native/CANJaguar.cpp +++ b/wpilibc/src/main/native/CANJaguar.cpp @@ -6,9 +6,9 @@ #include "CANJaguar.h" #define tNIRIO_i32 int -#include "CAN/JaguarCANDriver.h" +//#include "CAN/JaguarCANDriver.h" #include "CAN/can_proto.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include #include "LiveWindow/LiveWindow.h" @@ -31,7 +31,7 @@ constexpr double CANJaguar::kApproxBusVoltage; void CANJaguar::InitCANJaguar() { m_table = NULL; - m_transactionSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE); + m_transactionSemaphore = initializeMutexNormal(); if (m_deviceNumber < 1 || m_deviceNumber > 63) { char buf[256]; @@ -69,7 +69,7 @@ void CANJaguar::InitCANJaguar() } m_safetyHelper = new MotorSafetyHelper(this); - nUsageReporting::report(nUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode); + HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode); LiveWindow::GetInstance()->AddActuator("CANJaguar", m_deviceNumber, 0, this); } @@ -405,7 +405,7 @@ void CANJaguar::setTransaction(uint32_t messageID, const uint8_t *data, uint8_t return; // Make sure we don't have more than one transaction with the same Jaguar outstanding. - takeMutex(m_transactionSemaphore, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_transactionSemaphore); // Throw away any stale acks. receiveMessage(&ackMessageID, NULL, 0, 0.0f); @@ -444,7 +444,7 @@ void CANJaguar::getTransaction(uint32_t messageID, uint8_t *data, uint8_t *dataS } // Make sure we don't have more than one transaction with the same Jaguar outstanding. - takeMutex(m_transactionSemaphore, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_transactionSemaphore); // Throw away any stale responses. receiveMessage(&targetedMessageID, NULL, 0, 0.0f); @@ -778,7 +778,7 @@ void CANJaguar::ChangeControlMode(ControlMode controlMode) // Update the local mode m_controlMode = controlMode; - nUsageReporting::report(nUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode); + HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode); } /** diff --git a/wpilibc/src/main/native/Commands/Scheduler.cpp b/wpilibc/src/main/native/Commands/Scheduler.cpp index c625251d1d..fd88b89dbf 100644 --- a/wpilibc/src/main/native/Commands/Scheduler.cpp +++ b/wpilibc/src/main/native/Commands/Scheduler.cpp @@ -8,7 +8,7 @@ #include "Buttons/ButtonScheduler.h" #include "Commands/Subsystem.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" #include @@ -19,23 +19,21 @@ Scheduler *Scheduler::_instance = NULL; Scheduler::Scheduler() : m_buttonsLock(NULL), m_additionsLock(NULL), m_adding(false) { - m_buttonsLock = initializeMutex( - SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE); - m_additionsLock = initializeMutex( - SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE); + m_buttonsLock = initializeMutexNormal(); + m_additionsLock = initializeMutexNormal(); - nUsageReporting::report(nUsageReporting::kResourceType_Command, - nUsageReporting::kCommand_Scheduler); + HALReport(HALUsageReporting::kResourceType_Command, + HALUsageReporting::kCommand_Scheduler); m_table = NULL; m_enabled = true; } Scheduler::~Scheduler() { - takeMutex(m_additionsLock, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_additionsLock); deleteMutex(m_additionsLock); - takeMutex(m_buttonsLock, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_buttonsLock); deleteMutex(m_buttonsLock); } diff --git a/wpilibc/src/main/native/Compressor.cpp b/wpilibc/src/main/native/Compressor.cpp index 0c973f124c..32d72e11d6 100644 --- a/wpilibc/src/main/native/Compressor.cpp +++ b/wpilibc/src/main/native/Compressor.cpp @@ -6,7 +6,7 @@ #include "Compressor.h" #include "DigitalInput.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Timer.h" #include "WPIErrors.h" @@ -52,7 +52,7 @@ void Compressor::InitCompressor(uint8_t pressureSwitchModuleNumber, m_pressureSwitch = new DigitalInput(pressureSwitchModuleNumber, pressureSwitchChannel); m_relay = new Relay(compresssorRelayModuleNumber, compressorRelayChannel, Relay::kForwardOnly); - nUsageReporting::report(nUsageReporting::kResourceType_Compressor, 0); + HALReport(HALUsageReporting::kResourceType_Compressor, 0); if (!m_task.Start((int32_t)this)) { diff --git a/wpilibc/src/main/native/Counter.cpp b/wpilibc/src/main/native/Counter.cpp index 03e7237c36..c49dfd6395 100644 --- a/wpilibc/src/main/native/Counter.cpp +++ b/wpilibc/src/main/native/Counter.cpp @@ -7,7 +7,7 @@ #include "Counter.h" #include "AnalogTrigger.h" #include "DigitalInput.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" @@ -29,7 +29,7 @@ void Counter::InitCounter(Mode mode) m_allocatedUpSource = false; m_allocatedDownSource = false; - nUsageReporting::report(nUsageReporting::kResourceType_Counter, index, mode); + HALReport(HALUsageReporting::kResourceType_Counter, index, mode); } /** diff --git a/wpilibc/src/main/native/Dashboard.cpp b/wpilibc/src/main/native/Dashboard.cpp index d31cf03534..c4be829fa9 100644 --- a/wpilibc/src/main/native/Dashboard.cpp +++ b/wpilibc/src/main/native/Dashboard.cpp @@ -6,7 +6,7 @@ #include "Dashboard.h" #include "DriverStation.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" #include @@ -33,7 +33,7 @@ Dashboard::Dashboard(MUTEX_ID statusDataSem) m_localPrintBuffer = new char[kMaxDashboardDataSize * 2]; m_localPrintBuffer[0] = 0; m_packPtr = m_localBuffer; - m_printSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + m_printSemaphore = initializeMutexNormal(); } /** @@ -307,7 +307,7 @@ int32_t Dashboard::Finalize() static bool reported = false; if (!reported) { - nUsageReporting::report(nUsageReporting::kResourceType_Dashboard, 0); + HALReport(HALUsageReporting::kResourceType_Dashboard, 0); reported = true; } diff --git a/wpilibc/src/main/native/DigitalInput.cpp b/wpilibc/src/main/native/DigitalInput.cpp index 5e26e2d494..9d5be54682 100644 --- a/wpilibc/src/main/native/DigitalInput.cpp +++ b/wpilibc/src/main/native/DigitalInput.cpp @@ -6,7 +6,7 @@ #include "DigitalInput.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" @@ -39,7 +39,7 @@ void DigitalInput::InitDigitalInput(uint8_t moduleNumber, uint32_t channel) m_module = DigitalModule::GetInstance(moduleNumber); m_module->AllocateDIO(channel, true); - nUsageReporting::report(nUsageReporting::kResourceType_DigitalInput, channel, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_DigitalInput, channel, moduleNumber - 1); } /** diff --git a/wpilibc/src/main/native/DigitalOutput.cpp b/wpilibc/src/main/native/DigitalOutput.cpp index f1cbc9eb4c..0570df493d 100644 --- a/wpilibc/src/main/native/DigitalOutput.cpp +++ b/wpilibc/src/main/native/DigitalOutput.cpp @@ -6,7 +6,7 @@ #include "DigitalOutput.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" @@ -38,7 +38,7 @@ void DigitalOutput::InitDigitalOutput(uint8_t moduleNumber, uint32_t channel) m_module = DigitalModule::GetInstance(moduleNumber); m_module->AllocateDIO(m_channel, false); - nUsageReporting::report(nUsageReporting::kResourceType_DigitalOutput, channel, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_DigitalOutput, channel, moduleNumber - 1); } /** diff --git a/wpilibc/src/main/native/DoubleSolenoid.cpp b/wpilibc/src/main/native/DoubleSolenoid.cpp index ede74dfebb..607104bdd3 100644 --- a/wpilibc/src/main/native/DoubleSolenoid.cpp +++ b/wpilibc/src/main/native/DoubleSolenoid.cpp @@ -5,7 +5,7 @@ /*----------------------------------------------------------------------------*/ #include "DoubleSolenoid.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include #include "LiveWindow/LiveWindow.h" @@ -52,8 +52,8 @@ void DoubleSolenoid::InitSolenoid() m_forwardMask = 1 << (m_forwardChannel - 1); m_reverseMask = 1 << (m_reverseChannel - 1); - nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_forwardChannel, m_moduleNumber - 1); - nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_reverseChannel, m_moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_Solenoid, m_forwardChannel, m_moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel, m_moduleNumber - 1); LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", m_moduleNumber, m_forwardChannel, this); } diff --git a/wpilibc/src/main/native/DriverStation.cpp b/wpilibc/src/main/native/DriverStation.cpp index 002635a79b..4d2b142cfe 100644 --- a/wpilibc/src/main/native/DriverStation.cpp +++ b/wpilibc/src/main/native/DriverStation.cpp @@ -8,12 +8,20 @@ #include "AnalogChannel.h" #include "HAL/cpp/Synchronized.h" #include "Timer.h" -#include "NetworkCommunication/FRCComm.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/UsageReporting.h" #include "MotorSafetyHelper.h" #include "Utility.h" #include "WPIErrors.h" #include +#include "Log.h" + +// set the logging level +TLogLevel dsLogLevel = logDEBUG; + +#define DS_LOG(level) \ + if (level > dsLogLevel) ; \ + else Log().Get(level) const uint32_t DriverStation::kBatteryModuleNumber; const uint32_t DriverStation::kBatteryChannel; @@ -32,7 +40,7 @@ DriverStation::DriverStation() : m_controlData (NULL) , m_digitalOut (0) , m_batteryChannel (NULL) - , m_statusDataSemaphore (initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE)) + , m_statusDataSemaphore (initializeMutexNormal()) , m_task ("DriverStation", (FUNCPTR)DriverStation::InitTask) , m_dashboardHigh(m_statusDataSemaphore) , m_dashboardLow(m_statusDataSemaphore) @@ -49,16 +57,16 @@ DriverStation::DriverStation() , m_userInTest(false) { // Create a new semaphore - m_packetDataAvailableSem = initializeMutex(SEMAPHORE_Q_PRIORITY); - m_newControlData = initializeSemaphore(SEMAPHORE_Q_FIFO, SEMAPHORE_EMPTY); + m_packetDataAvailableSem = initializeMutexNormal(); + m_newControlData = initializeSemaphore(SEMAPHORE_EMPTY); // Register that semaphore with the network communications task. // It will signal when new packet data is available. - setNewDataSem(m_packetDataAvailableSem); + HALSetNewDataSem(m_packetDataAvailableSem); m_waitForDataSem = initializeMultiWait(); - m_controlData = new FRCCommonControlData; + m_controlData = new HALCommonControlData; // initialize packet number and control words to zero; m_controlData->packetIndex = 0; @@ -104,7 +112,7 @@ DriverStation::~DriverStation() m_instance = NULL; deleteMultiWait(m_waitForDataSem); // Unregister our semaphore. - setNewDataSem(0); + HALSetNewDataSem(0); deleteMutex(m_packetDataAvailableSem); } @@ -118,7 +126,7 @@ void DriverStation::Run() int period = 0; while (true) { - takeMutex(m_packetDataAvailableSem, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_packetDataAvailableSem); SetData(); m_enhancedIO.UpdateData(); GetData(); @@ -129,13 +137,13 @@ void DriverStation::Run() period = 0; } if (m_userInDisabled) - FRC_NetworkCommunication_observeUserProgramDisabled(); + HALNetworkCommunicationObserveUserProgramDisabled(); if (m_userInAutonomous) - FRC_NetworkCommunication_observeUserProgramAutonomous(); + HALNetworkCommunicationObserveUserProgramAutonomous(); if (m_userInTeleop) - FRC_NetworkCommunication_observeUserProgramTeleop(); + HALNetworkCommunicationObserveUserProgramTeleop(); if (m_userInTest) - FRC_NetworkCommunication_observeUserProgramTest(); + HALNetworkCommunicationObserveUserProgramTest(); } } @@ -159,7 +167,9 @@ DriverStation* DriverStation::GetInstance() void DriverStation::GetData() { static bool lastEnabled = false; - getCommonControlData(m_controlData, HAL_WAIT_FOREVER); + + HALGetCommonControlData(m_controlData, HAL_WAIT_FOREVER); + if (!lastEnabled && IsEnabled()) { // If starting teleop, assume that autonomous just took up 15 seconds @@ -190,7 +200,7 @@ void DriverStation::SetData() m_dashboardInUseHigh->GetStatusBuffer(&userStatusDataHigh, &userStatusDataHighSize); m_dashboardInUseLow->GetStatusBuffer(&userStatusDataLow, &userStatusDataLowSize); - setStatusData(GetBatteryVoltage(), m_digitalOut, m_updateNumber, + HALSetStatusData(GetBatteryVoltage(), m_digitalOut, m_updateNumber, userStatusDataHigh, userStatusDataHighSize, userStatusDataLow, userStatusDataLowSize, HAL_WAIT_FOREVER); m_dashboardInUseHigh->Flush(); @@ -311,7 +321,7 @@ float DriverStation::GetAnalogIn(uint32_t channel) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_Analog); + HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel, HALUsageReporting::kDriverStationCIO_Analog); reported_mask |= (1 >> channel); } @@ -343,7 +353,7 @@ bool DriverStation::GetDigitalIn(uint32_t channel) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_DigitalIn); + HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel, HALUsageReporting::kDriverStationCIO_DigitalIn); reported_mask |= (1 >> channel); } @@ -367,7 +377,7 @@ void DriverStation::SetDigitalOut(uint32_t channel, bool value) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationCIO, channel, nUsageReporting::kDriverStationCIO_DigitalOut); + HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel,HALUsageReporting::kDriverStationCIO_DigitalOut); reported_mask |= (1 >> channel); } @@ -421,7 +431,7 @@ bool DriverStation::IsTest() */ bool DriverStation::IsNewControlData() { - return takeSemaphore(m_newControlData, SEMAPHORE_NO_WAIT) == 0; + return tryTakeSemaphore(m_newControlData) == 0; } /** diff --git a/wpilibc/src/main/native/DriverStationEnhancedIO.cpp b/wpilibc/src/main/native/DriverStationEnhancedIO.cpp index 5d8b95868c..e815ada6c2 100644 --- a/wpilibc/src/main/native/DriverStationEnhancedIO.cpp +++ b/wpilibc/src/main/native/DriverStationEnhancedIO.cpp @@ -5,7 +5,7 @@ /*----------------------------------------------------------------------------*/ #include "DriverStationEnhancedIO.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" #include @@ -27,8 +27,8 @@ DriverStationEnhancedIO::DriverStationEnhancedIO() m_outputData.id = kOutputBlockID; // Expected to be active low, so initialize inactive. m_outputData.data.fixed_digital_out = 0x3; - m_inputDataSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); - m_outputDataSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + m_inputDataSemaphore = initializeMutexNormal(); + m_outputDataSemaphore = initializeMutexNormal(); m_encoderOffsets[0] = 0; m_encoderOffsets[1] = 0; } @@ -72,9 +72,9 @@ void DriverStationEnhancedIO::UpdateData() } m_outputData.flags |= kStatusConfigChanged; } - overrideIOConfig((char*)&m_outputData, 5); + HALOverrideIOConfig((char*)&m_outputData, 5); } - retVal = getDynamicControlData(kOutputBlockID, (char*)&tempOutputData, sizeof(status_block_t), 5); + retVal = HALGetDynamicControlData(kOutputBlockID, (char*)&tempOutputData, sizeof(status_block_t), 5); if (retVal == 0) { if (m_outputValid) @@ -114,7 +114,7 @@ void DriverStationEnhancedIO::UpdateData() { Synchronized sync(m_inputDataSemaphore); control_block_t tempInputData; - retVal = getDynamicControlData(kInputBlockID, (char*)&tempInputData, sizeof(control_block_t), 5); + retVal = HALGetDynamicControlData(kInputBlockID, (char*)&tempInputData, sizeof(control_block_t), 5); if (retVal == 0 && tempInputData.data.api_version == kSupportedAPIVersion) { m_inputData = tempInputData; @@ -179,7 +179,7 @@ double DriverStationEnhancedIO::GetAcceleration(tAccelChannel channel) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_Acceleration); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_Acceleration); reported_mask |= (1 >> channel); } @@ -221,7 +221,7 @@ double DriverStationEnhancedIO::GetAnalogInRatio(uint32_t channel) static uint16_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_AnalogIn); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_AnalogIn); reported_mask |= (1 >> channel); } @@ -286,7 +286,7 @@ void DriverStationEnhancedIO::SetAnalogOut(uint32_t channel, double value) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_AnalogOut); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_AnalogOut); reported_mask |= (1 >> channel); } @@ -320,7 +320,7 @@ bool DriverStationEnhancedIO::GetButton(uint32_t channel) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_Button); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_Button); reported_mask |= (1 >> channel); } @@ -339,7 +339,7 @@ uint8_t DriverStationEnhancedIO::GetButtons() wpi_setWPIError(EnhancedIOMissing); return 0; } - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 0, nUsageReporting::kDriverStationEIO_Button); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_Button); Synchronized sync(m_inputDataSemaphore); return m_inputData.data.buttons; } @@ -366,7 +366,7 @@ void DriverStationEnhancedIO::SetLED(uint32_t channel, bool value) static uint16_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_LED); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_LED); reported_mask |= (1 >> channel); } @@ -392,7 +392,8 @@ void DriverStationEnhancedIO::SetLEDs(uint8_t value) wpi_setWPIError(EnhancedIOMissing); return; } - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 0, nUsageReporting::kDriverStationEIO_LED); + + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_LED); Synchronized sync(m_outputDataSemaphore); m_outputData.data.leds = value; } @@ -414,7 +415,7 @@ bool DriverStationEnhancedIO::GetDigital(uint32_t channel) static uint32_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_DigitalIn); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_DigitalIn); reported_mask |= (1 >> channel); } @@ -433,7 +434,7 @@ uint16_t DriverStationEnhancedIO::GetDigitals() wpi_setWPIError(EnhancedIOMissing); return 0; } - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 0, nUsageReporting::kDriverStationEIO_DigitalIn); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_DigitalIn); Synchronized sync(m_inputDataSemaphore); return m_inputData.data.digital; } @@ -460,7 +461,7 @@ void DriverStationEnhancedIO::SetDigitalOutput(uint32_t channel, bool value) static uint32_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_DigitalOut); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_DigitalOut); reported_mask |= (1 >> channel); } @@ -762,7 +763,7 @@ void DriverStationEnhancedIO::SetFixedDigitalOutput(uint32_t channel, bool value static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_FixedDigitalOut); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_FixedDigitalOut); reported_mask |= (1 >> channel); } @@ -806,7 +807,7 @@ int16_t DriverStationEnhancedIO::GetEncoder(uint32_t encoderNumber) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> encoderNumber))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, encoderNumber, nUsageReporting::kDriverStationEIO_Encoder); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, encoderNumber, HALUsageReporting::kDriverStationEIO_Encoder); reported_mask |= (1 >> encoderNumber); } @@ -906,7 +907,7 @@ double DriverStationEnhancedIO::GetTouchSlider() return 0.0; } - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, 1, nUsageReporting::kDriverStationEIO_TouchSlider); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 1, HALUsageReporting::kDriverStationEIO_TouchSlider); Synchronized sync(m_inputDataSemaphore); uint8_t value = m_inputData.data.capsense_slider; @@ -961,7 +962,7 @@ void DriverStationEnhancedIO::SetPWMOutput(uint32_t channel, double value) static uint8_t reported_mask = 0; if (!(reported_mask & (1 >> channel))) { - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationEIO, channel, nUsageReporting::kDriverStationEIO_PWM); + HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_PWM); reported_mask |= (1 >> channel); } diff --git a/wpilibc/src/main/native/DriverStationLCD.cpp b/wpilibc/src/main/native/DriverStationLCD.cpp index 81e5cfbb7c..ee47a11c3d 100644 --- a/wpilibc/src/main/native/DriverStationLCD.cpp +++ b/wpilibc/src/main/native/DriverStationLCD.cpp @@ -8,8 +8,8 @@ //#include #include -#include "NetworkCommunication/FRCComm.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" #undef min @@ -29,14 +29,14 @@ DriverStationLCD::DriverStationLCD() : m_textBuffer (NULL) , m_textBufferSemaphore (NULL) { - m_textBuffer = new char[USER_DS_LCD_DATA_SIZE]; - memset(m_textBuffer, ' ', USER_DS_LCD_DATA_SIZE); + m_textBuffer = new char[HAL_USER_DS_LCD_DATA_SIZE]; + memset(m_textBuffer, ' ', HAL_USER_DS_LCD_DATA_SIZE); *((uint16_t *)m_textBuffer) = kFullDisplayTextCommand; - m_textBufferSemaphore = initializeMutex(SEMAPHORE_DELETE_SAFE); + m_textBufferSemaphore = initializeMutexNormal(); - nUsageReporting::report(nUsageReporting::kResourceType_DriverStationLCD, 0); + HALReport(HALUsageReporting::kResourceType_DriverStationLCD, 0); AddToSingletonList(); } @@ -66,7 +66,7 @@ DriverStationLCD* DriverStationLCD::GetInstance() void DriverStationLCD::UpdateLCD() { Synchronized sync(m_textBufferSemaphore); - setUserDsLcdData(m_textBuffer, USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms); + HALSetUserDsLcdData(m_textBuffer, HAL_USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms); } /** diff --git a/wpilibc/src/main/native/Encoder.cpp b/wpilibc/src/main/native/Encoder.cpp index f743dbee2c..86a47c8326 100644 --- a/wpilibc/src/main/native/Encoder.cpp +++ b/wpilibc/src/main/native/Encoder.cpp @@ -6,7 +6,7 @@ #include "Encoder.h" #include "DigitalInput.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -62,7 +62,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) m_distancePerPulse = 1.0; m_pidSource = kDistance; - nUsageReporting::report(nUsageReporting::kResourceType_Encoder, index, encodingType); + HALReport(HALUsageReporting::kResourceType_Encoder, index, encodingType); LiveWindow::GetInstance()->AddSensor("Encoder", m_aSource->GetModuleForRouting(), m_aSource->GetChannelForRouting(), this); } diff --git a/wpilibc/src/main/native/Error.cpp b/wpilibc/src/main/native/Error.cpp index 0b69ab65a9..2b5488e78a 100644 --- a/wpilibc/src/main/native/Error.cpp +++ b/wpilibc/src/main/native/Error.cpp @@ -10,7 +10,7 @@ #include #include -#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/FRCComm.h" #include "Timer.h" #include "Utility.h" bool Error::m_stackTraceEnabled = false; @@ -94,7 +94,7 @@ void Error::Report() // TODO: Add logging to disk // Send to the DriverStation - setErrorData(error_with_code, strlen(error_with_code), 100); + HALSetErrorData(error_with_code, strlen(error_with_code), 100); delete [] error_with_code; diff --git a/wpilibc/src/main/native/ErrorBase.cpp b/wpilibc/src/main/native/ErrorBase.cpp index 836a10fd17..a2b099ec77 100644 --- a/wpilibc/src/main/native/ErrorBase.cpp +++ b/wpilibc/src/main/native/ErrorBase.cpp @@ -14,7 +14,7 @@ #include #include -MUTEX_ID ErrorBase::_globalErrorMutex = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); +MUTEX_ID ErrorBase::_globalErrorMutex = initializeMutexNormal(); Error ErrorBase::_globalError; /** * @brief Initialize the instance status to 0 for now. diff --git a/wpilibc/src/main/native/Gyro.cpp b/wpilibc/src/main/native/Gyro.cpp index af69cf32db..dd6d219726 100644 --- a/wpilibc/src/main/native/Gyro.cpp +++ b/wpilibc/src/main/native/Gyro.cpp @@ -7,7 +7,7 @@ #include "Gyro.h" #include "AnalogChannel.h" #include "AnalogModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Timer.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -66,7 +66,7 @@ void Gyro::InitGyro() SetPIDSourceParameter(kAngle); - nUsageReporting::report(nUsageReporting::kResourceType_Gyro, m_analog->GetChannel(), m_analog->GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel(), m_analog->GetModuleNumber() - 1); LiveWindow::GetInstance()->AddSensor("Gyro", m_analog->GetModuleNumber(), m_analog->GetChannel(), this); } diff --git a/wpilibc/src/main/native/HiTechnicColorSensor.cpp b/wpilibc/src/main/native/HiTechnicColorSensor.cpp index 39850dc098..bd19fd3040 100644 --- a/wpilibc/src/main/native/HiTechnicColorSensor.cpp +++ b/wpilibc/src/main/native/HiTechnicColorSensor.cpp @@ -7,7 +7,7 @@ #include "HiTechnicColorSensor.h" #include "DigitalModule.h" #include "I2C.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "networktables2/type/NumberArray.h" #include "WPIErrors.h" @@ -54,7 +54,7 @@ HiTechnicColorSensor::HiTechnicColorSensor(uint8_t moduleNumber) wpi_setWPIError(CompassTypeError); } - nUsageReporting::report(nUsageReporting::kResourceType_HiTechnicColorSensor, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_HiTechnicColorSensor, moduleNumber - 1); } } diff --git a/wpilibc/src/main/native/HiTechnicCompass.cpp b/wpilibc/src/main/native/HiTechnicCompass.cpp index 2a98aa9efd..ca6dc1a246 100644 --- a/wpilibc/src/main/native/HiTechnicCompass.cpp +++ b/wpilibc/src/main/native/HiTechnicCompass.cpp @@ -7,7 +7,7 @@ #include "HiTechnicCompass.h" #include "DigitalModule.h" #include "I2C.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -45,7 +45,7 @@ HiTechnicCompass::HiTechnicCompass(uint8_t moduleNumber) wpi_setWPIError(CompassTypeError); } - nUsageReporting::report(nUsageReporting::kResourceType_HiTechnicCompass, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_HiTechnicCompass, moduleNumber - 1); LiveWindow::GetInstance()->AddSensor("HiTechnicCompass", moduleNumber, 0, this); } } diff --git a/wpilibc/src/main/native/I2C.cpp b/wpilibc/src/main/native/I2C.cpp index 1c5508ce8e..e1751005bb 100644 --- a/wpilibc/src/main/native/I2C.cpp +++ b/wpilibc/src/main/native/I2C.cpp @@ -6,7 +6,7 @@ #include "I2C.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" @@ -26,11 +26,11 @@ I2C::I2C(DigitalModule *module, uint8_t deviceAddress) { if (m_semaphore == NULL) { - m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + m_semaphore = initializeMutexNormal(); } m_objCount++; - nUsageReporting::report(nUsageReporting::kResourceType_I2C, deviceAddress, module->GetNumber() - 1); + HALReport(HALUsageReporting::kResourceType_I2C, deviceAddress, module->GetNumber() - 1); } /** @@ -163,7 +163,7 @@ void I2C::SetCompatibilityMode(bool enable) const char *cm = NULL; if (m_compatibilityMode) cm = "C"; - nUsageReporting::report(nUsageReporting::kResourceType_I2C, m_deviceAddress, m_module->GetNumber() - 1, cm); + HALReport(HALUsageReporting::kResourceType_I2C, m_deviceAddress, m_module->GetNumber() - 1, cm); } /** diff --git a/wpilibc/src/main/native/IterativeRobot.cpp b/wpilibc/src/main/native/IterativeRobot.cpp index 97f4854a6b..aa89add7f2 100644 --- a/wpilibc/src/main/native/IterativeRobot.cpp +++ b/wpilibc/src/main/native/IterativeRobot.cpp @@ -7,7 +7,7 @@ #include "IterativeRobot.h" #include "DriverStation.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/HAL.h" #include "SmartDashboard/SmartDashboard.h" #include "LiveWindow/LiveWindow.h" @@ -92,7 +92,7 @@ double IterativeRobot::GetLoopsPerSec() */ void IterativeRobot::StartCompetition() { - nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Iterative); + HALReport(HALUsageReporting::kResourceType_Framework, HALUsageReporting::kFramework_Iterative); LiveWindow *lw = LiveWindow::GetInstance(); // first and one-time initialization @@ -121,7 +121,7 @@ void IterativeRobot::StartCompetition() } if (NextPeriodReady()) { - FRC_NetworkCommunication_observeUserProgramDisabled(); + HALNetworkCommunicationObserveUserProgramDisabled(); DisabledPeriodic(); } } @@ -141,7 +141,7 @@ void IterativeRobot::StartCompetition() } if (NextPeriodReady()) { - FRC_NetworkCommunication_observeUserProgramAutonomous(); + HALNetworkCommunicationObserveUserProgramAutonomous(); AutonomousPeriodic(); } } @@ -161,7 +161,7 @@ void IterativeRobot::StartCompetition() } if (NextPeriodReady()) { - FRC_NetworkCommunication_observeUserProgramTest(); + HALNetworkCommunicationObserveUserProgramTest(); TestPeriodic(); } } @@ -182,7 +182,7 @@ void IterativeRobot::StartCompetition() } if (NextPeriodReady()) { - FRC_NetworkCommunication_observeUserProgramTeleop(); + HALNetworkCommunicationObserveUserProgramTeleop(); TeleopPeriodic(); } } diff --git a/wpilibc/src/main/native/Jaguar.cpp b/wpilibc/src/main/native/Jaguar.cpp index b5f1187c2a..79daa0ac4a 100644 --- a/wpilibc/src/main/native/Jaguar.cpp +++ b/wpilibc/src/main/native/Jaguar.cpp @@ -6,7 +6,7 @@ #include "Jaguar.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "DigitalModule.h" #include "LiveWindow/LiveWindow.h" @@ -28,7 +28,7 @@ void Jaguar::InitJaguar() SetPeriodMultiplier(kPeriodMultiplier_1X); SetRaw(m_centerPwm); - nUsageReporting::report(nUsageReporting::kResourceType_Jaguar, GetChannel(), GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_Jaguar, GetChannel(), GetModuleNumber() - 1); LiveWindow::GetInstance()->AddActuator("Jaguar", GetModuleNumber(), GetChannel(), this); } diff --git a/wpilibc/src/main/native/Joystick.cpp b/wpilibc/src/main/native/Joystick.cpp index 645a1e5659..426c78b83b 100644 --- a/wpilibc/src/main/native/Joystick.cpp +++ b/wpilibc/src/main/native/Joystick.cpp @@ -6,7 +6,7 @@ #include "Joystick.h" #include "DriverStation.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include @@ -43,7 +43,7 @@ Joystick::Joystick(uint32_t port) m_buttons[kTriggerButton] = kDefaultTriggerButton; m_buttons[kTopButton] = kDefaultTopButton; - nUsageReporting::report(nUsageReporting::kResourceType_Joystick, port); + HALReport(HALUsageReporting::kResourceType_Joystick, port); } /** diff --git a/wpilibc/src/main/native/Kinect.cpp b/wpilibc/src/main/native/Kinect.cpp index 3ca73127af..2ace5e71d4 100644 --- a/wpilibc/src/main/native/Kinect.cpp +++ b/wpilibc/src/main/native/Kinect.cpp @@ -7,16 +7,16 @@ #include "Kinect.h" #include "DriverStation.h" -#include "NetworkCommunication/FRCComm.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Skeleton.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" #include -#define kHeaderBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Header -#define kSkeletonExtraBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Extra1 -#define kSkeletonBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 +#define kHeaderBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Header +#define kSkeletonExtraBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1 +#define kSkeletonBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 Kinect *Kinect::_instance = NULL; @@ -25,14 +25,14 @@ Kinect::Kinect() : m_numberOfPlayers(0) { AddToSingletonList(); - m_dataLock = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE); + m_dataLock = initializeMutexNormal(); - nUsageReporting::report(nUsageReporting::kResourceType_Kinect, 0); + HALReport(HALUsageReporting::kResourceType_Kinect, 0); } Kinect::~Kinect() { - takeMutex(m_dataLock, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_dataLock); deleteMutex(m_dataLock); } @@ -156,7 +156,7 @@ void Kinect::UpdateData() if (m_recentPacketNumber != packetNumber) { m_recentPacketNumber = packetNumber; - int retVal = getDynamicControlData(kHeaderBundleID, m_rawHeader, sizeof(m_rawHeader), 5); + int retVal = HALGetDynamicControlData(kHeaderBundleID, m_rawHeader, sizeof(m_rawHeader), 5); if(retVal == 0) { m_numberOfPlayers = (int)m_rawHeader[13]; @@ -169,7 +169,7 @@ void Kinect::UpdateData() memcpy(&m_gravityNormal.z, &m_rawHeader[42], 4); } - retVal = getDynamicControlData(kSkeletonExtraBundleID, m_rawSkeletonExtra, sizeof(m_rawSkeletonExtra), 5); + retVal = HALGetDynamicControlData(kSkeletonExtraBundleID, m_rawSkeletonExtra, sizeof(m_rawSkeletonExtra), 5); if(retVal == 0) { memcpy(&m_position[0].x, &m_rawSkeletonExtra[22], 4); @@ -179,7 +179,7 @@ void Kinect::UpdateData() memcpy(&m_trackingState[0], &m_rawSkeletonExtra[38], 4); } - retVal = getDynamicControlData(kSkeletonBundleID, m_rawSkeleton, sizeof(m_rawSkeleton), 5); + retVal = HALGetDynamicControlData(kSkeletonBundleID, m_rawSkeleton, sizeof(m_rawSkeleton), 5); if(retVal == 0) { for(int i=0; i < Skeleton::JointCount; i++) diff --git a/wpilibc/src/main/native/KinectStick.cpp b/wpilibc/src/main/native/KinectStick.cpp index f6e30211aa..5a956ceb4f 100644 --- a/wpilibc/src/main/native/KinectStick.cpp +++ b/wpilibc/src/main/native/KinectStick.cpp @@ -8,15 +8,15 @@ #include "DriverStation.h" #include "Joystick.h" -#include "NetworkCommunication/FRCComm.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Utility.h" #include "WPIErrors.h" uint32_t KinectStick::_recentPacketNumber = 0; KinectStick::KinectStickData KinectStick::_sticks; -#define kJoystickBundleID kFRC_NetworkCommunication_DynamicType_Kinect_Joystick +#define kJoystickBundleID HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick #define kTriggerMask 1 #define kTopMask 2 @@ -34,7 +34,7 @@ KinectStick::KinectStick(int id) } m_id = id; - nUsageReporting::report(nUsageReporting::kResourceType_KinectStick, id); + HALReport(HALUsageReporting::kResourceType_KinectStick, id); } /** @@ -169,7 +169,7 @@ void KinectStick::GetData() if (_recentPacketNumber != packetNumber) { _recentPacketNumber = packetNumber; - int retVal = getDynamicControlData(kJoystickBundleID, _sticks.data, sizeof(_sticks.data), 5); + int retVal = HALGetDynamicControlData(kJoystickBundleID, _sticks.data, sizeof(_sticks.data), 5); if (retVal == 0) { wpi_assert(_sticks.formatted.size == sizeof(_sticks.data) - 1); diff --git a/wpilibc/src/main/native/Notifier.cpp b/wpilibc/src/main/native/Notifier.cpp index 502d5dbf6e..667495cc4a 100644 --- a/wpilibc/src/main/native/Notifier.cpp +++ b/wpilibc/src/main/native/Notifier.cpp @@ -30,7 +30,7 @@ Notifier::Notifier(TimerEventHandler handler, void *param) m_period = 0; m_nextEvent = NULL; m_queued = false; - m_handlerSemaphore = initializeSemaphore(SEMAPHORE_Q_PRIORITY, SEMAPHORE_FULL); + m_handlerSemaphore = initializeSemaphore(SEMAPHORE_FULL); { Synchronized sync(queueSemaphore); // do the first time intialization of static variables @@ -66,7 +66,7 @@ Notifier::~Notifier() // Acquire the semaphore; this makes certain that the handler is // not being executed by the interrupt manager. - takeSemaphore(m_handlerSemaphore, SEMAPHORE_WAIT_FOREVER); + takeSemaphore(m_handlerSemaphore); // Delete while holding the semaphore so there can be no race. deleteSemaphore(m_handlerSemaphore); } @@ -122,7 +122,7 @@ void Notifier::ProcessQueue(uint32_t mask, void *params) } // Take handler semaphore while holding queue semaphore to make sure // the handler will execute to completion in case we are being deleted. - takeSemaphore(current->m_handlerSemaphore, SEMAPHORE_WAIT_FOREVER); + takeSemaphore(current->m_handlerSemaphore); } current->m_handler(current->m_param); // call the event handler diff --git a/wpilibc/src/main/native/PIDController.cpp b/wpilibc/src/main/native/PIDController.cpp index 0c958e58d2..b79fb7a1d0 100644 --- a/wpilibc/src/main/native/PIDController.cpp +++ b/wpilibc/src/main/native/PIDController.cpp @@ -5,7 +5,7 @@ /*----------------------------------------------------------------------------*/ #include "PIDController.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Notifier.h" #include "PIDSource.h" #include "PIDOutput.h" @@ -63,7 +63,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf, { m_table = NULL; - m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY); + m_semaphore = initializeMutexNormal(); m_controlLoop = new Notifier(PIDController::CallCalculate, this); @@ -96,7 +96,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf, static int32_t instances = 0; instances++; - nUsageReporting::report(nUsageReporting::kResourceType_PIDController, instances); + HALReport(HALUsageReporting::kResourceType_PIDController, instances); m_toleranceType = kNoTolerance; } @@ -106,7 +106,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf, */ PIDController::~PIDController() { - takeMutex(m_semaphore, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_semaphore); deleteMutex(m_semaphore); delete m_controlLoop; } diff --git a/wpilibc/src/main/native/PWM.cpp b/wpilibc/src/main/native/PWM.cpp index 45c499e9bd..cd22f4d4a3 100644 --- a/wpilibc/src/main/native/PWM.cpp +++ b/wpilibc/src/main/native/PWM.cpp @@ -7,7 +7,7 @@ #include "PWM.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "Utility.h" #include "WPIErrors.h" @@ -54,7 +54,7 @@ void PWM::InitPWM(uint8_t moduleNumber, uint32_t channel) m_module->SetPWM(m_channel, kPwmDisabled); m_eliminateDeadband = false; - nUsageReporting::report(nUsageReporting::kResourceType_PWM, channel, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_PWM, channel, moduleNumber - 1); } /** diff --git a/wpilibc/src/main/native/Preferences.cpp b/wpilibc/src/main/native/Preferences.cpp index ee4aa45349..f492f97216 100644 --- a/wpilibc/src/main/native/Preferences.cpp +++ b/wpilibc/src/main/native/Preferences.cpp @@ -6,7 +6,7 @@ #include "Preferences.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" @@ -36,22 +36,22 @@ Preferences::Preferences() : m_readTask("PreferencesReadTask", (FUNCPTR)Preferences::InitReadTask), m_writeTask("PreferencesWriteTask", (FUNCPTR)Preferences::InitWriteTask) { - m_fileLock = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE); - m_fileOpStarted = initializeSemaphore (SEMAPHORE_Q_PRIORITY, SEMAPHORE_EMPTY); - m_tableLock = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_INVERSION_SAFE | SEMAPHORE_DELETE_SAFE); + m_fileLock = initializeMutexNormal(); + m_fileOpStarted = initializeSemaphore (SEMAPHORE_EMPTY); + m_tableLock = initializeMutexNormal(); Synchronized sync(m_fileLock); m_readTask.Start((uint32_t)this); - takeSemaphore(m_fileOpStarted, SEMAPHORE_WAIT_FOREVER); + takeSemaphore(m_fileOpStarted); - nUsageReporting::report(nUsageReporting::kResourceType_Preferences, 0); + HALReport(HALUsageReporting::kResourceType_Preferences, 0); } Preferences::~Preferences() { - takeMutex(m_tableLock, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_tableLock); deleteMutex(m_tableLock); - takeMutex(m_fileLock, SEMAPHORE_WAIT_FOREVER); + takeMutex(m_fileLock); deleteSemaphore(m_fileOpStarted); deleteMutex(m_fileLock); } @@ -325,7 +325,7 @@ void Preferences::Save() { Synchronized sync(m_fileLock); m_writeTask.Start((uint32_t)this); - takeSemaphore(m_fileOpStarted, SEMAPHORE_WAIT_FOREVER); + takeSemaphore(m_fileOpStarted); } /** diff --git a/wpilibc/src/main/native/Relay.cpp b/wpilibc/src/main/native/Relay.cpp index 904e8f7beb..4ada65586f 100644 --- a/wpilibc/src/main/native/Relay.cpp +++ b/wpilibc/src/main/native/Relay.cpp @@ -7,7 +7,7 @@ #include "Relay.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Resource.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -50,7 +50,7 @@ void Relay::InitRelay (uint8_t moduleNumber) return; } - nUsageReporting::report(nUsageReporting::kResourceType_Relay, m_channel, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_Relay, m_channel, moduleNumber - 1); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { @@ -61,7 +61,7 @@ void Relay::InitRelay (uint8_t moduleNumber) return; } - nUsageReporting::report(nUsageReporting::kResourceType_Relay, m_channel + 128, moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_Relay, m_channel + 128, moduleNumber - 1); } m_module = DigitalModule::GetInstance(moduleNumber); m_module->SetRelayForward(m_channel, false); diff --git a/wpilibc/src/main/native/RobotBase.cpp b/wpilibc/src/main/native/RobotBase.cpp index b405eaef37..f3f3eaeeb4 100644 --- a/wpilibc/src/main/native/RobotBase.cpp +++ b/wpilibc/src/main/native/RobotBase.cpp @@ -7,9 +7,9 @@ #include "RobotBase.h" #include "DriverStation.h" -#include "NetworkCommunication/FRCComm.h" -#include "NetworkCommunication/symModuleLink.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/symModuleLink.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Utility.h" #include #include "HAL/HAL.h" @@ -192,10 +192,10 @@ void RobotBase::startRobotTask(FUNCPTR factory) #endif // Let the framework know that we are starting a new user program so the Driver Station can disable. - FRC_NetworkCommunication_observeUserProgramStarting(); + HALNetworkCommunicationObserveUserProgramStarting(); // Let the Usage Reporting framework know that there is a C++ program running - nUsageReporting::report(nUsageReporting::kResourceType_Language, nUsageReporting::kLanguage_CPlusPlus); + HALReport(HALUsageReporting::kResourceType_Language, HALUsageReporting::kLanguage_CPlusPlus); // Start robot task // This is done to ensure that the C++ robot task is spawned with the floating point diff --git a/wpilibc/src/main/native/RobotDrive.cpp b/wpilibc/src/main/native/RobotDrive.cpp index 4edc7d7888..9b4f97f6a3 100644 --- a/wpilibc/src/main/native/RobotDrive.cpp +++ b/wpilibc/src/main/native/RobotDrive.cpp @@ -10,7 +10,7 @@ #include "GenericHID.h" #include "Joystick.h" #include "Jaguar.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Utility.h" #include "WPIErrors.h" #include @@ -204,7 +204,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve) static bool reported = false; if (!reported) { - nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_ArcadeRatioCurve); + HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_ArcadeRatioCurve); reported = true; } @@ -292,7 +292,7 @@ void RobotDrive::TankDrive(float leftValue, float rightValue, bool squaredInputs static bool reported = false; if (!reported) { - nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_Tank); + HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_Tank); reported = true; } @@ -405,7 +405,7 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue, bool squaredInp static bool reported = false; if (!reported) { - nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_ArcadeStandard); + HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_ArcadeStandard); reported = true; } @@ -487,7 +487,7 @@ void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation, float static bool reported = false; if (!reported) { - nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_MecanumCartesian); + HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_MecanumCartesian); reported = true; } @@ -536,7 +536,7 @@ void RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rota static bool reported = false; if (!reported) { - nUsageReporting::report(nUsageReporting::kResourceType_RobotDrive, GetNumMotors(), nUsageReporting::kRobotDrive_MecanumPolar); + HALReport(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(), HALUsageReporting::kRobotDrive_MecanumPolar); reported = true; } diff --git a/wpilibc/src/main/native/SPI.cpp b/wpilibc/src/main/native/SPI.cpp index 6e1b7ebbeb..1f802f2244 100644 --- a/wpilibc/src/main/native/SPI.cpp +++ b/wpilibc/src/main/native/SPI.cpp @@ -9,7 +9,7 @@ #include "DigitalModule.h" #include "DigitalInput.h" #include "DigitalOutput.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "HAL/cpp/Synchronized.h" #include "WPIErrors.h" @@ -122,7 +122,7 @@ void SPI::Init(DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *miso) static int32_t instances = 0; instances++; - nUsageReporting::report(nUsageReporting::kResourceType_SPI, instances); + HALReport(HALUsageReporting::kResourceType_SPI, instances); } /** diff --git a/wpilibc/src/main/native/SerialPort.cpp b/wpilibc/src/main/native/SerialPort.cpp index 6f8ee54c78..037b18c014 100644 --- a/wpilibc/src/main/native/SerialPort.cpp +++ b/wpilibc/src/main/native/SerialPort.cpp @@ -6,7 +6,7 @@ #include "SerialPort.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "visa/visa.h" #include @@ -57,7 +57,7 @@ SerialPort::SerialPort(uint32_t baudRate, uint8_t dataBits, SerialPort::Parity p //viInstallHandler(m_portHandle, VI_EVENT_IO_COMPLETION, ioCompleteHandler, this); //viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_NULL); - nUsageReporting::report(nUsageReporting::kResourceType_SerialPort, 0); + HALReport(HALUsageReporting::kResourceType_SerialPort, 0); } /** diff --git a/wpilibc/src/main/native/Servo.cpp b/wpilibc/src/main/native/Servo.cpp index ce6ebaed1e..53a66251e7 100644 --- a/wpilibc/src/main/native/Servo.cpp +++ b/wpilibc/src/main/native/Servo.cpp @@ -6,7 +6,7 @@ #include "Servo.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "LiveWindow/LiveWindow.h" constexpr float Servo::kMaxServoAngle; @@ -25,7 +25,7 @@ void Servo::InitServo() SetPeriodMultiplier(kPeriodMultiplier_4X); LiveWindow::GetInstance()->AddActuator("Servo", GetModuleNumber(), GetChannel(), this); - nUsageReporting::report(nUsageReporting::kResourceType_Servo, GetChannel(), GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_Servo, GetChannel(), GetModuleNumber() - 1); } /** diff --git a/wpilibc/src/main/native/SimpleRobot.cpp b/wpilibc/src/main/native/SimpleRobot.cpp index deabcdfe32..5b0ff4a8dd 100644 --- a/wpilibc/src/main/native/SimpleRobot.cpp +++ b/wpilibc/src/main/native/SimpleRobot.cpp @@ -7,7 +7,7 @@ #include "SimpleRobot.h" #include "DriverStation.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Timer.h" #include "SmartDashboard/SmartDashboard.h" #include "LiveWindow/LiveWindow.h" @@ -100,7 +100,7 @@ void SimpleRobot::StartCompetition() { LiveWindow *lw = LiveWindow::GetInstance(); - nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Simple); + HALReport(HALUsageReporting::kResourceType_Framework, HALUsageReporting::kFramework_Simple); SmartDashboard::init(); NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false); diff --git a/wpilibc/src/main/native/SmartDashboard/SmartDashboard.cpp b/wpilibc/src/main/native/SmartDashboard/SmartDashboard.cpp index 51a0ecf56b..a5b40c582e 100644 --- a/wpilibc/src/main/native/SmartDashboard/SmartDashboard.cpp +++ b/wpilibc/src/main/native/SmartDashboard/SmartDashboard.cpp @@ -6,7 +6,7 @@ #include "SmartDashboard/SmartDashboard.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "SmartDashboard/NamedSendable.h" #include "WPIErrors.h" #include "networktables/NetworkTable.h" diff --git a/wpilibc/src/main/native/Solenoid.cpp b/wpilibc/src/main/native/Solenoid.cpp index 79e2bf8a39..f02551ec6f 100644 --- a/wpilibc/src/main/native/Solenoid.cpp +++ b/wpilibc/src/main/native/Solenoid.cpp @@ -5,7 +5,7 @@ /*----------------------------------------------------------------------------*/ #include "Solenoid.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" @@ -38,7 +38,7 @@ void Solenoid::InitSolenoid() } LiveWindow::GetInstance()->AddActuator("Solenoid", m_moduleNumber, m_channel, this); - nUsageReporting::report(nUsageReporting::kResourceType_Solenoid, m_channel, m_moduleNumber - 1); + HALReport(HALUsageReporting::kResourceType_Solenoid, m_channel, m_moduleNumber - 1); } /** diff --git a/wpilibc/src/main/native/Talon.cpp b/wpilibc/src/main/native/Talon.cpp index b1081d4b13..e00fad7508 100644 --- a/wpilibc/src/main/native/Talon.cpp +++ b/wpilibc/src/main/native/Talon.cpp @@ -7,7 +7,7 @@ #include "Talon.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "LiveWindow/LiveWindow.h" /** @@ -29,7 +29,7 @@ void Talon::InitTalon() { SetPeriodMultiplier(kPeriodMultiplier_2X); SetRaw(m_centerPwm); - nUsageReporting::report(nUsageReporting::kResourceType_Talon, GetChannel(), GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_Talon, GetChannel(), GetModuleNumber() - 1); LiveWindow::GetInstance()->AddActuator("Talon", GetModuleNumber(), GetChannel(), this); } diff --git a/wpilibc/src/main/native/Task.cpp b/wpilibc/src/main/native/Task.cpp index 3e871f6907..2c794e8e7c 100644 --- a/wpilibc/src/main/native/Task.cpp +++ b/wpilibc/src/main/native/Task.cpp @@ -6,7 +6,7 @@ #include "Task.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "WPIErrors.h" #include #include @@ -33,7 +33,7 @@ Task::Task(const char* name, FUNCPTR function, int32_t priority, uint32_t stackS static int32_t instances = 0; instances++; - nUsageReporting::report(nUsageReporting::kResourceType_Task, instances, 0, m_taskName); + HALReport(HALUsageReporting::kResourceType_Task, instances, 0, m_taskName); } Task::~Task() diff --git a/wpilibc/src/main/native/Timer.cpp b/wpilibc/src/main/native/Timer.cpp index a0493926aa..1a4504e315 100644 --- a/wpilibc/src/main/native/Timer.cpp +++ b/wpilibc/src/main/native/Timer.cpp @@ -65,7 +65,7 @@ Timer::Timer() { //Creates a semaphore to control access to critical regions. //Initially 'open' - m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + m_semaphore = initializeMutexNormal(); Reset(); } diff --git a/wpilibc/src/main/native/Ultrasonic.cpp b/wpilibc/src/main/native/Ultrasonic.cpp index 03b365aa28..3a041a43a7 100644 --- a/wpilibc/src/main/native/Ultrasonic.cpp +++ b/wpilibc/src/main/native/Ultrasonic.cpp @@ -9,7 +9,7 @@ #include "Counter.h" #include "DigitalInput.h" #include "DigitalOutput.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "Timer.h" #include "Utility.h" #include "WPIErrors.h" @@ -58,9 +58,9 @@ void Ultrasonic::Initialize() { m_table = NULL; bool originalMode = m_automaticEnabled; - if (m_semaphore == 0) m_semaphore = initializeSemaphore(SEMAPHORE_Q_PRIORITY, SEMAPHORE_FULL); + if (m_semaphore == 0) m_semaphore = initializeSemaphore(SEMAPHORE_FULL); SetAutomaticMode(false); // kill task when adding a new sensor - takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER); // link this instance on the list + takeSemaphore(m_semaphore); // link this instance on the list { m_nextSensor = m_firstSensor; m_firstSensor = this; @@ -77,7 +77,7 @@ void Ultrasonic::Initialize() static int instances = 0; instances++; - nUsageReporting::report(nUsageReporting::kResourceType_Ultrasonic, instances); + HALReport(HALUsageReporting::kResourceType_Ultrasonic, instances); LiveWindow::GetInstance()->AddSensor("Ultrasonic", m_echoChannel->GetModuleForRouting(), m_echoChannel->GetChannel(), this); } @@ -176,7 +176,7 @@ Ultrasonic::~Ultrasonic() } wpi_assert(m_firstSensor != NULL); - takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER); + takeSemaphore(m_semaphore); { if (this == m_firstSensor) { diff --git a/wpilibc/src/main/native/Utility.cpp b/wpilibc/src/main/native/Utility.cpp index 49c51f4301..25f5595c59 100644 --- a/wpilibc/src/main/native/Utility.cpp +++ b/wpilibc/src/main/native/Utility.cpp @@ -6,7 +6,7 @@ #include "Utility.h" -#include "NetworkCommunication/FRCComm.h" +//#include "NetworkCommunication/FRCComm.h" #include "HAL/HAL.h" #include "HAL/cpp/StackTrace.h" #include "Task.h" @@ -75,7 +75,7 @@ bool wpi_assert_impl(bool conditionValue, // Print to console and send to remote dashboard printf("\n\n>>>>%s", error); - setErrorData(error, strlen(error), 100); + HALSetErrorData(error, strlen(error), 100); wpi_handleTracing(); if (suspendOnAssertEnabled) suspendTask(0); @@ -111,7 +111,7 @@ void wpi_assertEqual_common_impl(int valueA, // Print to console and send to remote dashboard printf("\n\n>>>>%s", error); - setErrorData(error, strlen(error), 100); + HALSetErrorData(error, strlen(error), 100); wpi_handleTracing(); if (suspendOnAssertEnabled) suspendTask(0); diff --git a/wpilibc/src/main/native/Victor.cpp b/wpilibc/src/main/native/Victor.cpp index c8a0565aca..36478ae6c0 100644 --- a/wpilibc/src/main/native/Victor.cpp +++ b/wpilibc/src/main/native/Victor.cpp @@ -7,7 +7,7 @@ #include "Victor.h" #include "DigitalModule.h" -#include "NetworkCommunication/UsageReporting.h" +//#include "NetworkCommunication/UsageReporting.h" #include "LiveWindow/LiveWindow.h" /** @@ -32,7 +32,7 @@ void Victor::InitVictor() { SetRaw(m_centerPwm); LiveWindow::GetInstance()->AddActuator("Victor", GetModuleNumber(), GetChannel(), this); - nUsageReporting::report(nUsageReporting::kResourceType_Victor, GetChannel(), GetModuleNumber() - 1); + HALReport(HALUsageReporting::kResourceType_Victor, GetChannel(), GetModuleNumber() - 1); } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java index 62707683d2..6f76468e0f 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java @@ -6,8 +6,8 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Accelerometer.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Accelerometer.java index b0ca934d57..cbe5b27e78 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Accelerometer.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Accelerometer.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogChannel.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogChannel.java index e089c99752..78c56e7000 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogChannel.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogChannel.java @@ -6,14 +6,17 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; +import java.nio.ByteOrder; import java.nio.IntBuffer; import java.nio.LongBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; +//import com.sun.jna.Pointer; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; + +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.AnalogJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; @@ -42,7 +45,7 @@ public class AnalogChannel extends SensorBase implements PIDSource, private static final int kAccumulatorSlot = 1; private static Resource channels = new Resource(kAnalogModules * kAnalogChannels); - private Pointer m_port; + private ByteBuffer m_port; private int m_moduleNumber, m_channel; private static final int[] kAccumulatorChannels = { 1, 2 }; private long m_accumulatorOffset; @@ -66,39 +69,38 @@ public class AnalogChannel extends SensorBase implements PIDSource, * The channel number to represent. */ public AnalogChannel(final int moduleNumber, final int channel) { - System.out.println("Module Number: " + moduleNumber + " Channel: " - + channel); - System.out.println(Thread.currentThread().getStackTrace()); m_channel = channel; m_moduleNumber = moduleNumber; - if (HALLibrary.checkAnalogModule((byte) moduleNumber) == 0) { + if (AnalogJNI.checkAnalogModule((byte)moduleNumber) == 0) { throw new AllocationException("Analog channel " + m_channel + " on module " + m_moduleNumber + " cannot be allocated. Module is not present."); } - if (HALLibrary.checkAnalogChannel(channel) == 0) { + if (AnalogJNI.checkAnalogChannel(channel) == 0) { throw new AllocationException("Analog channel " + m_channel + " on module " + m_moduleNumber + " cannot be allocated. Channel is not present."); } try { - channels.allocate((moduleNumber - 1) * kAnalogChannels + m_channel + channels.allocate((moduleNumber - 1) * kAnalogChannels + channel - 1); } catch (CheckedAllocationException e) { throw new AllocationException("Analog channel " + m_channel + " on module " + m_moduleNumber + " is already allocated"); } - Pointer port_pointer = HALLibrary.getPortWithModule( + ByteBuffer port_pointer = AnalogJNI.getPortWithModule( (byte) moduleNumber, (byte) channel); - IntBuffer status = IntBuffer.allocate(1); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); // XXX: Uncomment when Analog has been fixed - m_port = HALLibrary.initializeAnalogPort(port_pointer, status); - HALUtil.checkStatus(status); + m_port = AnalogJNI.initializeAnalogPort(port_pointer, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); LiveWindow.addSensor("Analog", moduleNumber, channel, this); UsageReporting.report(tResourceType.kResourceType_AnalogChannel, - channel, m_moduleNumber - 1); + channel, moduleNumber - 1); } /** @@ -129,9 +131,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return A sample straight from this channel on the module. */ public int getValue() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogValue(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogValue(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -147,9 +151,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return A sample from the oversample and average engine for this channel. */ public int getAverageValue() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogAverageValue(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogAverageValue(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -161,9 +167,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return A scaled sample straight from this channel on the module. */ public double getVoltage() { - IntBuffer status = IntBuffer.allocate(1); - double value = Float.intBitsToFloat(HALLibrary.getAnalogVoltageIntHack(m_port, status)); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + double value = AnalogJNI.getAnalogVoltage(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -179,9 +187,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * engine for this channel. */ public double getAverageVoltage() { - IntBuffer status = IntBuffer.allocate(1); - double value = Float.intBitsToFloat(HALLibrary.getAnalogAverageVoltageIntHack(m_port, status)); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + double value = AnalogJNI.getAnalogAverageVoltage(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -195,9 +205,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return Least significant bit weight. */ public long getLSBWeight() { - IntBuffer status = IntBuffer.allocate(1); - long value = HALLibrary.getAnalogLSBWeight(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + long value = AnalogJNI.getAnalogLSBWeight(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -211,9 +223,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return Offset constant. */ public int getOffset() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogOffset(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogOffset(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -244,9 +258,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * The number of averaging bits. */ public void setAverageBits(final int bits) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogAverageBits(m_port, bits, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAnalogAverageBits(m_port, bits, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -257,9 +273,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return The number of averaging bits. */ public int getAverageBits() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogAverageBits(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogAverageBits(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -272,9 +290,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * The number of oversample bits. */ public void setOversampleBits(final int bits) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogOversampleBits(m_port, bits, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAnalogOversampleBits(m_port, bits, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -285,9 +305,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return The number of oversample bits. */ public int getOversampleBits() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogOversampleBits(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogOversampleBits(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -303,9 +325,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, + kAccumulatorChannels[1]); } m_accumulatorOffset = 0; - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.initAccumulator(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.initAccumulator(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -324,9 +348,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * Resets the accumulator to the initial value. */ public void resetAccumulator() { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.resetAccumulator(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.resetAccumulator(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -342,18 +368,22 @@ public class AnalogChannel extends SensorBase implements PIDSource, * affect the size of the value for this field. */ public void setAccumulatorCenter(int center) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAccumulatorCenter(m_port, center, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAccumulatorCenter(m_port, center, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** * Set the accumulator's deadband. */ public void setAccumulatorDeadband(int deadband) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAccumulatorDeadband(m_port, deadband, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAccumulatorDeadband(m_port, deadband, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -365,9 +395,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return The 64-bit value accumulated since the last Reset(). */ public long getAccumulatorValue() { - IntBuffer status = IntBuffer.allocate(1); - long value = HALLibrary.getAccumulatorValue(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + long value = AnalogJNI.getAccumulatorValue(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value + m_accumulatorOffset; } @@ -380,9 +412,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, * @return The number of times samples from the channel were accumulated. */ public long getAccumulatorCount() { - IntBuffer status = IntBuffer.allocate(1); - long value = HALLibrary.getAccumulatorCount(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + long value = AnalogJNI.getAccumulatorCount(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -405,13 +439,19 @@ public class AnalogChannel extends SensorBase implements PIDSource, + " on module " + m_moduleNumber + " is not an accumulator channel."); } - LongBuffer value = LongBuffer.allocate(1); - IntBuffer count = IntBuffer.allocate(1); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.getAccumulatorOutput(m_port, value, count, status); - result.value = value.get(0) + m_accumulatorOffset; - result.count = count.get(0); - HALUtil.checkStatus(status); + ByteBuffer value = ByteBuffer.allocateDirect(8); + // set the byte order + value.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer count = ByteBuffer.allocateDirect(4); + // set the byte order + count.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.getAccumulatorOutput(m_port, value.asLongBuffer(), count.asIntBuffer(), status.asIntBuffer()); + result.value = value.asLongBuffer().get(0) + m_accumulatorOffset; + result.count = count.asIntBuffer().get(0); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -434,9 +474,11 @@ public class AnalogChannel extends SensorBase implements PIDSource, public void setSampleRate(final double samplesPerSecond) { // TODO: This will change when variable size scan lists are implemented. // TODO: Need float comparison with epsilon. - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogSampleRate((float) samplesPerSecond, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAnalogSampleRate((float) samplesPerSecond, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogModule.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogModule.java index b5e6aaf21e..24c61fcb04 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogModule.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogModule.java @@ -7,12 +7,11 @@ package edu.wpi.first.wpilibj; -import java.nio.IntBuffer; +import java.nio.ByteOrder; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tModuleType; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tModuleType; +import edu.wpi.first.wpilibj.hal.AnalogJNI; import edu.wpi.first.wpilibj.hal.HALUtil; /** @@ -40,7 +39,7 @@ public class AnalogModule extends Module { * The default sample rate */ public static final double kDefaultSampleRate = 50000.0; - private Pointer[] m_ports; + private ByteBuffer[] m_ports; /** * Get an instance of an Analog Module. @@ -70,13 +69,15 @@ public class AnalogModule extends Module { protected AnalogModule(final int moduleNumber) { super(tModuleType.kModuleType_Analog, moduleNumber); - m_ports = new Pointer[8]; + m_ports = new ByteBuffer[8]; for (int i = 0; i < SensorBase.kAnalogChannels; i++) { - Pointer port_pointer = HALLibrary.getPortWithModule((byte) moduleNumber, (byte) (i+1)); - IntBuffer status = IntBuffer.allocate(1); + ByteBuffer port_pointer = AnalogJNI.getPortWithModule((byte) moduleNumber, (byte) (i+1)); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); // XXX: Uncomment when analogchannel has been fixed // m_ports[i] = HALLibrary.initializeAnalogPort(port_pointer, status); - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -91,9 +92,11 @@ public class AnalogModule extends Module { public void setSampleRate(final double samplesPerSecond) { // TODO: This will change when variable size scan lists are implemented. // TODO: Need float comparison with epsilon. - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogSampleRateWithModule((byte) m_moduleNumber, (float) samplesPerSecond, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAnalogSampleRateWithModule((byte) m_moduleNumber, (float) samplesPerSecond, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -105,9 +108,11 @@ public class AnalogModule extends Module { * @return Sample rate. */ public double getSampleRate() { - IntBuffer status = IntBuffer.allocate(1); - double value = HALLibrary.getAnalogSampleRateWithModule((byte) m_moduleNumber, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + double value = AnalogJNI.getAnalogSampleRateWithModule((byte) m_moduleNumber, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -123,9 +128,11 @@ public class AnalogModule extends Module { * Number of bits to average. */ public void setAverageBits(final int channel, final int bits) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogAverageBits(m_ports[channel], bits, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAnalogAverageBits(m_ports[channel], bits, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -139,9 +146,11 @@ public class AnalogModule extends Module { * @return Bits to average. */ public int getAverageBits(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogAverageBits(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogAverageBits(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -156,9 +165,11 @@ public class AnalogModule extends Module { * @param bits Number of bits to oversample. */ public void setOversampleBits(final int channel, final int bits) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogOversampleBits(m_ports[channel], bits, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + AnalogJNI.setAnalogOversampleBits(m_ports[channel], bits, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -172,9 +183,11 @@ public class AnalogModule extends Module { * @return Bits to oversample. */ public int getOversampleBits(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogOversampleBits(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogOversampleBits(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -187,9 +200,11 @@ public class AnalogModule extends Module { * @return Raw value. */ public int getValue(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogValue(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogValue(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -200,9 +215,11 @@ public class AnalogModule extends Module { * @return The averaged and oversampled raw value. */ public int getAverageValue(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogAverageValue(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogAverageValue(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -222,9 +239,11 @@ public class AnalogModule extends Module { */ public int voltsToValue(final int channel, final double voltage) { // wpi_assert(voltage >= -10.0 && voltage <= 10.0); - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogVoltsToValue(m_ports[channel], (float) voltage, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocate(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogVoltsToValue(m_ports[channel], (float) voltage, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -237,9 +256,11 @@ public class AnalogModule extends Module { * @return The scaled voltage from the channel. */ public double getVoltage(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - double value = HALLibrary.getAnalogVoltage(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + double value = AnalogJNI.getAnalogVoltage(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -252,9 +273,11 @@ public class AnalogModule extends Module { * @return The scaled averaged and oversampled voltage from the channel. */ public double getAverageVoltage(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - double value = HALLibrary.getAnalogAverageVoltage(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + double value = AnalogJNI.getAnalogAverageVoltage(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -266,9 +289,11 @@ public class AnalogModule extends Module { */ public long getLSBWeight(final int channel) { // TODO: add scaling to make this worth while. - IntBuffer status = IntBuffer.allocate(1); - long value = HALLibrary.getAnalogLSBWeight(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + long value = AnalogJNI.getAnalogLSBWeight(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -281,9 +306,11 @@ public class AnalogModule extends Module { public int getOffset(final int channel) { // TODO: add scaling to make this worth while. // TODO: actually use this function. - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getAnalogOffset(m_ports[channel], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = AnalogJNI.getAnalogOffset(m_ports[channel], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java index b269a6b950..77204381f8 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java @@ -8,12 +8,13 @@ package edu.wpi.first.wpilibj; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; +//import com.sun.jna.Pointer; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.AnalogJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.parsing.IInputOutput; import edu.wpi.first.wpilibj.util.BoundaryException; @@ -45,7 +46,7 @@ public class AnalogTrigger implements IInputOutput { /** * Where the analog trigger is attached */ - protected Pointer m_port; + protected ByteBuffer m_port; protected int m_index; /** @@ -59,7 +60,7 @@ public class AnalogTrigger implements IInputOutput { * the port to use for the analog trigger */ protected void initTrigger(final int moduleNumber, final int channel) { - Pointer port_pointer = HALLibrary.getPortWithModule( + ByteBuffer port_pointer = AnalogJNI.getPortWithModule( (byte) moduleNumber, (byte) channel); IntBuffer status = IntBuffer.allocate(1); IntBuffer index = IntBuffer.allocate(1); @@ -114,7 +115,7 @@ public class AnalogTrigger implements IInputOutput { */ public void free() { IntBuffer status = IntBuffer.allocate(1); - HALLibrary.cleanAnalogTrigger(m_port, status); + AnalogJNI.cleanAnalogTrigger(m_port, status); HALUtil.checkStatus(status); m_port = null; } @@ -134,7 +135,7 @@ public class AnalogTrigger implements IInputOutput { throw new BoundaryException("Lower bound is greater than upper"); } IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogTriggerLimitsRaw(m_port, lower, upper, status); + AnalogJNI.setAnalogTriggerLimitsRaw(m_port, lower, upper, status); HALUtil.checkStatus(status); } @@ -155,7 +156,7 @@ public class AnalogTrigger implements IInputOutput { // TODO: This depends on the averaged setting. Only raw values will work // as is. IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogTriggerLimitsVoltage(m_port, (float) lower, + AnalogJNI.setAnalogTriggerLimitsVoltage(m_port, (float) lower, (float) upper, status); HALUtil.checkStatus(status); } @@ -170,7 +171,7 @@ public class AnalogTrigger implements IInputOutput { */ public void setAveraged(boolean useAveragedValue) { IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogTriggerAveraged(m_port, + AnalogJNI.setAnalogTriggerAveraged(m_port, (byte) (useAveragedValue ? 1 : 0), status); HALUtil.checkStatus(status); } @@ -186,7 +187,7 @@ public class AnalogTrigger implements IInputOutput { */ public void setFiltered(boolean useFilteredValue) { IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setAnalogTriggerFiltered(m_port, + AnalogJNI.setAnalogTriggerFiltered(m_port, (byte) (useFilteredValue ? 1 : 0), status); HALUtil.checkStatus(status); } @@ -209,7 +210,7 @@ public class AnalogTrigger implements IInputOutput { */ public boolean getInWindow() { IntBuffer status = IntBuffer.allocate(1); - byte value = HALLibrary.getAnalogTriggerInWindow(m_port, status); + byte value = AnalogJNI.getAnalogTriggerInWindow(m_port, status); HALUtil.checkStatus(status); return value != 0; } @@ -223,7 +224,7 @@ public class AnalogTrigger implements IInputOutput { */ public boolean getTriggerState() { IntBuffer status = IntBuffer.allocate(1); - byte value = HALLibrary.getAnalogTriggerTriggerState(m_port, status); + byte value = AnalogJNI.getAnalogTriggerTriggerState(m_port, status); HALUtil.checkStatus(status); return value != 0; } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java index eba2244662..6e4a30e5b4 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java @@ -8,10 +8,11 @@ package edu.wpi.first.wpilibj; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.AnalogJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.parsing.IInputOutput; @@ -99,7 +100,7 @@ public class AnalogTriggerOutput extends DigitalSource implements IInputOutput { */ public boolean get() { IntBuffer status = IntBuffer.allocate(1); - byte value = HALLibrary.getAnalogTriggerOutput(m_trigger.m_port, + byte value = AnalogJNI.getAnalogTriggerOutput(m_trigger.m_port, m_outputType, status); HALUtil.checkStatus(status); return value != 0; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java index 9cd85e26e0..024fb810fa 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java @@ -8,12 +8,14 @@ package edu.wpi.first.wpilibj; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.IntBuffer; +import edu.wpi.first.wpilibj.can.CANExceptionFactory; import edu.wpi.first.wpilibj.can.CANJaguarVersionException; -import edu.wpi.first.wpilibj.can.CANLibrary; +import edu.wpi.first.wpilibj.can.CANJNI; import edu.wpi.first.wpilibj.can.CANTimeoutException; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.hal.HALUtil; @@ -354,29 +356,29 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW switch (m_controlMode.value) { case ControlMode.kPercentVbus_val: - messageID = CANLibrary.LM_API_VOLT_T_SET; + messageID = CANJNI.LM_API_VOLT_T_SET; if (outputValue > 1.0) outputValue = 1.0; if (outputValue < -1.0) outputValue = -1.0; packPercentage(dataBuffer, outputValue); dataSize = 2; break; case ControlMode.kSpeed_val: { - messageID = CANLibrary.LM_API_SPD_T_SET; + messageID = CANJNI.LM_API_SPD_T_SET; dataSize = packFXP16_16(dataBuffer, outputValue); } break; case ControlMode.kPosition_val: { - messageID = CANLibrary.LM_API_POS_T_SET; + messageID = CANJNI.LM_API_POS_T_SET; dataSize = packFXP16_16(dataBuffer, outputValue); } break; case ControlMode.kCurrent_val: { - messageID = CANLibrary.LM_API_ICTRL_T_SET; + messageID = CANJNI.LM_API_ICTRL_T_SET; dataSize = packFXP8_8(dataBuffer, outputValue); } break; case ControlMode.kVoltage_val: { - messageID = CANLibrary.LM_API_VCOMP_T_SET; + messageID = CANJNI.LM_API_VCOMP_T_SET; dataSize = packFXP8_8(dataBuffer, outputValue); } break; @@ -424,31 +426,31 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW switch (m_controlMode.value) { case ControlMode.kPercentVbus_val: - dataSize = getTransaction(CANLibrary.LM_API_VOLT_SET, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_VOLT_SET, dataBuffer); if (dataSize == 2) { return unpackPercentage(dataBuffer); } break; case ControlMode.kSpeed_val: - dataSize = getTransaction(CANLibrary.LM_API_SPD_SET, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_SPD_SET, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kPosition_val: - dataSize = getTransaction(CANLibrary.LM_API_POS_SET, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_POS_SET, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kCurrent_val: - dataSize = getTransaction(CANLibrary.LM_API_ICTRL_SET, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_ICTRL_SET, dataBuffer); if (dataSize == 2) { return unpackFXP8_8(dataBuffer); } break; case ControlMode.kVoltage_val: - dataSize = getTransaction(CANLibrary.LM_API_VCOMP_SET, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_VCOMP_SET, dataBuffer); if (dataSize == 2) { return unpackFXP8_8(dataBuffer); } @@ -548,7 +550,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW long unpackINT32(byte[] buffer) { return unpack32(buffer,0); } - private static final byte[] sendTrustedDataBuffer = new byte[kMaxMessageDataSize]; + private static final ByteBuffer sendTrustedDataBuffer = ByteBuffer.allocateDirect(kMaxMessageDataSize); /** * Send a message on the CAN bus through the CAN driver in FRC_NetworkCommunication @@ -562,33 +564,58 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW */ protected static void sendMessage(int messageID, byte[] data, int dataSize) throws CANTimeoutException { final int[] kTrustedMessages = { - CANLibrary.LM_API_VOLT_T_EN, CANLibrary.LM_API_VOLT_T_SET, - CANLibrary.LM_API_SPD_T_EN, CANLibrary.LM_API_SPD_T_SET, - CANLibrary.LM_API_VCOMP_T_EN, CANLibrary.LM_API_VCOMP_T_SET, - CANLibrary.LM_API_POS_T_EN, CANLibrary.LM_API_POS_T_SET, - CANLibrary.LM_API_ICTRL_T_EN, CANLibrary.LM_API_ICTRL_T_SET + CANJNI.LM_API_VOLT_T_EN, CANJNI.LM_API_VOLT_T_SET, + CANJNI.LM_API_SPD_T_EN, CANJNI.LM_API_SPD_T_SET, + CANJNI.LM_API_VCOMP_T_EN, CANJNI.LM_API_VCOMP_T_SET, + CANJNI.LM_API_POS_T_EN, CANJNI.LM_API_POS_T_SET, + CANJNI.LM_API_ICTRL_T_EN, CANJNI.LM_API_ICTRL_T_SET }; byte i; for (i = 0; i < kTrustedMessages.length; i++) { - if ((kFullMessageIDMask & messageID) == kTrustedMessages[i]) { - sendTrustedDataBuffer[0] = 0; - sendTrustedDataBuffer[1] = 0; + if ((kFullMessageIDMask & messageID) == kTrustedMessages[i]) + { // Make sure the data will still fit after adjusting for the token. if (dataSize > kMaxMessageDataSize - 2) { throw new RuntimeException("CAN message has too much data."); } + ByteBuffer trustedBuffer = ByteBuffer.allocateDirect(dataSize+2); + trustedBuffer.put(0, (byte)0); + trustedBuffer.put(1, (byte)0); + byte j; for (j = 0; j < dataSize; j++) { - sendTrustedDataBuffer[j + 2] = data[j]; + trustedBuffer.put(j+2, data[j]); } - CANLibrary.FRC_NetworkCommunication_JaguarCANDriver_sendMessage(messageID, sendTrustedDataBuffer, (byte) sendTrustedDataBuffer.length, IntBuffer.wrap(new int[]{dataSize + 2})); + + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + status.asIntBuffer().put(0,dataSize+2); + + + CANJNI.FRCNetworkCommunicationJaguarCANDriverSendMessage(messageID, trustedBuffer, status.asIntBuffer()); return; } } - CANLibrary.FRC_NetworkCommunication_JaguarCANDriver_sendMessage(messageID, data, (byte) data.length, IntBuffer.wrap(new int[]{dataSize})); + + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + status.asIntBuffer().put(0,dataSize); + + ByteBuffer dataBuffer = null; + if( dataSize > 0) + { + dataBuffer = ByteBuffer.allocateDirect(dataSize); + dataBuffer.put(data); + } + + CANJNI.FRCNetworkCommunicationJaguarCANDriverSendMessage(messageID, dataBuffer, status.asIntBuffer()); + + CANExceptionFactory.checkStatus(status.asIntBuffer().get(0), messageID); } /** @@ -599,17 +626,36 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW * @param timeout Specify how long to wait for a message (in seconds) */ protected static byte receiveMessage(int messageID, byte[] data, double timeout) throws CANTimeoutException { - IntBuffer status = IntBuffer.allocate(1); - ByteBuffer dataSize = ByteBuffer.wrap(new byte[]{(byte) data.length}); - CANLibrary.FRC_NetworkCommunication_JaguarCANDriver_receiveMessage( - IntBuffer.wrap(new int[]{messageID}), ByteBuffer.wrap(data), - dataSize, (int) timeout, status); - HALUtil.checkStatus(status); - return dataSize.get(); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer messageIDBuffer = ByteBuffer.allocateDirect(4); + messageIDBuffer.order(ByteOrder.LITTLE_ENDIAN); + messageIDBuffer.asIntBuffer().put(0,messageID); + + ByteBuffer dataBuffer = CANJNI.FRCNetworkCommunicationJaguarCANDriverReceiveMessage( + messageIDBuffer.asIntBuffer(), (int) (timeout*1000), status.asIntBuffer()); + + CANExceptionFactory.checkStatus(status.asIntBuffer().get(0), messageID); + + byte returnValue = 0; + + if( dataBuffer != null ) + { + returnValue = (byte)dataBuffer.capacity(); + for(int index = 0; index < returnValue; index++) + { + data[index] = dataBuffer.get(index); + } + } + + return returnValue; } protected static byte receiveMessage(int messageID, byte[] data) throws CANTimeoutException { - return receiveMessage(messageID, data, 0.01); + //return receiveMessage(messageID, data, 0.01); + return receiveMessage(messageID, data, 0.1); } /** @@ -623,7 +669,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW * @param dataSize Specify how much of the data in "data" to send */ protected byte setTransaction(int messageID, byte[] data, byte dataSize) throws CANTimeoutException { - int ackMessageID = CANLibrary.LM_API_ACK | m_deviceNumber; + int ackMessageID = CANJNI.LM_API_ACK | m_deviceNumber; // Make sure we don't have more than one transaction with the same Jaguar outstanding. synchronized (m_transactionMutex) { @@ -674,7 +720,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; dataBuffer[0] = reference.value; - setTransaction(CANLibrary.LM_API_SPD_REF, dataBuffer, (byte) 1); + setTransaction(CANJNI.LM_API_SPD_REF, dataBuffer, (byte) 1); } /** @@ -686,7 +732,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize = 0; - dataSize = getTransaction(CANLibrary.LM_API_SPD_REF, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_SPD_REF, dataBuffer); if (dataSize == 1) { switch (dataBuffer[0]) { case SpeedReference.kEncoder_val: @@ -714,7 +760,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; dataBuffer[0] = reference.value; - setTransaction(CANLibrary.LM_API_POS_REF, dataBuffer, (byte) 1); + setTransaction(CANJNI.LM_API_POS_REF, dataBuffer, (byte) 1); } /** @@ -726,7 +772,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize = 0; - dataSize = getTransaction(CANLibrary.LM_API_POS_REF, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_POS_REF, dataBuffer); if (dataSize == 1) { switch (dataBuffer[0]) { case PositionReference.kPotentiometer_val: @@ -758,27 +804,27 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW break; case ControlMode.kSpeed_val: dataSize = packFXP16_16(dataBuffer, p); - setTransaction(CANLibrary.LM_API_SPD_PC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_SPD_PC, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, i); - setTransaction(CANLibrary.LM_API_SPD_IC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_SPD_IC, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, d); - setTransaction(CANLibrary.LM_API_SPD_DC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_SPD_DC, dataBuffer, dataSize); break; case ControlMode.kPosition_val: dataSize = packFXP16_16(dataBuffer, p); - setTransaction(CANLibrary.LM_API_POS_PC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_POS_PC, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, i); - setTransaction(CANLibrary.LM_API_POS_IC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_POS_IC, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, d); - setTransaction(CANLibrary.LM_API_POS_DC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_POS_DC, dataBuffer, dataSize); break; case ControlMode.kCurrent_val: dataSize = packFXP16_16(dataBuffer, p); - setTransaction(CANLibrary.LM_API_ICTRL_PC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_ICTRL_PC, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, i); - setTransaction(CANLibrary.LM_API_ICTRL_IC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_ICTRL_IC, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, d); - setTransaction(CANLibrary.LM_API_ICTRL_DC, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_ICTRL_DC, dataBuffer, dataSize); break; } } @@ -798,19 +844,19 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW // TODO: Error, Not Valid break; case ControlMode.kSpeed_val: - dataSize = getTransaction(CANLibrary.LM_API_SPD_PC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_SPD_PC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kPosition_val: - dataSize = getTransaction(CANLibrary.LM_API_POS_PC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_POS_PC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kCurrent_val: - dataSize = getTransaction(CANLibrary.LM_API_ICTRL_PC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_ICTRL_PC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } @@ -834,19 +880,19 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW // TODO: Error, Not Valid break; case ControlMode.kSpeed_val: - dataSize = getTransaction(CANLibrary.LM_API_SPD_IC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_SPD_IC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kPosition_val: - dataSize = getTransaction(CANLibrary.LM_API_POS_IC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_POS_IC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kCurrent_val: - dataSize = getTransaction(CANLibrary.LM_API_ICTRL_IC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_ICTRL_IC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } @@ -870,19 +916,19 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW // TODO: Error, Not Valid break; case ControlMode.kSpeed_val: - dataSize = getTransaction(CANLibrary.LM_API_SPD_DC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_SPD_DC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kPosition_val: - dataSize = getTransaction(CANLibrary.LM_API_POS_DC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_POS_DC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } break; case ControlMode.kCurrent_val: - dataSize = getTransaction(CANLibrary.LM_API_ICTRL_DC, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_ICTRL_DC, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } @@ -915,20 +961,20 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW switch (m_controlMode.value) { case ControlMode.kPercentVbus_val: - setTransaction(CANLibrary.LM_API_VOLT_T_EN, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_VOLT_T_EN, dataBuffer, dataSize); break; case ControlMode.kSpeed_val: - setTransaction(CANLibrary.LM_API_SPD_T_EN, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_SPD_T_EN, dataBuffer, dataSize); break; case ControlMode.kPosition_val: dataSize = packFXP16_16(dataBuffer, encoderInitialPosition); - setTransaction(CANLibrary.LM_API_POS_T_EN, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_POS_T_EN, dataBuffer, dataSize); break; case ControlMode.kCurrent_val: - setTransaction(CANLibrary.LM_API_ICTRL_T_EN, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_ICTRL_T_EN, dataBuffer, dataSize); break; case ControlMode.kVoltage_val: - setTransaction(CANLibrary.LM_API_VCOMP_T_EN, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_VCOMP_T_EN, dataBuffer, dataSize); break; } } @@ -944,19 +990,19 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW switch (m_controlMode.value) { case ControlMode.kPercentVbus_val: - setTransaction(CANLibrary.LM_API_VOLT_DIS, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_VOLT_DIS, dataBuffer, dataSize); break; case ControlMode.kSpeed_val: - setTransaction(CANLibrary.LM_API_SPD_DIS, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_SPD_DIS, dataBuffer, dataSize); break; case ControlMode.kPosition_val: - setTransaction(CANLibrary.LM_API_POS_DIS, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_POS_DIS, dataBuffer, dataSize); break; case ControlMode.kCurrent_val: - setTransaction(CANLibrary.LM_API_ICTRL_DIS, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_ICTRL_DIS, dataBuffer, dataSize); break; case ControlMode.kVoltage_val: - setTransaction(CANLibrary.LM_API_VCOMP_DIS, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_VCOMP_DIS, dataBuffer, dataSize); break; } } @@ -991,7 +1037,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize = 0; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_CMODE, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_CMODE, dataBuffer); if (dataSize == 1) { switch (dataBuffer[0]) { case ControlMode.kPercentVbus_val: @@ -1018,7 +1064,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize = 0; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_VOLTBUS, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_VOLTBUS, dataBuffer); if (dataSize == 2) { return unpackFXP8_8(dataBuffer); } @@ -1035,7 +1081,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte dataSize = 0; // Read the volt out which is in Volts units. - dataSize = getTransaction(CANLibrary.LM_API_STATUS_VOUT, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_VOUT, dataBuffer); if (dataSize == 2) { return unpackFXP8_8(dataBuffer); } @@ -1051,7 +1097,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_CURRENT, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_CURRENT, dataBuffer); if (dataSize == 2) { return unpackFXP8_8(dataBuffer); } @@ -1068,7 +1114,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_TEMP, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_TEMP, dataBuffer); if (dataSize == 2) { return unpackFXP8_8(dataBuffer); } @@ -1084,7 +1130,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_POS, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_POS, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } @@ -1100,7 +1146,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_SPD, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_SPD, dataBuffer); if (dataSize == 4) { return unpackFXP16_16(dataBuffer); } @@ -1116,7 +1162,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_LIMIT, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_LIMIT, dataBuffer); if (dataSize == 1) { return (dataBuffer[0] & Limits.kForwardLimit_val) != 0; } @@ -1132,7 +1178,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_LIMIT, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_LIMIT, dataBuffer); if (dataSize == 1) { return (dataBuffer[0] & Limits.kReverseLimit_val) != 0; } @@ -1148,7 +1194,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_FAULT, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_FAULT, dataBuffer); if (dataSize == 2) { return (short)unpackINT16(dataBuffer); } @@ -1167,14 +1213,14 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_STATUS_POWER, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_STATUS_POWER, dataBuffer); if (dataSize == 1) { boolean powerCycled = dataBuffer[0] != 0; // Clear the power cycled bit now that we've accessed it if (powerCycled) { dataBuffer[0] = 1; - setTransaction(CANLibrary.LM_API_STATUS_POWER, dataBuffer, (byte) 1); + setTransaction(CANJNI.LM_API_STATUS_POWER, dataBuffer, (byte) 1); } return powerCycled; @@ -1197,11 +1243,11 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW switch (m_controlMode.value) { case ControlMode.kPercentVbus_val: dataSize = packPercentage(dataBuffer, rampRate / (m_maxOutputVoltage * kControllerRate)); - setTransaction(CANLibrary.LM_API_VOLT_SET_RAMP, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_VOLT_SET_RAMP, dataBuffer, dataSize); break; case ControlMode.kVoltage_val: dataSize = packFXP8_8(dataBuffer, rampRate / kControllerRate); - setTransaction(CANLibrary.LM_API_VCOMP_IN_RAMP, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_VCOMP_IN_RAMP, dataBuffer, dataSize); break; default: return; @@ -1218,7 +1264,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte dataSize; // Set the MSB to tell the 2CAN that this is a remote message. - dataSize = getTransaction(0x80000000 | CANLibrary.CAN_MSGID_API_FIRMVER, dataBuffer); + dataSize = getTransaction(0x80000000 | CANJNI.CAN_MSGID_API_FIRMVER, dataBuffer); if (dataSize == 4) { return (int)unpackINT32(dataBuffer); } @@ -1234,14 +1280,14 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; byte dataSize; - dataSize = getTransaction(CANLibrary.LM_API_HWVER, dataBuffer); + dataSize = getTransaction(CANJNI.LM_API_HWVER, dataBuffer); if (dataSize == 1 + 1) { if (dataBuffer[0] == m_deviceNumber) { return dataBuffer[1]; } } // Assume Gray Jag if there is no response - return CANLibrary.LM_HWVER_JAG_1_0; + return CANJNI.LM_HWVER_JAG_1_0; } /** @@ -1255,7 +1301,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; dataBuffer[0] = mode.value; - setTransaction(CANLibrary.LM_API_CFG_BRAKE_COAST, dataBuffer, (byte) 1); + setTransaction(CANJNI.LM_API_CFG_BRAKE_COAST, dataBuffer, (byte) 1); } /** @@ -1268,7 +1314,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte dataSize; dataSize = packINT16(dataBuffer, (short)codesPerRev); - setTransaction(CANLibrary.LM_API_CFG_ENC_LINES, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_CFG_ENC_LINES, dataBuffer, dataSize); } /** @@ -1284,7 +1330,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte dataSize; dataSize = packINT16(dataBuffer, (short)turns); - setTransaction(CANLibrary.LM_API_CFG_POT_TURNS, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_CFG_POT_TURNS, dataBuffer, dataSize); } /** @@ -1303,14 +1349,14 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW dataSize = packFXP16_16(dataBuffer, forwardLimitPosition); dataBuffer[dataSize++] = (forwardLimitPosition > reverseLimitPosition) ? (byte) 1 : (byte) 0; - setTransaction(CANLibrary.LM_API_CFG_LIMIT_FWD, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_CFG_LIMIT_FWD, dataBuffer, dataSize); dataSize = packFXP16_16(dataBuffer, reverseLimitPosition); dataBuffer[dataSize++] = forwardLimitPosition <= reverseLimitPosition ? (byte) 1 : (byte) 0; - setTransaction(CANLibrary.LM_API_CFG_LIMIT_REV, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_CFG_LIMIT_REV, dataBuffer, dataSize); dataBuffer[0] = LimitMode.kSoftPositionLimit_val; - setTransaction(CANLibrary.LM_API_CFG_LIMIT_MODE, dataBuffer, (byte) 1); + setTransaction(CANJNI.LM_API_CFG_LIMIT_MODE, dataBuffer, (byte) 1); } /** @@ -1322,7 +1368,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; dataBuffer[0] = LimitMode.kSwitchInputsOnly_val; - setTransaction(CANLibrary.LM_API_CFG_LIMIT_MODE, dataBuffer, (byte) 1); + setTransaction(CANJNI.LM_API_CFG_LIMIT_MODE, dataBuffer, (byte) 1); } /** @@ -1339,7 +1385,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW m_maxOutputVoltage = voltage; dataSize = packFXP8_8(dataBuffer, voltage); - setTransaction(CANLibrary.LM_API_CFG_MAX_VOUT, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_CFG_MAX_VOUT, dataBuffer, dataSize); } /** @@ -1356,7 +1402,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW // Message takes ms dataSize = packINT16(dataBuffer, (short) (faultTime * 1000.0)); - setTransaction(CANLibrary.LM_API_CFG_FAULT_TIME, dataBuffer, dataSize); + setTransaction(CANJNI.LM_API_CFG_FAULT_TIME, dataBuffer, dataSize); } /** @@ -1368,7 +1414,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW byte[] dataBuffer = new byte[8]; dataBuffer[0] = syncGroup; - sendMessage(CANLibrary.CAN_MSGID_API_SYNC, dataBuffer, 1); + sendMessage(CANJNI.CAN_MSGID_API_SYNC, dataBuffer, 1); } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Compressor.java index 1f164058f5..febbed5256 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Compressor.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; import edu.wpi.first.wpilibj.parsing.IDevice; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Counter.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Counter.java index 17461b302f..368aa0c95a 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Counter.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Counter.java @@ -7,13 +7,13 @@ package edu.wpi.first.wpilibj; -import java.nio.IntBuffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.AnalogJNI; +import edu.wpi.first.wpilibj.hal.CounterJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; import edu.wpi.first.wpilibj.tables.ITable; @@ -68,16 +68,21 @@ public class Counter extends SensorBase implements CounterBase, private DigitalSource m_downSource; // /< What makes the counter count down. private boolean m_allocatedUpSource; private boolean m_allocatedDownSource; - private Pointer m_counter; // /< The FPGA counter object. + private ByteBuffer m_counter; // /< The FPGA counter object. private int m_index; // /< The index of this counter. private PIDSourceParameter m_pidSource; private double m_distancePerPulse; // distance of travel for each tick private void initCounter(final Mode mode) { - IntBuffer status = IntBuffer.allocate(1), index = IntBuffer.allocate(1); - m_counter = HALLibrary.initializeCounter(mode.value, index, status); - HALUtil.checkStatus(status); - m_index = index.get(); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer index = ByteBuffer.allocateDirect(4); + // set the byte order + index.order(ByteOrder.LITTLE_ENDIAN); + m_counter = CounterJNI.initializeCounter(mode.value, index.asIntBuffer(), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + m_index = index.asIntBuffer().get(0); m_allocatedUpSource = false; m_allocatedDownSource = false; @@ -189,7 +194,7 @@ public class Counter extends SensorBase implements CounterBase, */ public Counter(AnalogTrigger trigger) { initCounter(Mode.kTwoPulse); - setUpSource(trigger.createOutput(HALLibrary.AnalogTriggerType.kState)); + setUpSource(trigger.createOutput(AnalogJNI.AnalogTriggerType.kState)); } public void free() { @@ -198,9 +203,10 @@ public class Counter extends SensorBase implements CounterBase, clearUpSource(); clearDownSource(); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.freeCounter(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.freeCounter(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); m_upSource = null; m_downSource = null; @@ -245,12 +251,13 @@ public class Counter extends SensorBase implements CounterBase, m_allocatedUpSource = false; } m_upSource = source; - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterUpSourceWithModule(m_counter, + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterUpSourceWithModule(m_counter, (byte) source.getModuleForRouting(), source.getChannelForRouting(), - (byte) (source.getAnalogTriggerForRouting() ? 1 : 0), status); - HALUtil.checkStatus(status); + (byte) (source.getAnalogTriggerForRouting() ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -279,11 +286,12 @@ public class Counter extends SensorBase implements CounterBase, if (m_upSource == null) throw new RuntimeException( "Up Source must be set before setting the edge!"); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterUpSourceEdge(m_counter, + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterUpSourceEdge(m_counter, (byte) (risingEdge ? 1 : 0), (byte) (fallingEdge ? 1 : 0), - status); - HALUtil.checkStatus(status); + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -296,9 +304,10 @@ public class Counter extends SensorBase implements CounterBase, } m_upSource = null; - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.clearCounterUpSource(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.clearCounterUpSource(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -338,16 +347,17 @@ public class Counter extends SensorBase implements CounterBase, m_downSource.free(); m_allocatedDownSource = false; } - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterDownSourceWithModule(m_counter, + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterDownSourceWithModule(m_counter, (byte) source.getModuleForRouting(), source.getChannelForRouting(), - (byte) (source.getAnalogTriggerForRouting() ? 1 : 0), status); - if (status.get() == HALLibrary.PARAMETER_OUT_OF_RANGE) { + (byte) (source.getAnalogTriggerForRouting() ? 1 : 0), status.asIntBuffer()); + if (status.asIntBuffer().get(0) == HALUtil.PARAMETER_OUT_OF_RANGE) { throw new IllegalArgumentException( "Counter only supports DownSource in TwoPulse and ExternalDirection modes."); } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); m_downSource = source; } @@ -377,10 +387,11 @@ public class Counter extends SensorBase implements CounterBase, if (m_downSource == null) throw new RuntimeException( " Down Source must be set before setting the edge!"); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterDownSourceEdge(m_counter, (byte) (risingEdge ? 1 - : 0), (byte) (fallingEdge ? 0 : 1), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterDownSourceEdge(m_counter, (byte) (risingEdge ? 1 + : 0), (byte) (fallingEdge ? 0 : 1), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -393,9 +404,10 @@ public class Counter extends SensorBase implements CounterBase, } m_downSource = null; - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.clearCounterDownSource(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.clearCounterDownSource(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -403,9 +415,10 @@ public class Counter extends SensorBase implements CounterBase, * are sourced independently from two inputs. */ public void setUpDownCounterMode() { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterUpDownMode(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterUpDownMode(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -413,9 +426,10 @@ public class Counter extends SensorBase implements CounterBase, * counter input. The Down counter input represents the direction to count. */ public void setExternalDirectionMode() { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterExternalDirectionMode(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterExternalDirectionMode(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -426,10 +440,11 @@ public class Counter extends SensorBase implements CounterBase, * true to count up on both rising and falling */ public void setSemiPeriodMode(boolean highSemiPeriod) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterSemiPeriodMode(m_counter, - (byte) (highSemiPeriod ? 1 : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterSemiPeriodMode(m_counter, + (byte) (highSemiPeriod ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -442,10 +457,11 @@ public class Counter extends SensorBase implements CounterBase, * direction. Units are seconds. */ public void setPulseLengthMode(double threshold) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterPulseLengthMode(m_counter, (float) threshold, - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterPulseLengthMode(m_counter, threshold, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -454,9 +470,10 @@ public class Counter extends SensorBase implements CounterBase, * is not reset on starting, and still has the previous value. */ public void start() { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.startCounter(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.startCounter(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -465,9 +482,10 @@ public class Counter extends SensorBase implements CounterBase, * it might have a different value. */ public int get() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getCounter(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + int value = CounterJNI.getCounter(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -487,9 +505,10 @@ public class Counter extends SensorBase implements CounterBase, * zero. */ public void reset() { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.resetCounter(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.resetCounter(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -497,9 +516,10 @@ public class Counter extends SensorBase implements CounterBase, * value. */ public void stop() { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.stopCounter(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.stopCounter(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -513,9 +533,10 @@ public class Counter extends SensorBase implements CounterBase, * moving in seconds. */ public void setMaxPeriod(double maxPeriod) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterMaxPeriod(m_counter, maxPeriod, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterMaxPeriod(m_counter, maxPeriod, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -536,10 +557,11 @@ public class Counter extends SensorBase implements CounterBase, * true to continue updating */ public void setUpdateWhenEmpty(boolean enabled) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterUpdateWhenEmpty(m_counter, - (byte) (enabled ? 1 : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterUpdateWhenEmpty(m_counter, + (byte) (enabled ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -552,9 +574,10 @@ public class Counter extends SensorBase implements CounterBase, * MaxPeriod value set by SetMaxPeriod. */ public boolean getStopped() { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getCounterStopped(m_counter, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = CounterJNI.getCounterStopped(m_counter, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -564,9 +587,10 @@ public class Counter extends SensorBase implements CounterBase, * @return The last direction the counter value changed. */ public boolean getDirection() { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getCounterDirection(m_counter, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = CounterJNI.getCounterDirection(m_counter, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -579,10 +603,11 @@ public class Counter extends SensorBase implements CounterBase, * true if the value counted should be negated. */ public void setReverseDirection(boolean reverseDirection) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterReverseDirection(m_counter, - (byte) (reverseDirection ? 1 : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterReverseDirection(m_counter, + (byte) (reverseDirection ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -593,9 +618,10 @@ public class Counter extends SensorBase implements CounterBase, * @returns The period of the last two pulses in units of seconds. */ public double getPeriod() { - IntBuffer status = IntBuffer.allocate(1); - double value = HALLibrary.getCounterPeriod(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + double value = CounterJNI.getCounterPeriod(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -620,14 +646,15 @@ public class Counter extends SensorBase implements CounterBase, * The number of samples to average from 1 to 127. */ public void setSamplesToAverage(int samplesToAverage) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setCounterSamplesToAverage(m_counter, samplesToAverage, - status); - if (status.get() == HALLibrary.PARAMETER_OUT_OF_RANGE) { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + CounterJNI.setCounterSamplesToAverage(m_counter, samplesToAverage, + status.asIntBuffer()); + if (status.asIntBuffer().get(0) == HALUtil.PARAMETER_OUT_OF_RANGE) { throw new BoundaryException(BoundaryException.getMessage( samplesToAverage, 1, 127)); } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -640,9 +667,10 @@ public class Counter extends SensorBase implements CounterBase, * 127) */ public int getSamplesToAverage() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getCounterSamplesToAverage(m_counter, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + int value = CounterJNI.getCounterSamplesToAverage(m_counter, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Dashboard.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Dashboard.java index e38def9363..268269fa34 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Dashboard.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Dashboard.java @@ -8,7 +8,7 @@ package edu.wpi.first.wpilibj; import java.util.Stack; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.parsing.IInputOutput; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java index 559a63df6e..1fbc605e64 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java @@ -7,12 +7,14 @@ package edu.wpi.first.wpilibj; -import java.nio.IntBuffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; -import edu.wpi.first.wpilibj.hal.HALLibrary.InterruptHandlerFunction; +import edu.wpi.first.wpilibj.hal.InterruptJNI; +import edu.wpi.first.wpilibj.hal.DIOJNI; +import edu.wpi.first.wpilibj.hal.InterruptJNI.InterruptHandlerFunction; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; import edu.wpi.first.wpilibj.parsing.IInputOutput; @@ -64,9 +66,11 @@ public class DigitalInput extends DigitalSource implements IInputOutput, * @return the stats of the digital input */ public boolean get() { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getDIO(m_port, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = DIOJNI.getDIO(m_port, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -106,13 +110,15 @@ public class DigitalInput extends DigitalSource implements IInputOutput, allocateInterrupts(false); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.requestInterrupts(m_interrupt, (byte) getModuleForRouting(), + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + InterruptJNI.requestInterrupts(m_interrupt, (byte) getModuleForRouting(), getChannelForRouting(), - (byte) (getAnalogTriggerForRouting() ? 1 : 0), status); + (byte) (getAnalogTriggerForRouting() ? 1 : 0), status.asIntBuffer()); setUpSourceEdge(true, false); - HALLibrary.attachInterruptHandler(m_interrupt, handler, null, status); - HALUtil.checkStatus(status); + InterruptJNI.attachInterruptHandler(m_interrupt, handler, null, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -131,11 +137,13 @@ public class DigitalInput extends DigitalSource implements IInputOutput, allocateInterrupts(true); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.requestInterrupts(m_interrupt, (byte) getModuleForRouting(), + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + InterruptJNI.requestInterrupts(m_interrupt, (byte) getModuleForRouting(), getChannelForRouting(), - (byte) (getAnalogTriggerForRouting() ? 1 : 0), status); - HALUtil.checkStatus(status); + (byte) (getAnalogTriggerForRouting() ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); setUpSourceEdge(true, false); } @@ -150,11 +158,13 @@ public class DigitalInput extends DigitalSource implements IInputOutput, */ public void setUpSourceEdge(boolean risingEdge, boolean fallingEdge) { if (m_interrupt != null) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setInterruptUpSourceEdge(m_interrupt, + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + InterruptJNI.setInterruptUpSourceEdge(m_interrupt, (byte) (risingEdge ? 1 : 0), (byte) (fallingEdge ? 1 : 0), - status); - HALUtil.checkStatus(status); + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } else { throw new IllegalArgumentException( "You must call RequestInterrupts before setUpSourceEdge"); diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalModule.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalModule.java index bfd418a0ad..5dc04d9ea2 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalModule.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalModule.java @@ -6,12 +6,18 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; +import java.nio.ByteOrder; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.IntByReference; +//import com.sun.jna.Pointer; +//import com.sun.jna.ptr.IntByReference; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tModuleType; + +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tModuleType; +import edu.wpi.first.wpilibj.hal.DIOJNI; +import edu.wpi.first.wpilibj.hal.PWMJNI; +import edu.wpi.first.wpilibj.hal.RelayJNI; import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.hal.HALUtil; @@ -27,9 +33,9 @@ public class DigitalModule extends Module { */ public static final int kExpectedLoopTiming = 260; private int m_module; - private Pointer[] m_digital_ports; - private Pointer[] m_relay_ports; - private Pointer[] m_pwm_ports; + private ByteBuffer[] m_digital_ports; + private ByteBuffer[] m_relay_ports; + private ByteBuffer[] m_pwm_ports; /** * Get an instance of an Digital Module. Singleton digital module creation @@ -46,32 +52,6 @@ public class DigitalModule extends Module { moduleNumber); } - /** - * @deprecated - * Convert a channel to its fpga reference - * - * @param channel - * the channel to convert - * @return the converted channel - */ - public static int remapDigitalChannel(final int channel) { - System.err.println("This is going away for compatability reasons. Don't use it."); - return SensorBase.kDigitalChannels - channel; - } - - /** - * @deprecated - * Convert a channel from it's fpga reference - * - * @param channel - * the channel to convert - * @return the converted channel - */ - public static int unmapDigitalChannel(final int channel) { - System.err.println("This is going away for compatability reasons. Don't use it."); - return SensorBase.kDigitalChannels - channel; - } - /** * Create a new digital module * @@ -82,33 +62,39 @@ public class DigitalModule extends Module { super(tModuleType.kModuleType_Digital, moduleNumber); m_module = moduleNumber; - m_digital_ports = new Pointer[SensorBase.kDigitalChannels]; + m_digital_ports = new ByteBuffer[SensorBase.kDigitalChannels]; for (int i = 0; i < SensorBase.kDigitalChannels; i++) { - Pointer port_pointer = HALLibrary.getPortWithModule( + ByteBuffer port_pointer = DIOJNI.getPortWithModule( (byte) moduleNumber, (byte) (i + 1)); - IntBuffer status = IntBuffer.allocate(1); - m_digital_ports[i] = HALLibrary.initializeDigitalPort(port_pointer, - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + m_digital_ports[i] = DIOJNI.initializeDigitalPort(port_pointer, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } - m_relay_ports = new Pointer[SensorBase.kRelayChannels]; + m_relay_ports = new ByteBuffer[SensorBase.kRelayChannels]; for (int i = 0; i < SensorBase.kRelayChannels; i++) { - Pointer port_pointer = HALLibrary.getPortWithModule( + ByteBuffer port_pointer = RelayJNI.getPortWithModule( (byte) moduleNumber, (byte) (i + 1)); - IntBuffer status = IntBuffer.allocate(1); - m_relay_ports[i] = HALLibrary.initializeDigitalPort(port_pointer, - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + m_relay_ports[i] = RelayJNI.initializeDigitalPort(port_pointer, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } - m_pwm_ports = new Pointer[SensorBase.kPwmChannels]; + m_pwm_ports = new ByteBuffer[SensorBase.kPwmChannels]; for (int i = 0; i < SensorBase.kPwmChannels; i++) { - Pointer port_pointer = HALLibrary.getPortWithModule( + ByteBuffer port_pointer = PWMJNI.getPortWithModule( (byte) moduleNumber, (byte) (i + 1)); - IntBuffer status = IntBuffer.allocate(1); - m_pwm_ports[i] = HALLibrary.initializeDigitalPort(port_pointer, - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + m_pwm_ports[i] = PWMJNI.initializeDigitalPort(port_pointer, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -123,9 +109,11 @@ public class DigitalModule extends Module { * The PWM value to set. */ public void setPWM(final int channel, final int value) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setPWM(m_pwm_ports[channel - 1], (short) value, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWM(m_pwm_ports[channel - 1], (short) value, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -136,9 +124,11 @@ public class DigitalModule extends Module { * @return The raw PWM value. */ public int getPWM(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - int value = (int) HALLibrary.getPWM(m_pwm_ports[channel - 1], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = (int) PWMJNI.getPWM(m_pwm_ports[channel - 1], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -151,10 +141,12 @@ public class DigitalModule extends Module { * The 2-bit mask of outputs to squelch. */ public void setPWMPeriodScale(final int channel, final int squelchMask) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setPWMPeriodScale(m_pwm_ports[channel - 1], squelchMask, - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMPeriodScale(m_pwm_ports[channel - 1], squelchMask, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -167,10 +159,12 @@ public class DigitalModule extends Module { * Indicates whether to set the relay to the On state. */ public void setRelayForward(final int channel, final boolean on) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setRelayForward(m_relay_ports[channel - 1], (byte) (on ? 1 - : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + RelayJNI.setRelayForward(m_relay_ports[channel - 1], (byte) (on ? 1 + : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -183,10 +177,12 @@ public class DigitalModule extends Module { * Indicates whether to set the relay to the On state. */ public void setRelayReverse(final int channel, final boolean on) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setRelayReverse(m_relay_ports[channel - 1], (byte) (on ? 1 - : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + RelayJNI.setRelayReverse(m_relay_ports[channel - 1], (byte) (on ? 1 + : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -197,10 +193,12 @@ public class DigitalModule extends Module { * @return The current state of the relay. */ public boolean getRelayForward(int channel) { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getRelayForward(m_relay_ports[channel - 1], - status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = RelayJNI.getRelayForward(m_relay_ports[channel - 1], + status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -212,11 +210,13 @@ public class DigitalModule extends Module { */ public byte getRelayForward() { byte value = 0; - IntBuffer status = IntBuffer.allocate(1); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < SensorBase.kRelayChannels; i++) { - value |= HALLibrary.getRelayForward(m_relay_ports[i], status) << i; + value |= RelayJNI.getRelayForward(m_relay_ports[i], status.asIntBuffer()) << i; } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -228,10 +228,12 @@ public class DigitalModule extends Module { * @return The current statte of the relay */ public boolean getRelayReverse(int channel) { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getRelayReverse(m_relay_ports[channel - 1], - status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = RelayJNI.getRelayReverse(m_relay_ports[channel - 1], + status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -243,11 +245,13 @@ public class DigitalModule extends Module { */ public byte getRelayReverse() { byte value = 0; - IntBuffer status = IntBuffer.allocate(1); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < SensorBase.kRelayChannels; i++) { - value |= HALLibrary.getRelayReverse(m_relay_ports[i], status) << i; + value |= RelayJNI.getRelayReverse(m_relay_ports[i], status.asIntBuffer()) << i; } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -264,10 +268,12 @@ public class DigitalModule extends Module { * @return True if the I/O pin was allocated, false otherwise. */ public boolean allocateDIO(final int channel, final boolean input) { - IntBuffer status = IntBuffer.allocate(1); - boolean allocated = HALLibrary.allocateDIO( - m_digital_ports[channel - 1], (byte) (input ? 1 : 0), status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean allocated = DIOJNI.allocateDIO( + m_digital_ports[channel - 1], (byte) (input ? 1 : 0), status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return allocated; } @@ -278,9 +284,11 @@ public class DigitalModule extends Module { * The channel whose resources should be freed. */ public void freeDIO(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.freeDIO(m_digital_ports[channel - 1], status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + DIOJNI.freeDIO(m_digital_ports[channel - 1], status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -293,10 +301,12 @@ public class DigitalModule extends Module { * The value to set. */ public void setDIO(final int channel, final boolean value) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setDIO(m_digital_ports[channel - 1], (byte) (value ? 1 : 0), - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + DIOJNI.setDIO(m_digital_ports[channel - 1], (byte) (value ? 1 : 0), + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -308,9 +318,11 @@ public class DigitalModule extends Module { * @return The value of the selected channel */ public boolean getDIO(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getDIO(m_digital_ports[channel - 1], status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = DIOJNI.getDIO(m_digital_ports[channel - 1], status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -321,12 +333,14 @@ public class DigitalModule extends Module { * @return The state of all the Digital IO lines in hardware order */ public short getAllDIO() { - byte value = 0; - IntBuffer status = IntBuffer.allocate(1); + short value = 0; + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < SensorBase.kDigitalChannels; i++) { - value |= HALLibrary.getDIO(m_digital_ports[i], status) << i; + value |= DIOJNI.getDIO(m_digital_ports[i], status.asIntBuffer()) << i; } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -339,10 +353,12 @@ public class DigitalModule extends Module { * it is an input */ public boolean getDIODirection(int channel) { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getDIODirection( - m_digital_ports[channel - 1], status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = DIOJNI.getDIODirection( + m_digital_ports[channel - 1], status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -355,11 +371,13 @@ public class DigitalModule extends Module { */ public short getDIODirection() { byte value = 0; - IntBuffer status = IntBuffer.allocate(1); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < SensorBase.kDigitalChannels; i++) { - value |= HALLibrary.getDIODirection(m_digital_ports[i], status) << i; + value |= DIOJNI.getDIODirection(m_digital_ports[i], status.asIntBuffer()) << i; } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -373,9 +391,11 @@ public class DigitalModule extends Module { * The length of the pulse. */ public void pulse(final int channel, final float pulseLength) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.pulse(m_digital_ports[channel - 1], pulseLength, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + DIOJNI.pulse(m_digital_ports[channel - 1], pulseLength, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -389,13 +409,14 @@ public class DigitalModule extends Module { * The length of the pulse. */ public void pulse(final int channel, final int pulseLength) { - IntBuffer status = IntBuffer.allocate(1); - float convertedPulse = (float) (pulseLength / 1.0e9 * (HALLibrary - .getLoopTiming(status) * 25)); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + float convertedPulse = (float) (pulseLength / 1.0e9 * (DIOJNI.getLoopTiming(status.asIntBuffer()) * 25)); System.err .println("You should use the float version of pulse for portability. This is deprecated"); - HALLibrary.pulse(m_digital_ports[channel - 1], convertedPulse, status); - HALUtil.checkStatus(status); + DIOJNI.pulse(m_digital_ports[channel - 1], convertedPulse, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -406,10 +427,12 @@ public class DigitalModule extends Module { * @return True if the channel is pulsing, false otherwise. */ public boolean isPulsing(final int channel) { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.isPulsing(m_digital_ports[channel - 1], - status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = DIOJNI.isPulsing(m_digital_ports[channel - 1], + status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -420,9 +443,11 @@ public class DigitalModule extends Module { */ public boolean isPulsing() { boolean value; - IntBuffer status = IntBuffer.allocate(1); - value = HALLibrary.isAnyPulsingWithModule((byte) m_module, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + value = DIOJNI.isAnyPulsingWithModule((byte) m_module, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -430,22 +455,24 @@ public class DigitalModule extends Module { * Allocate a DO PWM Generator. Allocate PWM generators so that they are not * accidently reused. */ - public int allocateDO_PWM() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.allocatePWMWithModule((byte) m_module, status) - .getInt(0); // XXX: Hacky, needs heavy testing - HALUtil.checkStatus(status); + public ByteBuffer allocateDO_PWM() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer value = PWMJNI.allocatePWMWithModule((byte) m_module, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } /** * Free the resource associated with a DO PWM generator. */ - public void freeDO_PWM(int pwmGenerator) { - IntBuffer status = IntBuffer.allocate(1); - Pointer pointer = new IntByReference(pwmGenerator).getPointer(); - HALLibrary.freePWMWithModule((byte) m_module, pointer, status); - HALUtil.checkStatus(status); + public void freeDO_PWM(ByteBuffer pwmGenerator) { + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.freePWMWithModule((byte) m_module, pwmGenerator, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -459,9 +486,11 @@ public class DigitalModule extends Module { * module. */ public void setDO_PWMRate(double rate) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setPWMRateWithModuleIntHack((byte) m_module, Float.floatToIntBits((float) rate), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMRateWithModule((byte) m_module, rate, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -472,12 +501,13 @@ public class DigitalModule extends Module { * @param channel * The Digital Output channel to output on */ - public void setDO_PWMOutputChannel(int pwmGenerator, int channel) { - IntBuffer status = IntBuffer.allocate(1); - Pointer pointer = new IntByReference(pwmGenerator).getPointer(); - HALLibrary.setPWMOutputChannelWithModule((byte) m_module, pointer, - channel, status); - HALUtil.checkStatus(status); + public void setDO_PWMOutputChannel(ByteBuffer pwmGenerator, int channel) { + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMOutputChannelWithModule((byte) m_module, pwmGenerator, + channel, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -488,12 +518,12 @@ public class DigitalModule extends Module { * @param dutyCycle * The percent duty cycle to output [0..1]. */ - public void setDO_PWMDutyCycle(int pwmGenerator, double dutyCycle) { - IntBuffer status = IntBuffer.allocate(1); - Pointer pointer = new IntByReference(pwmGenerator).getPointer(); - HALLibrary.setPWMDutyCycleWithModuleIntHack((byte) m_module, pointer, - Float.floatToIntBits((float) dutyCycle), status); - HALUtil.checkStatus(status); + public void setDO_PWMDutyCycle(ByteBuffer pwmGenerator, double dutyCycle) { + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMDutyCycleWithModule((byte) m_module, pwmGenerator, dutyCycle, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -513,9 +543,11 @@ public class DigitalModule extends Module { * @return The number of clock ticks per DIO loop */ public int getLoopTiming() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getLoopTiming(status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = DIOJNI.getLoopTiming(status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java index 02038b1b72..ebb140bd97 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -7,13 +7,17 @@ package edu.wpi.first.wpilibj; +import java.nio.ByteOrder; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; +//import com.sun.jna.Pointer; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; + +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.DIOJNI; +import edu.wpi.first.wpilibj.hal.PWMJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; import edu.wpi.first.wpilibj.parsing.IInputOutput; @@ -28,7 +32,7 @@ import edu.wpi.first.wpilibj.tables.ITableListener; public class DigitalOutput extends DigitalSource implements IInputOutput, LiveWindowSendable { - private Pointer m_pwmGenerator; + private ByteBuffer m_pwmGenerator; /** * Create an instance of a digital output. Create an instance of a digital @@ -75,9 +79,11 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, * true is on, off is false */ public void set(boolean value) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setDIO(m_port, (short) (value ? 1 : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + DIOJNI.setDIO(m_port, (short) (value ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -97,9 +103,11 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, * The length of the pulse. */ public void pulse(final int channel, final float pulseLength) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.pulse(m_port, pulseLength, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + DIOJNI.pulse(m_port, pulseLength, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -113,13 +121,14 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, * The length of the pulse. */ public void pulse(final int channel, final int pulseLength) { - IntBuffer status = IntBuffer.allocate(1); - float convertedPulse = (float) (pulseLength / 1.0e9 * (HALLibrary - .getLoopTiming(status) * 25)); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + float convertedPulse = (float) (pulseLength / 1.0e9 * (DIOJNI.getLoopTiming(status.asIntBuffer()) * 25)); System.err .println("You should use the float version of pulse for portability. This is deprecated"); - HALLibrary.pulse(m_port, convertedPulse, status); - HALUtil.checkStatus(status); + DIOJNI.pulse(m_port, convertedPulse, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -129,9 +138,11 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, * @return true if pulsing */ public boolean isPulsing() { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.isPulsing(m_port, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = DIOJNI.isPulsing(m_port, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -148,10 +159,12 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, * module. */ public void setPWMRate(double rate) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setPWMRateWithModule((byte) m_moduleNumber, (float) rate, - status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMRateWithModule((byte) m_moduleNumber, rate, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /** @@ -171,15 +184,17 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, public void enablePWM(double initialDutyCycle) { if (m_pwmGenerator == null) return; - IntBuffer status = IntBuffer.allocate(1); - m_pwmGenerator = HALLibrary.allocatePWMWithModule( - (byte) m_moduleNumber, status); - HALUtil.checkStatus(status); - HALLibrary.setPWMDutyCycle(m_pwmGenerator, (float) initialDutyCycle, - status); - HALUtil.checkStatus(status); - HALLibrary.setPWMOutputChannelWithModule((byte) m_moduleNumber, - m_pwmGenerator, m_channel, status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + m_pwmGenerator = PWMJNI.allocatePWMWithModule( + (byte) m_moduleNumber, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + PWMJNI.setPWMDutyCycle(m_pwmGenerator, initialDutyCycle, + status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + PWMJNI.setPWMOutputChannelWithModule((byte) m_moduleNumber, + m_pwmGenerator, m_channel, status.asIntBuffer()); } /** @@ -189,12 +204,13 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, */ public void disablePWM() { // Disable the output by routing to a dead bit. - IntBuffer status = IntBuffer.allocate(1); - HALLibrary - .setPWMOutputChannel(m_pwmGenerator, kDigitalChannels, status); - HALUtil.checkStatus(status); - HALLibrary.freePWMWithModule((byte) m_moduleNumber, m_pwmGenerator, - status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMOutputChannel(m_pwmGenerator, kDigitalChannels, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + PWMJNI.freePWMWithModule((byte) m_moduleNumber, m_pwmGenerator, + status.asIntBuffer()); m_pwmGenerator = null; } @@ -208,10 +224,12 @@ public class DigitalOutput extends DigitalSource implements IInputOutput, * The duty-cycle to change to. [0..1] */ public void updateDutyCycle(double dutyCycle) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setPWMDutyCycleWithModule((byte) m_moduleNumber, - m_pwmGenerator, (float) dutyCycle, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + PWMJNI.setPWMDutyCycleWithModule((byte) m_moduleNumber, + m_pwmGenerator, dutyCycle, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } /* diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalSource.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalSource.java index 553ff31f8e..be214ea6d4 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalSource.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DigitalSource.java @@ -7,11 +7,11 @@ package edu.wpi.first.wpilibj; +import java.nio.ByteOrder; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.DIOJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.util.AllocationException; import edu.wpi.first.wpilibj.util.CheckedAllocationException; @@ -27,14 +27,14 @@ public abstract class DigitalSource extends InterruptableSensorBase { protected static Resource channels = new Resource(kDigitalChannels * kDigitalModules); - protected Pointer m_port; + protected ByteBuffer m_port; protected int m_moduleNumber, m_channel; protected void initDigitalPort(int moduleNumber, int channel, boolean input) { m_channel = channel; m_moduleNumber = moduleNumber; - if (HALLibrary.checkDigitalModule((byte) m_moduleNumber) != 1) { + if (DIOJNI.checkDigitalModule((byte) m_moduleNumber) != 1) { throw new AllocationException("Digital input " + m_channel + " on module " + m_moduleNumber + " cannot be allocated. Module is not present."); @@ -51,20 +51,24 @@ public abstract class DigitalSource extends InterruptableSensorBase { + " on module " + m_moduleNumber + " is already allocated"); } - Pointer port_pointer = HALLibrary.getPortWithModule( + ByteBuffer port_pointer = DIOJNI.getPortWithModule( (byte) moduleNumber, (byte) channel); - IntBuffer status = IntBuffer.allocate(1); - m_port = HALLibrary.initializeDigitalPort(port_pointer, status); - HALUtil.checkStatus(status); - HALLibrary.allocateDIO(m_port, (byte) (input ? 1 : 0), status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + m_port = DIOJNI.initializeDigitalPort(port_pointer, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + DIOJNI.allocateDIO(m_port, (byte) (input ? 1 : 0), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } public void free() { channels.free(((m_moduleNumber - 1) * kDigitalChannels + m_channel - 1)); - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.freeDIO(m_port, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + DIOJNI.freeDIO(m_port, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); m_channel = 0; m_moduleNumber = 0; } @@ -75,10 +79,7 @@ public abstract class DigitalSource extends InterruptableSensorBase { * @return channel routing number */ public int getChannelForRouting() { - IntBuffer status = IntBuffer.allocate(1); - int channel = HALLibrary.remapDigitalChannel(m_channel - 1, status); - HALUtil.checkStatus(status); - return channel; + return m_channel - 1; } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java index c318707769..b64a9e7b6b 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java @@ -6,7 +6,7 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; @@ -50,28 +50,28 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable { * Common function to implement constructor behavior. */ private synchronized void initSolenoid() { - checkSolenoidModule(m_moduleNumber); - checkSolenoidChannel(m_forwardChannel); - checkSolenoidChannel(m_reverseChannel); - - try { - m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_forwardChannel - 1); - } catch (CheckedAllocationException e) { - throw new AllocationException( - "Solenoid channel " + m_forwardChannel + " on module " + m_moduleNumber + " is already allocated"); - } - try { - m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_reverseChannel - 1); - } catch (CheckedAllocationException e) { - throw new AllocationException( - "Solenoid channel " + m_reverseChannel + " on module " + m_moduleNumber + " is already allocated"); - } - m_forwardMask = (byte) (1 << (m_forwardChannel - 1)); - m_reverseMask = (byte) (1 << (m_reverseChannel - 1)); - - UsageReporting.report(tResourceType.kResourceType_Solenoid, m_forwardChannel, m_moduleNumber-1); - UsageReporting.report(tResourceType.kResourceType_Solenoid, m_reverseChannel, m_moduleNumber-1); - LiveWindow.addActuator("DoubleSolenoid", m_moduleNumber, m_forwardChannel, this); +// checkSolenoidModule(m_moduleNumber); +// checkSolenoidChannel(m_forwardChannel); +// checkSolenoidChannel(m_reverseChannel); +// +// try { +// m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_forwardChannel - 1); +// } catch (CheckedAllocationException e) { +// throw new AllocationException( +// "Solenoid channel " + m_forwardChannel + " on module " + m_moduleNumber + " is already allocated"); +// } +// try { +// m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_reverseChannel - 1); +// } catch (CheckedAllocationException e) { +// throw new AllocationException( +// "Solenoid channel " + m_reverseChannel + " on module " + m_moduleNumber + " is already allocated"); +// } +// m_forwardMask = (byte) (1 << (m_forwardChannel - 1)); +// m_reverseMask = (byte) (1 << (m_reverseChannel - 1)); +// +// UsageReporting.report(tResourceType.kResourceType_Solenoid, m_forwardChannel, m_moduleNumber-1); +// UsageReporting.report(tResourceType.kResourceType_Solenoid, m_reverseChannel, m_moduleNumber-1); +// LiveWindow.addActuator("DoubleSolenoid", m_moduleNumber, m_forwardChannel, this); } /** @@ -105,8 +105,8 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable { * Destructor. */ public synchronized void free() { - m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_forwardChannel - 1); - m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_reverseChannel - 1); +// m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_forwardChannel - 1); +// m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_reverseChannel - 1); } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index b9828bfb0f..0b347975d8 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -6,10 +6,13 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import com.sun.jna.Pointer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; -import edu.wpi.first.wpilibj.communication.*; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; +import edu.wpi.first.wpilibj.communication.FRCCommonControlData; +import edu.wpi.first.wpilibj.communication.FRCCommonControlMasks; +import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.parsing.IInputOutput; /** @@ -20,7 +23,7 @@ public class DriverStation implements IInputOutput { /** * The size of the user status data */ - public static final int USER_STATUS_DATA_SIZE = FRC_NetworkCommunicationsLibrary.USER_STATUS_DATA_SIZE; + public static final int USER_STATUS_DATA_SIZE = FRCNetworkCommunicationsLibrary.USER_STATUS_DATA_SIZE; /** * Slot for the analog module to read the battery */ @@ -100,7 +103,7 @@ public class DriverStation implements IInputOutput { private boolean m_userInTeleop = false; private boolean m_userInTest = false; private boolean m_newControlData; - private final Pointer m_packetDataAvailableSem; + private final ByteBuffer m_packetDataAvailableSem; // XXX: Add DriverStationEnhancedIO back // private DriverStationEnhancedIO m_enhancedIO = new DriverStationEnhancedIO(); @@ -132,8 +135,12 @@ public class DriverStation implements IInputOutput { // XXX: Uncomment when analogChannel is fixed //m_batteryChannel = new AnalogChannel(kBatterySlot, kBatteryChannel); - m_packetDataAvailableSem = HALLibrary.initializeMutex(HALLibrary.SEMAPHORE_Q_PRIORITY.get()); - FRC_NetworkCommunicationsLibrary.setNewDataSem(m_packetDataAvailableSem); + m_packetDataAvailableSem = HALUtil.initializeMutexNormal(); + + // set the byte order + m_packetDataAvailableSem.order(ByteOrder.LITTLE_ENDIAN); + + FRCNetworkCommunicationsLibrary.setNewDataSem(m_packetDataAvailableSem); m_thread = new Thread(new DriverStationTask(this), "FRCDriverStation"); m_thread.setPriority((Thread.NORM_PRIORITY + Thread.MAX_PRIORITY) / 2); @@ -154,7 +161,7 @@ public class DriverStation implements IInputOutput { private void task() { int safetyCounter = 0; while (m_thread_keepalive) { - HALLibrary.takeMutex(m_packetDataAvailableSem, HALLibrary.SEMAPHORE_WAIT_FOREVER.get()); + HALUtil.takeMutex(m_packetDataAvailableSem); synchronized (this) { getData(); // XXX: Add DriverStationEnhancedIO back @@ -170,16 +177,16 @@ public class DriverStation implements IInputOutput { safetyCounter = 0; } if (m_userInDisabled) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramDisabled(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramDisabled(); } if (m_userInAutonomous) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramAutonomous(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramAutonomous(); } if (m_userInTeleop) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramTeleop(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramTeleop(); } if (m_userInTest) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramTest(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramTest(); } } } @@ -213,7 +220,7 @@ public class DriverStation implements IInputOutput { * the data will be copied from the DS polling loop. */ protected synchronized void getData() { - FRC_NetworkCommunicationsLibrary.getCommonControlData(m_controlData, HALLibrary.SEMAPHORE_WAIT_FOREVER.get()); + FRCNetworkCommunicationsLibrary.getCommonControlData(m_controlData); if (!lastEnabled && isEnabled()) { // If starting teleop, assume that autonomous just took up 15 seconds @@ -236,14 +243,13 @@ public class DriverStation implements IInputOutput { */ protected void setData() { synchronized (m_semaphore) { - FRC_NetworkCommunicationsLibrary.setStatusData((float) getBatteryVoltage(), + FRCNetworkCommunicationsLibrary.setStatusData((float) getBatteryVoltage(), (byte) m_digitalOut, (byte) m_updateNumber, new String(m_dashboardInUseHigh.getBytes()), m_dashboardInUseHigh.getBytesLength(), new String(m_dashboardInUseLow.getBytes()), - m_dashboardInUseLow.getBytesLength(), - HALLibrary.SEMAPHORE_WAIT_FOREVER.get()); + m_dashboardInUseLow.getBytesLength()); m_dashboardInUseHigh.flush(); m_dashboardInUseLow.flush(); } @@ -282,16 +288,16 @@ public class DriverStation implements IInputOutput { int value; switch (stick) { case 1: - value = m_controlData.field2.stick0Axes[axis - 1]; + value = m_controlData.stick0Axes[axis - 1]; break; case 2: - value = m_controlData.field3.stick1Axes[axis - 1]; + value = m_controlData.stick1Axes[axis - 1]; break; case 3: - value = m_controlData.field4.stick2Axes[axis - 1]; + value = m_controlData.stick2Axes[axis - 1]; break; case 4: - value = m_controlData.field5.stick3Axes[axis - 1]; + value = m_controlData.stick3Axes[axis - 1]; break; default: return 0.0; @@ -400,7 +406,7 @@ public class DriverStation implements IInputOutput { * @return True if the robot is enabled, false otherwise. */ public boolean isEnabled() { - return (m_controlData.field1.control & FRCCommonControlMasks.ENABLED) != 0; + return (m_controlData.control & FRCCommonControlMasks.ENABLED) != 0; } /** @@ -420,7 +426,7 @@ public class DriverStation implements IInputOutput { * @return True if autonomous mode should be enabled, false otherwise. */ public boolean isAutonomous() { - return (m_controlData.field1.control & FRCCommonControlMasks.AUTONOMOUS) != 0; + return (m_controlData.control & FRCCommonControlMasks.AUTONOMOUS) != 0; } /** @@ -429,7 +435,7 @@ public class DriverStation implements IInputOutput { * @return True if test mode should be enabled, false otherwise. */ public boolean isTest() { - return (m_controlData.field1.control & FRCCommonControlMasks.TEST) != 0; + return (m_controlData.control & FRCCommonControlMasks.TEST) != 0; } /** @@ -588,7 +594,7 @@ public class DriverStation implements IInputOutput { * @return True if the robot is competing on a field being controlled by a Field Management System */ public boolean isFMSAttached() { - return (m_controlData.field1.control & FRCCommonControlMasks.FMS_ATTATCHED) > 0; + return (m_controlData.control & FRCCommonControlMasks.FMS_ATTATCHED) > 0; } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java index a3f1dd423e..973da9d0f3 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java @@ -10,8 +10,8 @@ package edu.wpi.first.wpilibj; import java.nio.ByteBuffer; import java.nio.IntBuffer; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.parsing.IInputOutput; @@ -111,9 +111,9 @@ public class DriverStationLCD extends SensorBase implements IInputOutput { * This is only called once the first time GetInstance() is called */ private DriverStationLCD() { - m_textBuffer = new byte[FRC_NetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE]; + m_textBuffer = new byte[FRCNetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE]; - for (int i = 0; i < FRC_NetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE; i++) { + for (int i = 0; i < FRCNetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE; i++) { m_textBuffer[i] = ' '; } @@ -127,7 +127,7 @@ public class DriverStationLCD extends SensorBase implements IInputOutput { * Send the text data to the Driver Station. */ public synchronized void updateLCD() { - FRC_NetworkCommunicationsLibrary.setUserDsLcdData(new String(m_textBuffer), FRC_NetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms); + FRCNetworkCommunicationsLibrary.setUserDsLcdData(new String(m_textBuffer), FRCNetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms); } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Encoder.java index f793f90c32..9eaf4b6c17 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Encoder.java @@ -6,14 +6,13 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import java.nio.IntBuffer; +import java.nio.ByteOrder; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.EncoderJNI; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; @@ -46,7 +45,7 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, * The index source */ protected DigitalSource m_indexSource = null; // Index on some encoders - private Pointer m_encoder; + private ByteBuffer m_encoder; private int m_index; private double m_distancePerPulse; // distance of travel for each encoder // tick @@ -75,18 +74,22 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, private void initEncoder(boolean reverseDirection) { switch (m_encodingType.value) { case EncodingType.k4X_val: - IntBuffer status = IntBuffer.allocate(1); - IntBuffer index = IntBuffer.allocate(1); - m_encoder = HALLibrary.initializeEncoder( + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer index = ByteBuffer.allocateDirect(4); + // set the byte order + index.order(ByteOrder.LITTLE_ENDIAN); + m_encoder = EncoderJNI.initializeEncoder( (byte) m_aSource.getModuleForRouting(), m_aSource.getChannelForRouting(), (byte) (m_aSource.getAnalogTriggerForRouting() ? 1 : 0), (byte) m_bSource.getModuleForRouting(), m_bSource.getChannelForRouting(), (byte) (m_bSource.getAnalogTriggerForRouting() ? 1 : 0), - (byte) (reverseDirection ? 1 : 0), index, status); - HALUtil.checkStatus(status); - m_index = index.get(); + (byte) (reverseDirection ? 1 : 0), index.asIntBuffer(), status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + m_index = index.asIntBuffer().get(0); m_counter = null; break; case EncodingType.k2X_val: @@ -511,9 +514,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, m_counter.free(); m_counter = null; } else { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.freeEncoder(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + EncoderJNI.freeEncoder(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -524,9 +529,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { m_counter.start(); } else { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.startEncoder(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + EncoderJNI.startEncoder(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -537,9 +544,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { m_counter.stop(); } else { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.stopEncoder(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + EncoderJNI.stopEncoder(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -554,9 +563,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { value = m_counter.get(); } else { - IntBuffer status = IntBuffer.allocate(1); - value = HALLibrary.getEncoder(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + value = EncoderJNI.getEncoder(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } return value; } @@ -580,9 +591,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { m_counter.reset(); } else { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.resetEncoder(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + EncoderJNI.resetEncoder(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -602,9 +615,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { measuredPeriod = m_counter.getPeriod(); } else { - IntBuffer status = IntBuffer.allocate(1); - measuredPeriod = HALLibrary.getEncoderPeriod(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + measuredPeriod = EncoderJNI.getEncoderPeriod(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } return measuredPeriod / decodingScaleFactor(); } @@ -626,10 +641,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { m_counter.setMaxPeriod(maxPeriod * decodingScaleFactor()); } else { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary - .setEncoderMaxPeriod(m_encoder, (float) maxPeriod, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + EncoderJNI.setEncoderMaxPeriod(m_encoder, maxPeriod, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); } } @@ -645,9 +661,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { return m_counter.getStopped(); } else { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getEncoderStopped(m_encoder, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = EncoderJNI.getEncoderStopped(m_encoder, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } } @@ -661,9 +679,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, if (m_counter != null) { return m_counter.getDirection(); } else { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getEncoderDirection(m_encoder, status) != 0; - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + boolean value = EncoderJNI.getEncoderDirection(m_encoder, status.asIntBuffer()) != 0; + HALUtil.checkStatus(status.asIntBuffer()); return value; } } @@ -766,14 +786,16 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, public void setSamplesToAverage(int samplesToAverage) { switch (m_encodingType.value) { case EncodingType.k4X_val: - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setEncoderSamplesToAverage(m_encoder, samplesToAverage, - status); - if (status.get() == HALLibrary.PARAMETER_OUT_OF_RANGE) { + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + EncoderJNI.setEncoderSamplesToAverage(m_encoder, samplesToAverage, + status.asIntBuffer()); + if (status.get() == HALUtil.PARAMETER_OUT_OF_RANGE) { throw new BoundaryException(BoundaryException.getMessage( samplesToAverage, 1, 127)); } - HALUtil.checkStatus(status); + HALUtil.checkStatus(status.asIntBuffer()); break; case EncodingType.k1X_val: case EncodingType.k2X_val: @@ -793,10 +815,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, public int getSamplesToAverage() { switch (m_encodingType.value) { case EncodingType.k4X_val: - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary - .getEncoderSamplesToAverage(m_encoder, status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = EncoderJNI.getEncoderSamplesToAverage(m_encoder, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; case EncodingType.k1X_val: case EncodingType.k2X_val: diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/GearTooth.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/GearTooth.java index e5df96a1b6..6561c1a105 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/GearTooth.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/GearTooth.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.parsing.ISensor; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Gyro.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Gyro.java index b0eca93ab3..82840ab7fb 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Gyro.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Gyro.java @@ -6,7 +6,7 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicColorSensor.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicColorSensor.java index 0c42aba520..27ddf8896e 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicColorSensor.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicColorSensor.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicCompass.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicCompass.java index bf3d6ce04b..9dcf636400 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicCompass.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/HiTechnicCompass.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/I2C.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/I2C.java index 6c2c9cd81e..31899fdbf5 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/I2C.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/I2C.java @@ -9,10 +9,11 @@ package edu.wpi.first.wpilibj; import java.nio.ByteBuffer; import java.nio.IntBuffer; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.hal.HALUtil; +import edu.wpi.first.wpilibj.hal.I2CJNI; import edu.wpi.first.wpilibj.util.BoundaryException; /** @@ -80,12 +81,12 @@ public class I2C extends SensorBase { ByteBuffer dataReceivedBuffer = ByteBuffer.allocate(1); IntBuffer status = IntBuffer.allocate(1); - aborted = HALLibrary + aborted = I2CJNI .doI2CTransactionWithModule((byte) m_module.m_moduleNumber, (byte) m_deviceAddress, (byte) (m_compatibilityMode ? 1 : 0), dataToSendBuffer, (byte) sendSize, dataReceivedBuffer, (byte) receiveSize, status) != 0; - if (status.get() == HALLibrary.PARAMETER_OUT_OF_RANGE) { + if (status.get() == HALUtil.PARAMETER_OUT_OF_RANGE) { if (sendSize > 6) { throw new BoundaryException(BoundaryException.getMessage( sendSize, 0, 6)); diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java index 8d961a79e6..f38b2c06b5 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java @@ -8,11 +8,10 @@ package edu.wpi.first.wpilibj; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.hal.HALLibrary; -import edu.wpi.first.wpilibj.hal.HALLibrary.InterruptHandlerFunction; +import edu.wpi.first.wpilibj.hal.InterruptJNI; +import edu.wpi.first.wpilibj.hal.InterruptJNI.InterruptHandlerFunction; import edu.wpi.first.wpilibj.hal.HALUtil; /** @@ -23,7 +22,7 @@ public abstract class InterruptableSensorBase extends SensorBase { /** * The interrupt resource */ - protected Pointer m_interrupt; + protected ByteBuffer m_interrupt; /** * The interrupt manager resource */ @@ -35,7 +34,7 @@ public abstract class InterruptableSensorBase extends SensorBase { /** * Resource manager */ - protected static Resource interrupts = new Resource(HALLibrary.interrupt_kNumSystems.get()); + protected static Resource interrupts = new Resource(8); /** * Create a new InterrupatableSensorBase @@ -57,7 +56,7 @@ public abstract class InterruptableSensorBase extends SensorBase { } // Expects the calling leaf class to allocate an interrupt index. IntBuffer status = IntBuffer.allocate(1); - m_interrupt = HALLibrary.initializeInterrupts(m_interruptIndex, + m_interrupt = InterruptJNI.initializeInterrupts(m_interruptIndex, (byte) (watcher ? 1 : 0), status); HALUtil.checkStatus(status); } @@ -71,7 +70,7 @@ public abstract class InterruptableSensorBase extends SensorBase { throw new IllegalStateException(); } IntBuffer status = IntBuffer.allocate(1); - HALLibrary.cleanInterrupts(m_interrupt, status); + InterruptJNI.cleanInterrupts(m_interrupt, status); HALUtil.checkStatus(status); } @@ -87,7 +86,7 @@ public abstract class InterruptableSensorBase extends SensorBase { throw new IllegalStateException(); } IntBuffer status = IntBuffer.allocate(1); - HALLibrary.waitForInterrupt(m_interrupt, (float) timeout, status); + InterruptJNI.waitForInterrupt(m_interrupt, (float) timeout, status); HALUtil.checkStatus(status); } @@ -101,7 +100,7 @@ public abstract class InterruptableSensorBase extends SensorBase { throw new IllegalStateException(); } IntBuffer status = IntBuffer.allocate(1); - HALLibrary.enableInterrupts(m_interrupt, status); + InterruptJNI.enableInterrupts(m_interrupt, status); HALUtil.checkStatus(status); } @@ -113,7 +112,7 @@ public abstract class InterruptableSensorBase extends SensorBase { throw new IllegalStateException(); } IntBuffer status = IntBuffer.allocate(1); - HALLibrary.disableInterrupts(m_interrupt, status); + InterruptJNI.disableInterrupts(m_interrupt, status); HALUtil.checkStatus(status); } @@ -128,7 +127,7 @@ public abstract class InterruptableSensorBase extends SensorBase { throw new IllegalStateException(); } IntBuffer status = IntBuffer.allocate(1); - double timestamp = HALLibrary.readInterruptTimestamp(m_interrupt, status); + double timestamp = InterruptJNI.readInterruptTimestamp(m_interrupt, status); HALUtil.checkStatus(status); return timestamp; } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/IterativeRobot.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/IterativeRobot.java index 0e936de8ec..7fec084625 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/IterativeRobot.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/IterativeRobot.java @@ -6,9 +6,9 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; @@ -94,7 +94,7 @@ public class IterativeRobot extends RobotBase { m_testInitialized = false; } if (nextPeriodReady()) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramDisabled(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramDisabled(); disabledPeriodic(); didDisabledPeriodic = true; } @@ -110,7 +110,7 @@ public class IterativeRobot extends RobotBase { m_disabledInitialized = false; } if (nextPeriodReady()) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramTest(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramTest(); testPeriodic(); didTestPeriodic = true; } @@ -129,7 +129,8 @@ public class IterativeRobot extends RobotBase { m_disabledInitialized = false; } if (nextPeriodReady()) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramAutonomous(); + getWatchdog().feed(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramAutonomous(); autonomousPeriodic(); didAutonomousPeriodic = true; } @@ -145,7 +146,8 @@ public class IterativeRobot extends RobotBase { m_disabledInitialized = false; } if (nextPeriodReady()) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramTeleop(); + getWatchdog().feed(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramTeleop(); teleopPeriodic(); didTeleopPeriodic = true; } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Jaguar.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Jaguar.java index cc89711abc..adc616e5f5 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Jaguar.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Jaguar.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.parsing.IDeviceController; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Joystick.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Joystick.java index 99ab2ec46b..8864e9d79d 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Joystick.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Joystick.java @@ -6,7 +6,7 @@ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.parsing.IInputOutput; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Module.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Module.java index 05299fae3c..3f26f73c9d 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Module.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Module.java @@ -7,8 +7,8 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tModuleType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tModuleType; /** * Base class for AnalogModule and DigitalModule. @@ -20,7 +20,7 @@ public class Module extends SensorBase { /** * An array holding the object representing each module */ - protected static Module[] m_modules = new Module[tModuleType.kModuleType_Solenoid * FRC_NetworkCommunicationsLibrary.kMaxModuleNumber + (FRC_NetworkCommunicationsLibrary.kMaxModuleNumber - 1)]; + protected static Module[] m_modules = new Module[tModuleType.kModuleType_Solenoid * FRCNetworkCommunicationsLibrary.kMaxModuleNumber + (FRCNetworkCommunicationsLibrary.kMaxModuleNumber - 1)]; /** * The module number of the module */ @@ -86,8 +86,8 @@ public class Module extends SensorBase { * @return The index into m_modules. */ private static int toIndex(int moduleType, int moduleNumber) { - if(moduleNumber == 0 || moduleNumber > FRC_NetworkCommunicationsLibrary.kMaxModuleNumber) + if(moduleNumber == 0 || moduleNumber > FRCNetworkCommunicationsLibrary.kMaxModuleNumber) return 0; - return moduleType * FRC_NetworkCommunicationsLibrary.kMaxModuleNumber + (moduleNumber - 1); + return moduleType * FRCNetworkCommunicationsLibrary.kMaxModuleNumber + (moduleNumber - 1); } } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PIDController.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PIDController.java index bdc8376d27..6e0e242c0b 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PIDController.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PIDController.java @@ -8,7 +8,7 @@ package edu.wpi.first.wpilibj; import java.util.TimerTask; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; import edu.wpi.first.wpilibj.parsing.IUtility; @@ -201,7 +201,7 @@ public class PIDController implements IUtility, LiveWindowSendable, Controller { * This should only be called by the PIDTask * and is created during initialization. */ - protected void calculate() { + private void calculate() { boolean enabled; PIDSource pidInput; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PWM.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PWM.java index adc94b0bf0..9cd76fff2b 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PWM.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/PWM.java @@ -7,9 +7,9 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.PWMJNI; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; import edu.wpi.first.wpilibj.tables.ITable; import edu.wpi.first.wpilibj.tables.ITableListener; @@ -39,7 +39,7 @@ public class PWM extends SensorBase implements LiveWindowSendable { * tests running for the first time. */ - private static Resource allocated = new Resource((HALLibrary.dio_kNumSystems.get() * kPwmChannels)); + private static Resource allocated = new Resource( kPwmChannels); /** * Represents the amount to multiply the minimum servo-pulse pwm period by. diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Preferences.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Preferences.java index 4e285a199c..4893b55a9c 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Preferences.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Preferences.java @@ -15,7 +15,7 @@ import java.io.OutputStream; import java.util.Hashtable; import java.util.Vector; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.networktables.NetworkTable; import edu.wpi.first.wpilibj.tables.ITable; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Relay.java index c3e82b5346..68166def20 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Relay.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.livewindow.LiveWindow; @@ -122,8 +122,7 @@ public class Relay extends SensorBase implements IDeviceController, private int m_channel; private Direction m_direction; private DigitalModule m_module; - private static Resource relayChannels = new Resource( - HALLibrary.dio_kNumSystems.get() * kRelayChannels * 2); + private static Resource relayChannels = new Resource(kRelayChannels * 2); /** * Common relay initialization method. This code is common to all Relay diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Resource.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Resource.java index 9d29e154c6..ca94c648f2 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Resource.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Resource.java @@ -108,4 +108,5 @@ public class Resource { throw new AllocationException("No resource available to be freed"); m_numAllocated[index] = false; } + } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotBase.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotBase.java index 839982b8fa..91c5bb3b0d 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotBase.java @@ -9,14 +9,16 @@ package edu.wpi.first.wpilibj; import java.io.IOException; import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; import java.util.Enumeration; import java.util.jar.Manifest; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.networktables.NetworkTable; /** @@ -39,6 +41,7 @@ public abstract class RobotBase { public final static String ERRORS_TO_DRIVERSTATION_PROP = "first.driverstation.senderrors"; protected final DriverStation m_ds; + private final Watchdog m_watchdog = Watchdog.getInstance(); /** * Constructor for a generic robot program. @@ -58,6 +61,7 @@ public abstract class RobotBase { // } NetworkTable.setServerMode();//must be before b m_ds = DriverStation.getInstance(); + m_watchdog.setEnabled(false); NetworkTable.getTable(""); // forces network tables to initialize NetworkTable.getTable("LiveWindow").getSubTable("~STATUS~").putBoolean("LW Enabled", false); } @@ -69,13 +73,23 @@ public abstract class RobotBase { } /** - * @deprecated This has been deprecated in favor of {@link #isEnabled()} * Check on the overall status of the system. * * @return Is the system active (i.e. PWM motor outputs, etc. enabled)? */ public boolean isSystemActive() { - return isEnabled(); + return m_watchdog.isSystemActive(); + } + + /** + * Return the instance of the Watchdog timer. + * Get the watchdog timer so the user program can either disable it or feed it when + * necessary. + * + * @return The Watchdog timer. + */ + public Watchdog getWatchdog() { + return m_watchdog; } /** @@ -152,9 +166,108 @@ public abstract class RobotBase { */ public static void main(String args[]) { // TODO: expose main to teams?{ boolean errorOnExit = false; + + /* JNI Testing */ + boolean booleanTest = true; + byte byteTest = (byte)0xa5; + char charTest = 'X'; + short shortTest = 12346; + int intTest = 2987654; + long longTest = 897678665; + float floatTest = 45.123456f; + double doubleTest = 234E16; + + FRCNetworkCommunicationsLibrary.JNIValueParameterTest(booleanTest, byteTest, charTest, shortTest, + intTest, longTest, floatTest, doubleTest); + + boolean booleanReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnBooleanTest(booleanTest); + System.out.println("Boolean Return: " + booleanReturn ); - HALLibrary.FRC_NetworkCommunication_Reserve(); - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_observeUserProgramStarting(); + byte byteReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnByteTest(byteTest); + System.out.println("Byte Return: " + byteReturn ); + + char charReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnCharTest(charTest); + System.out.println("Char Return: " + charReturn ); + + short shortReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnShortTest(shortTest); + System.out.println("Short Return: " + shortReturn ); + + int intReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnIntTest(intTest); + System.out.println("Int Return: " + intReturn ); + + long longReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnLongTest(longTest); + System.out.println("Long Return: " + longReturn ); + + float floatReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnFloatTest(floatTest); + System.out.println("Float Return: " + floatReturn ); + + double doubleReturn = FRCNetworkCommunicationsLibrary.JNIValueReturnDoubleTest(doubleTest); + System.out.println("Double Return: " + doubleReturn ); + + + + String testValue = "This is a test string"; + + String returnValue = FRCNetworkCommunicationsLibrary.JNIObjectReturnStringTest(testValue); + + System.out.println("String Return:" + returnValue); + + ByteBuffer directBuffer = ByteBuffer.allocateDirect(4); + + directBuffer.put(0, (byte)0xFA); + directBuffer.put(1, (byte)0xAB); + directBuffer.put(2, (byte)0xB4); + directBuffer.put(3, (byte)0xCD); + + ByteBuffer returnBuffer1 = FRCNetworkCommunicationsLibrary.JNIObjectReturnByteBufferTest(directBuffer); + + System.out.println("Return Buffer Capacity: " + returnBuffer1.capacity()); + System.out.println("ByteBuffer1 Return0: " + returnBuffer1.get(0) ); + System.out.println("ByteBuffer1 Return1: " + returnBuffer1.get(1) ); + System.out.println("ByteBuffer1 Return2: " + returnBuffer1.get(2) ); + System.out.println("ByteBuffer1 Return3: " + returnBuffer1.get(3) ); + + + ByteBuffer directByteBuffer = ByteBuffer.allocateDirect(4); + // set to little endian for C++ + directByteBuffer.order(ByteOrder.LITTLE_ENDIAN); + + directByteBuffer.putInt(0,2874933); + + System.out.println("Param In: " + directByteBuffer.getInt(0)); + System.out.println("Param In Byte0: " + directByteBuffer.get(0) ); + System.out.println("Param In Byte1: " + directByteBuffer.get(1) ); + System.out.println("Param In Byte2: " + directByteBuffer.get(2) ); + System.out.println("Param In Byte3: " + directByteBuffer.get(3) ); + + + ByteBuffer returnBuffer2 = FRCNetworkCommunicationsLibrary.JNIObjectAndParamReturnIntBufferTest(directByteBuffer.asIntBuffer()); + + System.out.println("Param Out: " + directByteBuffer.getInt(0)); + + + + System.out.println("Return Buffer Capacity: " + returnBuffer2.capacity()); + System.out.println("ByteBuffer2 Return0: " + returnBuffer2.get(0) ); + System.out.println("ByteBuffer2 Return1: " + returnBuffer2.get(1) ); + System.out.println("ByteBuffer2 Return2: " + returnBuffer2.get(2) ); + System.out.println("ByteBuffer2 Return3: " + returnBuffer2.get(3) ); + + System.out.println("Byte Order from C++" + returnBuffer2.order().toString()); + System.out.println("ByteBuffer2 as Int" + returnBuffer2.getInt(0)); + // change to little endian + returnBuffer2.order(ByteOrder.LITTLE_ENDIAN); + System.out.println("ByteBuffer2 as Int" + returnBuffer2.getInt(0)); + + + + + + /* End JNI Testing */ + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationReserve(); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramStarting(); + Watchdog.getInstance().setExpiration(0.1); + Watchdog.getInstance().setEnabled(false); UsageReporting.report(tResourceType.kResourceType_Language, tInstances.kLanguage_Java); diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotDrive.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotDrive.java index 0767e2d628..07d04e4f96 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotDrive.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/RobotDrive.java @@ -8,8 +8,8 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.wpilibj.can.CANNotInitializedException; import edu.wpi.first.wpilibj.can.CANTimeoutException; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.parsing.IUtility; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SensorBase.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SensorBase.java index 85261f67c7..2948cc9267 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SensorBase.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SensorBase.java @@ -7,7 +7,8 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.hal.HALLibrary; +import edu.wpi.first.wpilibj.hal.DIOJNI; +import edu.wpi.first.wpilibj.hal.AnalogJNI; /** * Base class for all sensors. @@ -27,20 +28,20 @@ public abstract class SensorBase { // TODO: Refactor /** * Number of digital channels per digital sidecar */ - public static final int kDigitalChannels = 14; + public static final int kDigitalChannels = 10; /** * Number of digital modules * XXX: This number is incorrect. We need to find the correct number. */ - public static final int kDigitalModules = 2; + public static final int kDigitalModules = 1; /** * Number of analog channels per module */ - public static final int kAnalogChannels = 8; + public static final int kAnalogChannels = 4; /** * Number of analog modules */ - public static final int kAnalogModules = 2; + public static final int kAnalogModules = 1; /** * Number of solenoid channels per module */ @@ -56,7 +57,7 @@ public abstract class SensorBase { // TODO: Refactor /** * Number of relay channels per sidecar */ - public static final int kRelayChannels = 8; + public static final int kRelayChannels = 4; private static int m_defaultAnalogModule = 1; private static int m_defaultDigitalModule = 1; @@ -111,7 +112,7 @@ public abstract class SensorBase { // TODO: Refactor * @param moduleNumber The digital module module number to check. */ protected static void checkDigitalModule(final int moduleNumber) { - if(HALLibrary.checkDigitalModule((byte) moduleNumber) != 1) + if(DIOJNI.checkDigitalModule((byte) moduleNumber) != 1) System.err.println("Digital module " + moduleNumber + " is not present."); } @@ -142,7 +143,7 @@ public abstract class SensorBase { // TODO: Refactor * @param moduleNumber The analog module module number to check. */ protected static void checkAnalogModule(final int moduleNumber) { - if(HALLibrary.checkAnalogModule((byte) (moduleNumber - 1)) != 0) { + if(AnalogJNI.checkAnalogModule((byte) (moduleNumber - 1)) != 0) { System.err.println("Analog module " + moduleNumber + " is not present."); } } @@ -154,9 +155,9 @@ public abstract class SensorBase { // TODO: Refactor * @param moduleNumber The solenoid module module number to check. */ protected static void checkSolenoidModule(final int moduleNumber) { - if(HALLibrary.checkSolenoidModule((byte) (moduleNumber - 1)) != 0) { - System.err.println("Solenoid module " + moduleNumber + " is not present."); - } +// if(HALLibrary.checkSolenoidModule((byte) (moduleNumber - 1)) != 0) { +// System.err.println("Solenoid module " + moduleNumber + " is not present."); +// } } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Servo.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Servo.java index 6a0e0844ca..e4aa3bb78c 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Servo.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Servo.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.parsing.IDevice; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SimpleRobot.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SimpleRobot.java index c00bcdf72e..21d00f5c87 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SimpleRobot.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SimpleRobot.java @@ -8,8 +8,8 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.livewindow.LiveWindow; /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Solenoid.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Solenoid.java index f4cbed9443..2a3b4a56b0 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Solenoid.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Solenoid.java @@ -8,12 +8,10 @@ package edu.wpi.first.wpilibj; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; -import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; @@ -31,30 +29,30 @@ import edu.wpi.first.wpilibj.util.CheckedAllocationException; public class Solenoid extends SolenoidBase implements LiveWindowSendable { private int m_channel; ///< The channel on the module to control. - private Pointer m_port; + private ByteBuffer m_port; /** * Common function to implement constructor behavior. */ private synchronized void initSolenoid() { - checkSolenoidModule(m_moduleNumber); - checkSolenoidChannel(m_channel); - - try { - m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_channel - 1); - } catch (CheckedAllocationException e) { - throw new AllocationException( - "Solenoid channel " + m_channel + " on module " + m_moduleNumber + " is already allocated"); - } - - IntBuffer status = IntBuffer.allocate(1); - m_port = HALLibrary.getPortWithModule((byte) m_moduleNumber, (byte) m_channel); - HALUtil.checkStatus(status); - HALLibrary.initializeSolenoidPort(m_port, status); - HALUtil.checkStatus(status); - - LiveWindow.addActuator("Solenoid", m_moduleNumber, m_channel, this); - UsageReporting.report(tResourceType.kResourceType_Solenoid, m_channel, m_moduleNumber - 1); +// checkSolenoidModule(m_moduleNumber); +// checkSolenoidChannel(m_channel); +// +// try { +// m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_channel - 1); +// } catch (CheckedAllocationException e) { +// throw new AllocationException( +// "Solenoid channel " + m_channel + " on module " + m_moduleNumber + " is already allocated"); +// } +// +// IntBuffer status = IntBuffer.allocate(1); +// m_port = SolenoidJNI.getPortWithModule((byte) m_moduleNumber, (byte) m_channel); +// HALUtil.checkStatus(status); +// SolenoidJNI.initializeSolenoidPort(m_port, status); +// HALUtil.checkStatus(status); +// +// LiveWindow.addActuator("Solenoid", m_moduleNumber, m_channel, this); +// UsageReporting.report(tResourceType.kResourceType_Solenoid, m_channel, m_moduleNumber - 1); } /** @@ -84,7 +82,7 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable { * Destructor. */ public synchronized void free() { - m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_channel - 1); + // m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_channel - 1); } /** @@ -93,9 +91,9 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable { * @param on Turn the solenoid output off or on. */ public void set(boolean on) { - IntBuffer status = IntBuffer.allocate(1); - HALLibrary.setSolenoid(m_port, (byte) (on ? 1 : 0), status); - HALUtil.checkStatus(status); +// IntBuffer status = IntBuffer.allocate(1); +// SolenoidJNI.setSolenoid(m_port, (byte) (on ? 1 : 0), status); +// HALUtil.checkStatus(status); } /** @@ -104,9 +102,10 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable { * @return The current value of the solenoid. */ public boolean get() { - IntBuffer status = IntBuffer.allocate(1); - boolean value = HALLibrary.getSolenoid(m_port, status) != 0; - HALUtil.checkStatus(status); + boolean value = false; +// IntBuffer status = IntBuffer.allocate(1); +// boolean value = SolenoidJNI.getSolenoid(m_port, status) != 0; +// HALUtil.checkStatus(status); return value; } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java index 2fb63fca55..e332555637 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java @@ -8,10 +8,8 @@ package edu.wpi.first.wpilibj; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -import com.sun.jna.Pointer; - -import edu.wpi.first.wpilibj.hal.HALLibrary; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.parsing.IDeviceController; @@ -21,10 +19,10 @@ import edu.wpi.first.wpilibj.parsing.IDeviceController; */ public abstract class SolenoidBase extends SensorBase implements IDeviceController { - private Pointer[] m_ports; + private ByteBuffer[] m_ports; protected int m_moduleNumber; ///< The number of the solenoid module being used. // XXX: Move this to be both HAL calls - protected Resource m_allocated = new Resource(HALLibrary.solenoid_kNumDO7_0Elements.get() * SensorBase.kSolenoidChannels); + //protected Resource m_allocated = new Resource(SolenoidJNI.getModuleCount() * SensorBase.kSolenoidChannels); /** * Constructor. @@ -32,14 +30,14 @@ public abstract class SolenoidBase extends SensorBase implements IDeviceControll * @param moduleNumber The number of the solenoid module to use. */ public SolenoidBase(final int moduleNumber) { - m_moduleNumber = moduleNumber; - m_ports = new Pointer[SensorBase.kSolenoidChannels]; - for (int i = 0; i < SensorBase.kSolenoidChannels; i++) { - Pointer port = HALLibrary.getPortWithModule((byte) moduleNumber, (byte) (i+1)); - IntBuffer status = IntBuffer.allocate(1); - m_ports[i] = HALLibrary.initializeSolenoidPort(port, status); - HALUtil.checkStatus(status); - } +// m_moduleNumber = moduleNumber; +// m_ports = new ByteBuffer[SensorBase.kSolenoidChannels]; +// for (int i = 0; i < SensorBase.kSolenoidChannels; i++) { +// ByteBuffer port = SolenoidJNI.getPortWithModule((byte) moduleNumber, (byte) (i+1)); +// IntBuffer status = IntBuffer.allocate(1); +// m_ports[i] = SolenoidJNI.initializeSolenoidPort(port, status); +// HALUtil.checkStatus(status); +// } } /** @@ -49,13 +47,13 @@ public abstract class SolenoidBase extends SensorBase implements IDeviceControll * @param mask The channels you want to be affected. */ protected synchronized void set(int value, int mask) { - IntBuffer status = IntBuffer.allocate(1); - for (int i = 0; i < SensorBase.kSolenoidChannels; i++) { - int local_mask = 1 << i; - if ((mask & local_mask) != 0) - HALLibrary.setSolenoid(m_ports[i], (byte) (value & local_mask), status); - } - HALUtil.checkStatus(status); +// IntBuffer status = IntBuffer.allocate(1); +// for (int i = 0; i < SensorBase.kSolenoidChannels; i++) { +// int local_mask = 1 << i; +// if ((mask & local_mask) != 0) +// SolenoidJNI.setSolenoid(m_ports[i], (byte) (value & local_mask), status); +// } +// HALUtil.checkStatus(status); } /** @@ -65,11 +63,11 @@ public abstract class SolenoidBase extends SensorBase implements IDeviceControll */ public byte getAll() { byte value = 0; - IntBuffer status = IntBuffer.allocate(1); - for (int i = 0; i < SensorBase.kSolenoidChannels; i++) { - value |= HALLibrary.getSolenoid(m_ports[i], status) << i; - } - HALUtil.checkStatus(status); +// IntBuffer status = IntBuffer.allocate(1); +// for (int i = 0; i < SensorBase.kSolenoidChannels; i++) { +// value |= SolenoidJNI.getSolenoid(m_ports[i], status) << i; +// } +// HALUtil.checkStatus(status); return value; } @@ -88,7 +86,9 @@ public abstract class SolenoidBase extends SensorBase implements IDeviceControll * @return The current value of all 8 solenoids on the specified module. */ public static byte getAllFromModule(int moduleNumber) { - checkSolenoidModule(moduleNumber); - throw new RuntimeException("Not supported right now."); + byte value = 0; +// checkSolenoidModule(moduleNumber); +// throw new RuntimeException("Not supported right now."); + return value; } } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Talon.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Talon.java index 48aca0edc0..00c5e2953a 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Talon.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Talon.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.parsing.IDeviceController; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java index a97b96df08..632e6d26e3 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Utility.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Utility.java index 1caee4e47f..e84cd92180 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Utility.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Utility.java @@ -7,6 +7,8 @@ package edu.wpi.first.wpilibj; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.IntBuffer; import edu.wpi.first.wpilibj.hal.HALLibrary; @@ -27,9 +29,11 @@ public class Utility implements IUtility { * @return FPGA Version number. */ int getFPGAVersion() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getFPGAVersion(status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = HALUtil.getFPGAVersion(status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return value; } @@ -41,9 +45,11 @@ public class Utility implements IUtility { * @return FPGA Revision number. */ long getFPGARevision() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getFPGARevision(status); - HALUtil.checkStatus(status); + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + int value = HALUtil.getFPGARevision(status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); return (long) value; } @@ -53,10 +59,13 @@ public class Utility implements IUtility { * @return The current time in microseconds according to the FPGA. */ public static long getFPGATime() { - IntBuffer status = IntBuffer.allocate(1); - int value = HALLibrary.getFPGATime(status); - HALUtil.checkStatus(status); - return (long) value; + ByteBuffer status = ByteBuffer.allocateDirect(4); + // set the byte order + status.order(ByteOrder.LITTLE_ENDIAN); + + long value = HALUtil.getFPGATime(status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + return value; } /** diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Victor.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Victor.java index a58409e40f..04b3f6a8e3 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Victor.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/Victor.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.parsing.IDeviceController; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java index 98e7b3d59f..ed576dbd8c 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java @@ -12,8 +12,8 @@ import java.util.Vector; import edu.wpi.first.wpilibj.NamedSendable; import edu.wpi.first.wpilibj.buttons.Trigger.ButtonScheduler; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tInstances; -import edu.wpi.first.wpilibj.communication.FRC_NetworkCommunicationsLibrary.tResourceType; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances; +import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.networktables2.type.NumberArray; import edu.wpi.first.wpilibj.networktables2.type.StringArray; diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java index 0983b6ff90..ea9c132651 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java @@ -1,36 +1,33 @@ package edu.wpi.first.wpilibj.communication; -import com.ochafik.lang.jnaerator.runtime.Structure; -import com.ochafik.lang.jnaerator.runtime.Union; +//import com.ochafik.lang.jnaerator.runtime.Structure; +//import com.ochafik.lang.jnaerator.runtime.Union; +//import com.sun.jna.Pointer; import java.util.Arrays; import java.util.List; /** - * native declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:29
+ * native declaration : src\main\include\NetworkCommunication\FRCComm.h:11
* This file was autogenerated by JNAerator,
* a tool written by Olivier Chafik that uses a few opensource projects..
* For help, please visit NativeLibs4Java , Rococoa, or JNA. */ -public class FRCCommonControlData extends Structure { +public class FRCCommonControlData /*extends Structure*/ { public short packetIndex; /** C type : field1_union */ - public field1_union field1; + public byte control; public byte dsDigitalIn; public short teamID; public byte dsID_Alliance; public byte dsID_Position; - /** C type : field2_union */ - public field2_union field2; + public byte[] stick0Axes = new byte[6]; /** Left-most 4 bits are unused */ public short stick0Buttons; - /** C type : field3_union */ - public field3_union field3; + public byte[] stick1Axes = new byte[6]; /** Left-most 4 bits are unused */ public short stick1Buttons; - /** C type : field4_union */ - public field4_union field4; + public byte[] stick2Axes = new byte[6]; /** Left-most 4 bits are unused */ public short stick2Buttons; - /** C type : field5_union */ - public field5_union field5; + public byte[] stick3Axes = new byte[6]; /** Left-most 4 bits are unused */ public short stick3Buttons; /** Analog inputs are 10 bit right-justified */ @@ -45,38 +42,76 @@ public class FRCCommonControlData extends Structurenative declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:31 */ - public static class field1_union extends Union { + + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:13 */ + public static class field1_union /*extends Union*/ { public byte control; + /** C type : field1_struct */ + public field1_struct field1; + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:16 */ + public static abstract class field1_struct /*extends Structure*/ { + /** Conversion Error : checkVersions:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : test:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : resync:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : fmsAttached:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : autonomous:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : enabled:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : notEStop:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + /** Conversion Error : reset:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ + public field1_struct() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList(); + } + //public field1_struct(Pointer peer) { + // super(peer); + //} + //public static abstract class ByReference extends field1_struct implements Structure.ByReference { + + //}; + //public static abstract class ByValue extends field1_struct implements Structure.ByValue { + + //}; + }; public field1_union() { super(); } + /** @param field1 C type : field1_struct */ + public field1_union(field1_struct field1) { + super(); + this.field1 = field1; + //setType(field1_struct.class); + } public field1_union(byte control) { super(); this.control = control; - setType(Byte.TYPE); + //setType(Byte.TYPE); } - protected ByReference newByReference() { return new ByReference(); } - protected ByValue newByValue() { return new ByValue(); } + //public field1_union(Pointer peer) { + // super(peer); + //} + //protected ByReference newByReference() { return new ByReference(); } + //protected ByValue newByValue() { return new ByValue(); } protected field1_union newInstance() { return new field1_union(); } - public static field1_union[] newArray(int arrayLength) { - return Union.newArray(field1_union.class, arrayLength); - } - public static class ByReference extends field1_union implements Structure.ByReference { + //public static field1_union[] newArray(int arrayLength) { + // return Union.newArray(field1_union.class, arrayLength); + //} + //public static class ByReference extends field1_union implements Structure.ByReference { - }; - public static class ByValue extends field1_union implements Structure.ByValue { + //}; + //public static class ByValue extends field1_union implements Structure.ByValue { - }; + //}; }; - /** native declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:63 */ - public static class field2_union extends Union { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:45 */ + public static class field2_union /*extends Union*/ { /** C type : int8_t[6] */ public byte[] stick0Axes = new byte[6]; /** C type : field1_struct */ public field1_struct field1; - /** native declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:65 */ - public static class field1_struct extends Structure { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:47 */ + public static class field1_struct /*extends Structure*/ { public byte stick0Axis1; public byte stick0Axis2; public byte stick0Axis3; @@ -98,18 +133,21 @@ public class FRCCommonControlData extends Structurenative declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:76 */ - public static class field3_union extends Union { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:58 */ + public static class field3_union /*extends Union*/ { /** C type : int8_t[6] */ public byte[] stick1Axes = new byte[6]; /** C type : field1_struct */ public field1_struct field1; - /** native declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:78 */ - public static class field1_struct extends Structure { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:60 */ + public static class field1_struct /* extends Structure*/ { public byte stick1Axis1; public byte stick1Axis2; public byte stick1Axis3; @@ -170,18 +211,21 @@ public class FRCCommonControlData extends Structurenative declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:89 */ - public static class field4_union extends Union { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:71 */ + public static class field4_union /*extends Union*/ { /** C type : int8_t[6] */ public byte[] stick2Axes = new byte[6]; /** C type : field1_struct */ public field1_struct field1; - /** native declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:91 */ - public static class field1_struct extends Structure { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:73 */ + public static class field1_struct /* extends Structure*/ { public byte stick2Axis1; public byte stick2Axis2; public byte stick2Axis3; @@ -242,18 +289,21 @@ public class FRCCommonControlData extends Structurenative declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:102 */ - public static class field5_union extends Union { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:84 */ + public static class field5_union /* extends Union*/ { /** C type : int8_t[6] */ public byte[] stick3Axes = new byte[6]; /** C type : field1_struct */ public field1_struct field1; - /** native declaration : /home/alex/Projects/WPILib-Development/WPILibC/WPILib/src/main/include/NetworkCommunication/FRCComm.h:104 */ - public static class field1_struct extends Structure { + /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:86 */ + public static class field1_struct /*extends Structure*/ { public byte stick3Axis1; public byte stick3Axis2; public byte stick3Axis3; @@ -314,18 +367,21 @@ public class FRCCommonControlData extends Structure getFieldOrder() { return Arrays.asList("packetIndex", "field1", "dsDigitalIn", "teamID", "dsID_Alliance", "dsID_Position", "field2", "stick0Buttons", "field3", "stick1Buttons", "field4", "stick2Buttons", "field5", "stick3Buttons", "analog1", "analog2", "analog3", "analog4", "cRIOChecksum", "FPGAChecksum0", "FPGAChecksum1", "FPGAChecksum2", "FPGAChecksum3", "versionData"); } - protected ByReference newByReference() { return new ByReference(); } - protected ByValue newByValue() { return new ByValue(); } + //public FRCCommonControlData(Pointer peer) { + // super(peer); + //} + //protected ByReference newByReference() { return new ByReference(); } + //protected ByValue newByValue() { return new ByValue(); } protected FRCCommonControlData newInstance() { return new FRCCommonControlData(); } - public static FRCCommonControlData[] newArray(int arrayLength) { - return Structure.newArray(FRCCommonControlData.class, arrayLength); - } - public static class ByReference extends FRCCommonControlData implements Structure.ByReference { + //public static FRCCommonControlData[] newArray(int arrayLength) { + // return Structure.newArray(FRCCommonControlData.class, arrayLength); + //} + //public static class ByReference extends FRCCommonControlData implements Structure.ByReference { + // + //}; + //public static class ByValue extends FRCCommonControlData implements Structure.ByValue { - }; - public static class ByValue extends FRCCommonControlData implements Structure.ByValue { - - }; + //}; } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/UsageReporting.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/UsageReporting.java index 826fdfa307..6787e76280 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/UsageReporting.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/communication/UsageReporting.java @@ -12,7 +12,7 @@ public class UsageReporting { public static void report(int resource, int instanceNumber, int i, String string) { - FRC_NetworkCommunicationsLibrary.FRC_NetworkCommunication_nUsageReporting_report((byte)resource, (byte) instanceNumber, (byte) i, string); + FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationUsageReportingReport((byte)resource, (byte) instanceNumber, (byte) i, string); } } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALLibrary.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALLibrary.java index 4861126c67..84d07289db 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALLibrary.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALLibrary.java @@ -1,2287 +1,526 @@ package edu.wpi.first.wpilibj.hal; -import com.ochafik.lang.jnaerator.runtime.LibraryExtractor; -import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper; -import com.ochafik.lang.jnaerator.runtime.globals.GlobalDouble; -import com.ochafik.lang.jnaerator.runtime.globals.GlobalInt; -import com.sun.jna.Callback; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; -import com.sun.jna.ptr.NativeLongByReference; +//import com.ochafik.lang.jnaerator.runtime.LibraryExtractor; +//import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper; +//import com.ochafik.lang.jnaerator.runtime.globals.GlobalDouble; +//import com.ochafik.lang.jnaerator.runtime.globals.GlobalInt; +//import com.sun.jna.Callback; +//import com.sun.jna.Library; +//import com.sun.jna.Native; +//import com.sun.jna.NativeLibrary; +//import com.sun.jna.Pointer; +//import com.sun.jna.PointerType; +//import com.sun.jna.ptr.IntByReference; +//import com.sun.jna.ptr.LongByReference; import java.nio.ByteBuffer; import java.nio.IntBuffer; -import java.nio.LongBuffer; /** * JNA Wrapper for library HAL
* This file was autogenerated by JNAerator,
* a tool written by Olivier Chafik that uses a few opensource projects..
* For help, please visit NativeLibs4Java , Rococoa, or JNA. */ -public class HALLibrary implements Library { - public static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("HALAthenaJava", true, HALLibrary.class); - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(HALLibrary.JNA_LIBRARY_NAME, MangledFunctionMapper.DEFAULT_OPTIONS); +public class HALLibrary /* implements Library */ { + //public static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("HALAthenaJava", true, HALLibrary.class); + //public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(HALLibrary.JNA_LIBRARY_NAME, MangledFunctionMapper.DEFAULT_OPTIONS); static { - Native.register(HALLibrary.JNA_LIBRARY_NAME); + System.loadLibrary("JNIWrappers"); + // Native.register(HALLibrary.class, HALLibrary.JNA_NATIVE_LIB); } /** - * native declaration : target/native/include/HAL/Analog.h
- * enum values - */ - public static interface AnalogTriggerType { - /** native declaration : target/native/include/HAL/Analog.h:36 */ - public static final int kInWindow = 0; - /** native declaration : target/native/include/HAL/Analog.h:36 */ - public static final int kState = 1; - /** native declaration : target/native/include/HAL/Analog.h:36 */ - public static final int kRisingPulse = 2; - /** native declaration : target/native/include/HAL/Analog.h:36 */ - public static final int kFallingPulse = 3; - }; - /** - * native declaration : target/native/include/HAL/Digital.h
+ * native declaration : AthenaJava\target\native\include\HAL\Digital.h:148
* enum values */ public static interface Mode { - /** native declaration : target/native/include/HAL/Digital.h:42 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:144 */ public static final int kTwoPulse = 0; - /** native declaration : target/native/include/HAL/Digital.h:42 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:145 */ public static final int kSemiperiod = 1; - /** native declaration : target/native/include/HAL/Digital.h:42 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:146 */ public static final int kPulseLength = 2; - /** native declaration : target/native/include/HAL/Digital.h:42 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:147 */ public static final int kExternalDirection = 3; }; /** - * native declaration : target/native/include/HAL/Digital.h:91
+ * native declaration : AthenaJava\target\native\include\HAL\Digital.h:235
* enum values */ public static interface tSPIConstants { - /** native declaration : target/native/include/HAL/Digital.h:91 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:233 */ public static final int kReceiveFIFODepth = 512; - /** native declaration : target/native/include/HAL/Digital.h:91 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:234 */ public static final int kTransmitFIFODepth = 512; }; /** - * native declaration : target/native/include/HAL/Digital.h:92
+ * native declaration : AthenaJava\target\native\include\HAL\Digital.h:241
* enum values */ public static interface tFrameMode { - /** native declaration : target/native/include/HAL/Digital.h:92 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:237 */ public static final int kChipSelect = 0; - /** native declaration : target/native/include/HAL/Digital.h:92 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:238 */ public static final int kPreLatchPulse = 1; - /** native declaration : target/native/include/HAL/Digital.h:92 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:239 */ public static final int kPostLatchPulse = 2; - /** native declaration : target/native/include/HAL/Digital.h:92 */ + /** native declaration : AthenaJava\target\native\include\HAL\Digital.h:240 */ public static final int kPreAndPostLatchPulse = 3; }; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String NO_AVAILABLE_RESOURCES_MESSAGE = "No available resources to allocate"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String INCOMPATIBLE_STATE_MESSAGE = "Incompatible State: The operation cannot be completed"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int SPI_WRITE_NO_MOSI = 12; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int PARAMETER_OUT_OF_RANGE = -28; - /** native declaration : target/native/include/HAL/Errors.h */ + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ public static final String NULL_PARAMETER_MESSAGE = "A pointer parameter to a method is NULL"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int ANALOG_TRIGGER_LIMIT_ORDER_ERROR = -10; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int INCOMPATIBLE_STATE = 15; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String VOLTAGE_OUT_OF_RANGE_MESSAGE = "Voltage to convert to raw value is out of range [-10; 10]"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int SAMPLE_RATE_TOO_HIGH = 1; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int NULL_PARAMETER = -5; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String PARAMETER_OUT_OF_RANGE_MESSAGE = "A parameter is out of range."; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String SAMPLE_RATE_TOO_HIGH_MESSAGE = "Analog module sample rate is too high"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String SPI_WRITE_NO_MOSI_MESSAGE = "Cannot write to SPI port with no MOSI output"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String LOOP_TIMING_ERROR_MESSAGE = "Digital module loop timing is not the expected value"; - /** native declaration : target/native/include/HAL/Errors.h */ + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String NO_AVAILABLE_RESOURCES_MESSAGE = "No available resources to allocate"; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String INCOMPATIBLE_STATE_MESSAGE = "Incompatible State: The operation cannot be completed"; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ public static final String ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE = "Attempted to read AnalogTrigger pulse output."; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int ANALOG_TRIGGER_PULSE_OUTPUT_ERROR = -11; - /** native declaration : target/native/include/HAL/Task.h */ - public static final int OK = 0; - /** native declaration : target/native/include/HAL/Task.h */ - public static final int ERROR = (-1); - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int SPI_READ_NO_MISO = 13; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final String SPI_READ_NO_MISO_MESSAGE = "Cannot read from SPI port with no MISO input"; - /** native declaration : target/native/include/HAL/Errors.h */ + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final int ANALOG_TRIGGER_LIMIT_ORDER_ERROR = -10; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ public static final int SPI_READ_NO_DATA = 14; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int NO_AVAILABLE_RESOURCES = -4; - /** native declaration : target/native/include/HAL/Errors.h */ + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String VOLTAGE_OUT_OF_RANGE_MESSAGE = "Voltage to convert to raw value is out of range [-10; 10]"; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ public static final String ANALOG_TRIGGER_LIMIT_ORDER_ERROR_MESSAGE = "AnalogTrigger limits error. Lower limit > Upper Limit"; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int VOLTAGE_OUT_OF_RANGE = 2; - /** native declaration : target/native/include/HAL/Errors.h */ - public static final int LOOP_TIMING_ERROR = 4; - /** native declaration : target/native/include/HAL/Errors.h */ + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final int SPI_WRITE_NO_MOSI = 12; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String PARAMETER_OUT_OF_RANGE_MESSAGE = "A parameter is out of range."; + /** native declaration : AthenaJava\target\native\include\HAL\Task.h */ + public static final int OK = 0; + /** native declaration : AthenaJava\target\native\include\HAL\Task.h */ + public static final int ERROR = (-1); + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String SAMPLE_RATE_TOO_HIGH_MESSAGE = "Analog module sample rate is too high"; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String SPI_WRITE_NO_MOSI_MESSAGE = "Cannot write to SPI port with no MOSI output"; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final int SPI_READ_NO_MISO = 13; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ public static final String SPI_READ_NO_DATA_MESSAGE = "No data available to read from SPI"; - /** native declaration : target/native/include/HAL/Notifier.h:7 */ - public interface initializeNotifier_ProcessQueue_callback extends Callback { - void apply(int uint32_t1, Pointer voidPtr1); - }; - /** native declaration : target/native/include/HAL/Interrupts.h */ - public interface InterruptHandlerFunction extends Callback { - void apply(int interruptAssertedMask, Pointer param); - }; - /** native declaration : target/native/include/HAL/Task.h */ - public interface FUNCPTR extends Callback { - int apply(Object... varargs); - }; - /** - * Original signature : void* initializeAnalogPort(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:7
- * @deprecated use the safer methods {@link #initializeAnalogPort(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #initializeAnalogPort(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeAnalogPort(Pointer port_pointer, IntByReference status); - /** - * Original signature : void* initializeAnalogPort(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:7 - */ - public static native Pointer initializeAnalogPort(Pointer port_pointer, IntBuffer status); - /** - * Original signature : bool checkAnalogModule(uint8_t)
- * native declaration : target/native/include/HAL/Analog.h:8 - */ - public static native byte checkAnalogModule(byte module); - /** - * Original signature : bool checkAnalogChannel(uint32_t)
- * native declaration : target/native/include/HAL/Analog.h:9 - */ - public static native byte checkAnalogChannel(int pin); - /** - * Original signature : void setAnalogSampleRate(float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:11
- * @deprecated use the safer methods {@link #setAnalogSampleRate(float, java.nio.IntBuffer)} and {@link #setAnalogSampleRate(float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogSampleRate(double samplesPerSecond, IntByReference status); - /** - * Original signature : void setAnalogSampleRate(float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:11 - */ - public static native void setAnalogSampleRate(double samplesPerSecond, IntBuffer status); - /** - * Original signature : float getAnalogSampleRate(int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:12
- * @deprecated use the safer methods {@link #getAnalogSampleRate(java.nio.IntBuffer)} and {@link #getAnalogSampleRate(com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native float getAnalogSampleRate(IntByReference status); - /** - * Original signature : float getAnalogSampleRate(int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:12 - */ - public static native float getAnalogSampleRate(IntBuffer status); - /** - * Original signature : void setAnalogSampleRateWithModule(uint8_t, float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:13
- * @deprecated use the safer methods {@link #setAnalogSampleRateWithModule(byte, float, java.nio.IntBuffer)} and {@link #setAnalogSampleRateWithModule(byte, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogSampleRateWithModule(byte module, double samplesPerSecond, IntByReference status); - /** - * Original signature : void setAnalogSampleRateWithModule(uint8_t, float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:13 - */ - public static native void setAnalogSampleRateWithModule(byte module, double samplesPerSecond, IntBuffer status); - /** - * Original signature : float getAnalogSampleRateWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:14
- * @deprecated use the safer methods {@link #getAnalogSampleRateWithModule(byte, java.nio.IntBuffer)} and {@link #getAnalogSampleRateWithModule(byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native float getAnalogSampleRateWithModule(byte module, IntByReference status); - /** - * Original signature : float getAnalogSampleRateWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:14 - */ - public static native float getAnalogSampleRateWithModule(byte module, IntBuffer status); - /** - * Original signature : void setAnalogAverageBits(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:15
- * @deprecated use the safer methods {@link #setAnalogAverageBits(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setAnalogAverageBits(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogAverageBits(Pointer analog_port_pointer, int bits, IntByReference status); - /** - * Original signature : void setAnalogAverageBits(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:15 - */ - public static native void setAnalogAverageBits(Pointer analog_port_pointer, int bits, IntBuffer status); - /** - * Original signature : uint32_t getAnalogAverageBits(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:16
- * @deprecated use the safer methods {@link #getAnalogAverageBits(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogAverageBits(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAnalogAverageBits(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : uint32_t getAnalogAverageBits(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:16 - */ - public static native int getAnalogAverageBits(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : void setAnalogOversampleBits(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:17
- * @deprecated use the safer methods {@link #setAnalogOversampleBits(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setAnalogOversampleBits(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogOversampleBits(Pointer analog_port_pointer, int bits, IntByReference status); - /** - * Original signature : void setAnalogOversampleBits(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:17 - */ - public static native void setAnalogOversampleBits(Pointer analog_port_pointer, int bits, IntBuffer status); - /** - * Original signature : uint32_t getAnalogOversampleBits(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:18
- * @deprecated use the safer methods {@link #getAnalogOversampleBits(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogOversampleBits(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAnalogOversampleBits(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : uint32_t getAnalogOversampleBits(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:18 - */ - public static native int getAnalogOversampleBits(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : int16_t getAnalogValue(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:19
- * @deprecated use the safer methods {@link #getAnalogValue(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogValue(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native short getAnalogValue(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : int16_t getAnalogValue(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:19 - */ - public static native short getAnalogValue(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : int32_t getAnalogAverageValue(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:20
- * @deprecated use the safer methods {@link #getAnalogAverageValue(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogAverageValue(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAnalogAverageValue(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : int32_t getAnalogAverageValue(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:20 - */ - public static native int getAnalogAverageValue(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : int32_t getAnalogVoltsToValue(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:21
- * @deprecated use the safer methods {@link #getAnalogVoltsToValue(com.sun.jna.Pointer, float, java.nio.IntBuffer)} and {@link #getAnalogVoltsToValue(com.sun.jna.Pointer, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAnalogVoltsToValue(Pointer analog_port_pointer, double voltage, IntByReference status); - /** - * Original signature : int32_t getAnalogVoltsToValue(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:21 - */ - public static native int getAnalogVoltsToValue(Pointer analog_port_pointer, double voltage, IntBuffer status); - /** - * Original signature : float getAnalogVoltage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:22
- * @deprecated use the safer methods {@link #getAnalogVoltage(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogVoltage(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native float getAnalogVoltage(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : float getAnalogVoltage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:22 - */ - public static native float getAnalogVoltage(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : float getAnalogAverageVoltage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:23
- * @deprecated use the safer methods {@link #getAnalogAverageVoltage(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogAverageVoltage(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native float getAnalogAverageVoltage(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : float getAnalogAverageVoltage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:23 - */ - public static native float getAnalogAverageVoltage(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : uint32_t getAnalogLSBWeight(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:24
- * @deprecated use the safer methods {@link #getAnalogLSBWeight(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogLSBWeight(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAnalogLSBWeight(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : uint32_t getAnalogLSBWeight(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:24 - */ - public static native int getAnalogLSBWeight(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : int32_t getAnalogOffset(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:25
- * @deprecated use the safer methods {@link #getAnalogOffset(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogOffset(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAnalogOffset(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : int32_t getAnalogOffset(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:25 - */ - public static native int getAnalogOffset(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : bool isAccumulatorChannel(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:27
- * @deprecated use the safer methods {@link #isAccumulatorChannel(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #isAccumulatorChannel(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isAccumulatorChannel(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : bool isAccumulatorChannel(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:27 - */ - public static native byte isAccumulatorChannel(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : void initAccumulator(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:28
- * @deprecated use the safer methods {@link #initAccumulator(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #initAccumulator(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void initAccumulator(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : void initAccumulator(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:28 - */ - public static native void initAccumulator(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : void resetAccumulator(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:29
- * @deprecated use the safer methods {@link #resetAccumulator(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #resetAccumulator(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void resetAccumulator(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : void resetAccumulator(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:29 - */ - public static native void resetAccumulator(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : void setAccumulatorCenter(void*, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:30
- * @deprecated use the safer methods {@link #setAccumulatorCenter(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setAccumulatorCenter(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAccumulatorCenter(Pointer analog_port_pointer, int center, IntByReference status); - /** - * Original signature : void setAccumulatorCenter(void*, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:30 - */ - public static native void setAccumulatorCenter(Pointer analog_port_pointer, int center, IntBuffer status); - /** - * Original signature : void setAccumulatorDeadband(void*, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:31
- * @deprecated use the safer methods {@link #setAccumulatorDeadband(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setAccumulatorDeadband(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAccumulatorDeadband(Pointer analog_port_pointer, int deadband, IntByReference status); - /** - * Original signature : void setAccumulatorDeadband(void*, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:31 - */ - public static native void setAccumulatorDeadband(Pointer analog_port_pointer, int deadband, IntBuffer status); - /** - * Original signature : int64_t getAccumulatorValue(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:32
- * @deprecated use the safer methods {@link #getAccumulatorValue(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAccumulatorValue(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native long getAccumulatorValue(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : int64_t getAccumulatorValue(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:32 - */ - public static native long getAccumulatorValue(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : uint32_t getAccumulatorCount(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:33
- * @deprecated use the safer methods {@link #getAccumulatorCount(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAccumulatorCount(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getAccumulatorCount(Pointer analog_port_pointer, IntByReference status); - /** - * Original signature : uint32_t getAccumulatorCount(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:33 - */ - public static native int getAccumulatorCount(Pointer analog_port_pointer, IntBuffer status); - /** - * Original signature : void getAccumulatorOutput(void*, int64_t*, uint32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:34
- * @deprecated use the safer methods {@link #getAccumulatorOutput(com.sun.jna.Pointer, java.nio.LongBuffer, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #getAccumulatorOutput(com.sun.jna.Pointer, com.sun.jna.ptr.LongByReference, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void getAccumulatorOutput(Pointer analog_port_pointer, LongByReference value, IntByReference count, IntByReference status); - /** - * Original signature : void getAccumulatorOutput(void*, int64_t*, uint32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:34 - */ - public static native void getAccumulatorOutput(Pointer analog_port_pointer, LongBuffer value, IntBuffer count, IntBuffer status); - /** - * Original signature : void* initializeAnalogTrigger(void*, uint32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:37
- * @deprecated use the safer methods {@link #initializeAnalogTrigger(com.sun.jna.Pointer, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #initializeAnalogTrigger(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeAnalogTrigger(Pointer port_pointer, IntByReference index, IntByReference status); - /** - * Original signature : void* initializeAnalogTrigger(void*, uint32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:37 - */ - public static native Pointer initializeAnalogTrigger(Pointer port_pointer, IntBuffer index, IntBuffer status); - /** - * Original signature : void cleanAnalogTrigger(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:38
- * @deprecated use the safer methods {@link #cleanAnalogTrigger(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #cleanAnalogTrigger(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void cleanAnalogTrigger(Pointer analog_trigger_pointer, IntByReference status); - /** - * Original signature : void cleanAnalogTrigger(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:38 - */ - public static native void cleanAnalogTrigger(Pointer analog_trigger_pointer, IntBuffer status); - /** - * Original signature : void setAnalogTriggerLimitsRaw(void*, int32_t, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:39
- * @deprecated use the safer methods {@link #setAnalogTriggerLimitsRaw(com.sun.jna.Pointer, int, int, java.nio.IntBuffer)} and {@link #setAnalogTriggerLimitsRaw(com.sun.jna.Pointer, int, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogTriggerLimitsRaw(Pointer analog_trigger_pointer, int lower, int upper, IntByReference status); - /** - * Original signature : void setAnalogTriggerLimitsRaw(void*, int32_t, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:39 - */ - public static native void setAnalogTriggerLimitsRaw(Pointer analog_trigger_pointer, int lower, int upper, IntBuffer status); - /** - * Original signature : void setAnalogTriggerLimitsVoltage(void*, float, float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:40
- * @deprecated use the safer methods {@link #setAnalogTriggerLimitsVoltage(com.sun.jna.Pointer, float, float, java.nio.IntBuffer)} and {@link #setAnalogTriggerLimitsVoltage(com.sun.jna.Pointer, float, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogTriggerLimitsVoltage(Pointer analog_trigger_pointer, double lower, double upper, IntByReference status); - /** - * Original signature : void setAnalogTriggerLimitsVoltage(void*, float, float, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:40 - */ - public static native void setAnalogTriggerLimitsVoltage(Pointer analog_trigger_pointer, double lower, double upper, IntBuffer status); - /** - * Original signature : void setAnalogTriggerAveraged(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:41
- * @deprecated use the safer methods {@link #setAnalogTriggerAveraged(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setAnalogTriggerAveraged(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogTriggerAveraged(Pointer analog_trigger_pointer, byte useAveragedValue, IntByReference status); - /** - * Original signature : void setAnalogTriggerAveraged(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:41 - */ - public static native void setAnalogTriggerAveraged(Pointer analog_trigger_pointer, byte useAveragedValue, IntBuffer status); - /** - * Original signature : void setAnalogTriggerFiltered(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:42
- * @deprecated use the safer methods {@link #setAnalogTriggerFiltered(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setAnalogTriggerFiltered(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setAnalogTriggerFiltered(Pointer analog_trigger_pointer, byte useFilteredValue, IntByReference status); - /** - * Original signature : void setAnalogTriggerFiltered(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:42 - */ - public static native void setAnalogTriggerFiltered(Pointer analog_trigger_pointer, byte useFilteredValue, IntBuffer status); - /** - * Original signature : bool getAnalogTriggerInWindow(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:43
- * @deprecated use the safer methods {@link #getAnalogTriggerInWindow(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogTriggerInWindow(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getAnalogTriggerInWindow(Pointer analog_trigger_pointer, IntByReference status); - /** - * Original signature : bool getAnalogTriggerInWindow(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:43 - */ - public static native byte getAnalogTriggerInWindow(Pointer analog_trigger_pointer, IntBuffer status); - /** - * Original signature : bool getAnalogTriggerTriggerState(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:44
- * @deprecated use the safer methods {@link #getAnalogTriggerTriggerState(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getAnalogTriggerTriggerState(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getAnalogTriggerTriggerState(Pointer analog_trigger_pointer, IntByReference status); - /** - * Original signature : bool getAnalogTriggerTriggerState(void*, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:44 - */ - public static native byte getAnalogTriggerTriggerState(Pointer analog_trigger_pointer, IntBuffer status); - /** - * Original signature : bool getAnalogTriggerOutput(void*, AnalogTriggerType, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:45
- * @deprecated use the safer methods {@link #getAnalogTriggerOutput(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #getAnalogTriggerOutput(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getAnalogTriggerOutput(Pointer analog_trigger_pointer, int type, IntByReference status); - /** - * Original signature : bool getAnalogTriggerOutput(void*, AnalogTriggerType, int32_t*)
- * native declaration : target/native/include/HAL/Analog.h:45 - */ - public static native byte getAnalogTriggerOutput(Pointer analog_trigger_pointer, int type, IntBuffer status); - /** - * Original signature : void* initializeDigitalPort(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:6
- * @deprecated use the safer methods {@link #initializeDigitalPort(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #initializeDigitalPort(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeDigitalPort(Pointer port_pointer, IntByReference status); - /** - * Original signature : void* initializeDigitalPort(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:6 - */ - public static native Pointer initializeDigitalPort(Pointer port_pointer, IntBuffer status); - /** - * Original signature : bool checkDigitalModule(uint8_t)
- * native declaration : target/native/include/HAL/Digital.h:7 - */ - public static native byte checkDigitalModule(byte module); + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String SPI_READ_NO_MISO_MESSAGE = "Cannot read from SPI port with no MISO input"; + /** native declaration : AthenaJava\target\native\include\HAL\Errors.h */ + public static final String LOOP_TIMING_ERROR_MESSAGE = "Digital module loop timing is not the expected value"; + /** native declaration : AthenaJava\target\native\include\HAL\Notifier.h:339 */ + //public interface initializeNotifier_ProcessQueue_callback extends Callback { + // void apply(int uint32_t1, Pointer voidPtr1); + //}; + /** native declaration : AthenaJava\target\native\include\HAL\Interrupts.h:342 */ + /** native declaration : AthenaJava\target\native\include\HAL\Task.h:409 */ + //public interface FUNCPTR extends Callback { + // int apply(Object... varargs); + //}; /** * Original signature : bool checkPWMChannel(void*)
- * native declaration : target/native/include/HAL/Digital.h:8 + * native declaration : AthenaJava\target\native\include\HAL\Digital.h:84 */ - public static native byte checkPWMChannel(Pointer digital_port_pointer); + //public static native byte checkPWMChannel(Pointer digital_port_pointer); /** * Original signature : bool checkRelayChannel(void*)
- * native declaration : target/native/include/HAL/Digital.h:9 + * native declaration : AthenaJava\target\native\include\HAL\Digital.h:86 */ - public static native byte checkRelayChannel(Pointer digital_port_pointer); - /** - * Original signature : uint8_t remapDigitalChannel(uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:10
- * @deprecated use the safer methods {@link #remapDigitalChannel(int, java.nio.IntBuffer)} and {@link #remapDigitalChannel(int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte remapDigitalChannel(int pin, IntByReference status); - /** - * Original signature : uint8_t remapDigitalChannel(uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:10 - */ - public static native byte remapDigitalChannel(int pin, IntBuffer status); - /** - * Original signature : uint8_t unmapDigitalChannel(uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:11
- * @deprecated use the safer methods {@link #unmapDigitalChannel(int, java.nio.IntBuffer)} and {@link #unmapDigitalChannel(int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte unmapDigitalChannel(int pin, IntByReference status); - /** - * Original signature : uint8_t unmapDigitalChannel(uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:11 - */ - public static native byte unmapDigitalChannel(int pin, IntBuffer status); - /** - * Original signature : void setPWM(void*, uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:13
- * @deprecated use the safer methods {@link #setPWM(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setPWM(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWM(Pointer digital_port_pointer, short value, IntByReference status); - /** - * Original signature : void setPWM(void*, uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:13 - */ - public static native void setPWM(Pointer digital_port_pointer, short value, IntBuffer status); - /** - * Original signature : uint8_t getPWM(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:14
- * @deprecated use the safer methods {@link #getPWM(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getPWM(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getPWM(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : uint8_t getPWM(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:14 - */ - public static native byte getPWM(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : void setPWMPeriodScale(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:15
- * @deprecated use the safer methods {@link #setPWMPeriodScale(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setPWMPeriodScale(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMPeriodScale(Pointer digital_port_pointer, int squelchMask, IntByReference status); - /** - * Original signature : void setPWMPeriodScale(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:15 - */ - public static native void setPWMPeriodScale(Pointer digital_port_pointer, int squelchMask, IntBuffer status); - /** - * Original signature : void* allocatePWM(int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:16
- * @deprecated use the safer methods {@link #allocatePWM(java.nio.IntBuffer)} and {@link #allocatePWM(com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer allocatePWM(IntByReference status); - /** - * Original signature : void* allocatePWM(int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:16 - */ - public static native Pointer allocatePWM(IntBuffer status); - /** - * Original signature : void* allocatePWMWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:17
- * @deprecated use the safer methods {@link #allocatePWMWithModule(byte, java.nio.IntBuffer)} and {@link #allocatePWMWithModule(byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer allocatePWMWithModule(byte module, IntByReference status); - /** - * Original signature : void* allocatePWMWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:17 - */ - public static native Pointer allocatePWMWithModule(byte module, IntBuffer status); - /** - * Original signature : void freePWM(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:18
- * @deprecated use the safer methods {@link #freePWM(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #freePWM(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void freePWM(Pointer pwmGenerator, IntByReference status); - /** - * Original signature : void freePWM(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:18 - */ - public static native void freePWM(Pointer pwmGenerator, IntBuffer status); - /** - * Original signature : void freePWMWithModule(uint8_t, void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:19
- * @deprecated use the safer methods {@link #freePWMWithModule(byte, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #freePWMWithModule(byte, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void freePWMWithModule(byte module, Pointer pwmGenerator, IntByReference status); - /** - * Original signature : void freePWMWithModule(uint8_t, void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:19 - */ - public static native void freePWMWithModule(byte module, Pointer pwmGenerator, IntBuffer status); - /** - * Original signature : void setPWMRate(float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:20
- * @deprecated use the safer methods {@link #setPWMRate(float, java.nio.IntBuffer)} and {@link #setPWMRate(float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMRate(double rate, IntByReference status); - /** - * Original signature : void setPWMRate(float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:20 - */ - public static native void setPWMRate(double rate, IntBuffer status); - /** - * Original signature : void setPWMRateWithModule(uint8_t, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:21
- * @deprecated use the safer methods {@link #setPWMRateWithModule(byte, float, java.nio.IntBuffer)} and {@link #setPWMRateWithModule(byte, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMRateWithModule(byte module, double rate, IntByReference status); - /** - * Original signature : void setPWMRateWithModule(uint8_t, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:21 - */ - public static native void setPWMRateWithModule(byte module, double rate, IntBuffer status); - /** - * Original signature : void setPWMDutyCycle(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:22
- * @deprecated use the safer methods {@link #setPWMDutyCycle(com.sun.jna.Pointer, float, java.nio.IntBuffer)} and {@link #setPWMDutyCycle(com.sun.jna.Pointer, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMDutyCycle(Pointer pwmGenerator, double dutyCycle, IntByReference status); - /** - * Original signature : void setPWMDutyCycle(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:22 - */ - public static native void setPWMDutyCycle(Pointer pwmGenerator, double dutyCycle, IntBuffer status); - /** - * Original signature : void setPWMDutyCycleWithModule(uint8_t, void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:23
- * @deprecated use the safer methods {@link #setPWMDutyCycleWithModule(byte, com.sun.jna.Pointer, float, java.nio.IntBuffer)} and {@link #setPWMDutyCycleWithModule(byte, com.sun.jna.Pointer, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMDutyCycleWithModule(byte module, Pointer pwmGenerator, double dutyCycle, IntByReference status); - /** - * Original signature : void setPWMDutyCycleWithModule(uint8_t, void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:23 - */ - public static native void setPWMDutyCycleWithModule(byte module, Pointer pwmGenerator, double dutyCycle, IntBuffer status); - /** - * Original signature : void setPWMOutputChannel(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:24
- * @deprecated use the safer methods {@link #setPWMOutputChannel(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setPWMOutputChannel(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMOutputChannel(Pointer pwmGenerator, int pin, IntByReference status); - /** - * Original signature : void setPWMOutputChannel(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:24 - */ - public static native void setPWMOutputChannel(Pointer pwmGenerator, int pin, IntBuffer status); - /** - * Original signature : void setPWMOutputChannelWithModule(uint8_t, void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:25
- * @deprecated use the safer methods {@link #setPWMOutputChannelWithModule(byte, com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setPWMOutputChannelWithModule(byte, com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setPWMOutputChannelWithModule(byte module, Pointer pwmGenerator, int pin, IntByReference status); - /** - * Original signature : void setPWMOutputChannelWithModule(uint8_t, void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:25 - */ - public static native void setPWMOutputChannelWithModule(byte module, Pointer pwmGenerator, int pin, IntBuffer status); - /** - * Original signature : void setRelayForward(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:27
- * @deprecated use the safer methods {@link #setRelayForward(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setRelayForward(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setRelayForward(Pointer digital_port_pointer, byte on, IntByReference status); - /** - * Original signature : void setRelayForward(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:27 - */ - public static native void setRelayForward(Pointer digital_port_pointer, byte on, IntBuffer status); - /** - * Original signature : void setRelayReverse(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:28
- * @deprecated use the safer methods {@link #setRelayReverse(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setRelayReverse(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setRelayReverse(Pointer digital_port_pointer, byte on, IntByReference status); - /** - * Original signature : void setRelayReverse(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:28 - */ - public static native void setRelayReverse(Pointer digital_port_pointer, byte on, IntBuffer status); - /** - * Original signature : bool getRelayForward(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:29
- * @deprecated use the safer methods {@link #getRelayForward(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getRelayForward(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getRelayForward(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : bool getRelayForward(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:29 - */ - public static native byte getRelayForward(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : bool getRelayReverse(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:30
- * @deprecated use the safer methods {@link #getRelayReverse(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getRelayReverse(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getRelayReverse(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : bool getRelayReverse(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:30 - */ - public static native byte getRelayReverse(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : bool allocateDIO(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:32
- * @deprecated use the safer methods {@link #allocateDIO(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #allocateDIO(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte allocateDIO(Pointer digital_port_pointer, byte input, IntByReference status); - /** - * Original signature : bool allocateDIO(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:32 - */ - public static native byte allocateDIO(Pointer digital_port_pointer, byte input, IntBuffer status); - /** - * Original signature : void freeDIO(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:33
- * @deprecated use the safer methods {@link #freeDIO(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #freeDIO(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void freeDIO(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : void freeDIO(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:33 - */ - public static native void freeDIO(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : void setDIO(void*, short, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:34
- * @deprecated use the safer methods {@link #setDIO(com.sun.jna.Pointer, short, java.nio.IntBuffer)} and {@link #setDIO(com.sun.jna.Pointer, short, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setDIO(Pointer digital_port_pointer, short value, IntByReference status); - /** - * Original signature : void setDIO(void*, short, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:34 - */ - public static native void setDIO(Pointer digital_port_pointer, short value, IntBuffer status); - /** - * Original signature : bool getDIO(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:35
- * @deprecated use the safer methods {@link #getDIO(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getDIO(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getDIO(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : bool getDIO(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:35 - */ - public static native byte getDIO(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : bool getDIODirection(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:36
- * @deprecated use the safer methods {@link #getDIODirection(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getDIODirection(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getDIODirection(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : bool getDIODirection(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:36 - */ - public static native byte getDIODirection(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : void pulse(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:37
- * @deprecated use the safer methods {@link #pulse(com.sun.jna.Pointer, float, java.nio.IntBuffer)} and {@link #pulse(com.sun.jna.Pointer, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void pulse(Pointer digital_port_pointer, double pulseLength, IntByReference status); - /** - * Original signature : void pulse(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:37 - */ - public static native void pulse(Pointer digital_port_pointer, double pulseLength, IntBuffer status); - /** - * Original signature : bool isPulsing(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:38
- * @deprecated use the safer methods {@link #isPulsing(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #isPulsing(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isPulsing(Pointer digital_port_pointer, IntByReference status); - /** - * Original signature : bool isPulsing(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:38 - */ - public static native byte isPulsing(Pointer digital_port_pointer, IntBuffer status); - /** - * Original signature : bool isAnyPulsing(int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:39
- * @deprecated use the safer methods {@link #isAnyPulsing(java.nio.IntBuffer)} and {@link #isAnyPulsing(com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isAnyPulsing(IntByReference status); - /** - * Original signature : bool isAnyPulsing(int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:39 - */ - public static native byte isAnyPulsing(IntBuffer status); - /** - * Original signature : bool isAnyPulsingWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:40
- * @deprecated use the safer methods {@link #isAnyPulsingWithModule(byte, java.nio.IntBuffer)} and {@link #isAnyPulsingWithModule(byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isAnyPulsingWithModule(byte module, IntByReference status); - /** - * Original signature : bool isAnyPulsingWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:40 - */ - public static native byte isAnyPulsingWithModule(byte module, IntBuffer status); - /** - * Original signature : void* initializeCounter(Mode, uint32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:44
- * @deprecated use the safer methods {@link #initializeCounter(int, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #initializeCounter(int, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeCounter(int mode, IntByReference index, IntByReference status); - /** - * Original signature : void* initializeCounter(Mode, uint32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:44 - */ - public static native Pointer initializeCounter(int mode, IntBuffer index, IntBuffer status); - /** - * Original signature : void freeCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:45
- * @deprecated use the safer methods {@link #freeCounter(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #freeCounter(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void freeCounter(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void freeCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:45 - */ - public static native void freeCounter(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterAverageSize(void*, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:46
- * @deprecated use the safer methods {@link #setCounterAverageSize(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setCounterAverageSize(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterAverageSize(Pointer counter_pointer, int size, IntByReference status); - /** - * Original signature : void setCounterAverageSize(void*, int32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:46 - */ - public static native void setCounterAverageSize(Pointer counter_pointer, int size, IntBuffer status); - /** - * Original signature : void setCounterUpSourceWithModule(void*, uint8_t, uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:47
- * @deprecated use the safer methods {@link #setCounterUpSourceWithModule(com.sun.jna.Pointer, byte, int, byte, java.nio.IntBuffer)} and {@link #setCounterUpSourceWithModule(com.sun.jna.Pointer, byte, int, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterUpSourceWithModule(Pointer counter_pointer, byte module, int pin, byte analogTrigger, IntByReference status); - /** - * Original signature : void setCounterUpSourceWithModule(void*, uint8_t, uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:47 - */ - public static native void setCounterUpSourceWithModule(Pointer counter_pointer, byte module, int pin, byte analogTrigger, IntBuffer status); - /** - * Original signature : void setCounterUpSourceEdge(void*, bool, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:49
- * @deprecated use the safer methods {@link #setCounterUpSourceEdge(com.sun.jna.Pointer, byte, byte, java.nio.IntBuffer)} and {@link #setCounterUpSourceEdge(com.sun.jna.Pointer, byte, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterUpSourceEdge(Pointer counter_pointer, byte risingEdge, byte fallingEdge, IntByReference status); - /** - * Original signature : void setCounterUpSourceEdge(void*, bool, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:49 - */ - public static native void setCounterUpSourceEdge(Pointer counter_pointer, byte risingEdge, byte fallingEdge, IntBuffer status); - /** - * Original signature : void clearCounterUpSource(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:50
- * @deprecated use the safer methods {@link #clearCounterUpSource(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clearCounterUpSource(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void clearCounterUpSource(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void clearCounterUpSource(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:50 - */ - public static native void clearCounterUpSource(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterDownSourceWithModule(void*, uint8_t, uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:51
- * @deprecated use the safer methods {@link #setCounterDownSourceWithModule(com.sun.jna.Pointer, byte, int, byte, java.nio.IntBuffer)} and {@link #setCounterDownSourceWithModule(com.sun.jna.Pointer, byte, int, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterDownSourceWithModule(Pointer counter_pointer, byte module, int pin, byte analogTrigger, IntByReference status); - /** - * Original signature : void setCounterDownSourceWithModule(void*, uint8_t, uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:51 - */ - public static native void setCounterDownSourceWithModule(Pointer counter_pointer, byte module, int pin, byte analogTrigger, IntBuffer status); - /** - * Original signature : void setCounterDownSourceEdge(void*, bool, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:53
- * @deprecated use the safer methods {@link #setCounterDownSourceEdge(com.sun.jna.Pointer, byte, byte, java.nio.IntBuffer)} and {@link #setCounterDownSourceEdge(com.sun.jna.Pointer, byte, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterDownSourceEdge(Pointer counter_pointer, byte risingEdge, byte fallingEdge, IntByReference status); - /** - * Original signature : void setCounterDownSourceEdge(void*, bool, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:53 - */ - public static native void setCounterDownSourceEdge(Pointer counter_pointer, byte risingEdge, byte fallingEdge, IntBuffer status); - /** - * Original signature : void clearCounterDownSource(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:54
- * @deprecated use the safer methods {@link #clearCounterDownSource(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clearCounterDownSource(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void clearCounterDownSource(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void clearCounterDownSource(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:54 - */ - public static native void clearCounterDownSource(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterUpDownMode(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:55
- * @deprecated use the safer methods {@link #setCounterUpDownMode(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setCounterUpDownMode(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterUpDownMode(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void setCounterUpDownMode(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:55 - */ - public static native void setCounterUpDownMode(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterExternalDirectionMode(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:56
- * @deprecated use the safer methods {@link #setCounterExternalDirectionMode(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setCounterExternalDirectionMode(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterExternalDirectionMode(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void setCounterExternalDirectionMode(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:56 - */ - public static native void setCounterExternalDirectionMode(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterSemiPeriodMode(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:57
- * @deprecated use the safer methods {@link #setCounterSemiPeriodMode(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setCounterSemiPeriodMode(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterSemiPeriodMode(Pointer counter_pointer, byte highSemiPeriod, IntByReference status); - /** - * Original signature : void setCounterSemiPeriodMode(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:57 - */ - public static native void setCounterSemiPeriodMode(Pointer counter_pointer, byte highSemiPeriod, IntBuffer status); - /** - * Original signature : void setCounterPulseLengthMode(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:58
- * @deprecated use the safer methods {@link #setCounterPulseLengthMode(com.sun.jna.Pointer, float, java.nio.IntBuffer)} and {@link #setCounterPulseLengthMode(com.sun.jna.Pointer, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterPulseLengthMode(Pointer counter_pointer, double threshold, IntByReference status); - /** - * Original signature : void setCounterPulseLengthMode(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:58 - */ - public static native void setCounterPulseLengthMode(Pointer counter_pointer, double threshold, IntBuffer status); - /** - * Original signature : int32_t getCounterSamplesToAverage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:59
- * @deprecated use the safer methods {@link #getCounterSamplesToAverage(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getCounterSamplesToAverage(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getCounterSamplesToAverage(Pointer counter_pointer, IntByReference status); - /** - * Original signature : int32_t getCounterSamplesToAverage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:59 - */ - public static native int getCounterSamplesToAverage(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterSamplesToAverage(void*, int, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:60
- * @deprecated use the safer methods {@link #setCounterSamplesToAverage(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setCounterSamplesToAverage(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterSamplesToAverage(Pointer counter_pointer, int samplesToAverage, IntByReference status); - /** - * Original signature : void setCounterSamplesToAverage(void*, int, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:60 - */ - public static native void setCounterSamplesToAverage(Pointer counter_pointer, int samplesToAverage, IntBuffer status); - /** - * Original signature : void startCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:61
- * @deprecated use the safer methods {@link #startCounter(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #startCounter(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void startCounter(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void startCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:61 - */ - public static native void startCounter(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void stopCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:62
- * @deprecated use the safer methods {@link #stopCounter(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #stopCounter(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void stopCounter(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void stopCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:62 - */ - public static native void stopCounter(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void resetCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:63
- * @deprecated use the safer methods {@link #resetCounter(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #resetCounter(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void resetCounter(Pointer counter_pointer, IntByReference status); - /** - * Original signature : void resetCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:63 - */ - public static native void resetCounter(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : int32_t getCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:64
- * @deprecated use the safer methods {@link #getCounter(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getCounter(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getCounter(Pointer counter_pointer, IntByReference status); - /** - * Original signature : int32_t getCounter(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:64 - */ - public static native int getCounter(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : double getCounterPeriod(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:65
- * @deprecated use the safer methods {@link #getCounterPeriod(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getCounterPeriod(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native double getCounterPeriod(Pointer counter_pointer, IntByReference status); - /** - * Original signature : double getCounterPeriod(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:65 - */ - public static native double getCounterPeriod(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterMaxPeriod(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:66
- * @deprecated use the safer methods {@link #setCounterMaxPeriod(com.sun.jna.Pointer, double, java.nio.IntBuffer)} and {@link #setCounterMaxPeriod(com.sun.jna.Pointer, double, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterMaxPeriod(Pointer counter_pointer, double maxPeriod, IntByReference status); - /** - * Original signature : void setCounterMaxPeriod(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:66 - */ - public static native void setCounterMaxPeriod(Pointer counter_pointer, double maxPeriod, IntBuffer status); - /** - * Original signature : void setCounterUpdateWhenEmpty(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:67
- * @deprecated use the safer methods {@link #setCounterUpdateWhenEmpty(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setCounterUpdateWhenEmpty(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterUpdateWhenEmpty(Pointer counter_pointer, byte enabled, IntByReference status); - /** - * Original signature : void setCounterUpdateWhenEmpty(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:67 - */ - public static native void setCounterUpdateWhenEmpty(Pointer counter_pointer, byte enabled, IntBuffer status); - /** - * Original signature : bool getCounterStopped(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:68
- * @deprecated use the safer methods {@link #getCounterStopped(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getCounterStopped(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getCounterStopped(Pointer counter_pointer, IntByReference status); - /** - * Original signature : bool getCounterStopped(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:68 - */ - public static native byte getCounterStopped(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : bool getCounterDirection(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:69
- * @deprecated use the safer methods {@link #getCounterDirection(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getCounterDirection(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getCounterDirection(Pointer counter_pointer, IntByReference status); - /** - * Original signature : bool getCounterDirection(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:69 - */ - public static native byte getCounterDirection(Pointer counter_pointer, IntBuffer status); - /** - * Original signature : void setCounterReverseDirection(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:70
- * @deprecated use the safer methods {@link #setCounterReverseDirection(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setCounterReverseDirection(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setCounterReverseDirection(Pointer counter_pointer, byte reverseDirection, IntByReference status); - /** - * Original signature : void setCounterReverseDirection(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:70 - */ - public static native void setCounterReverseDirection(Pointer counter_pointer, byte reverseDirection, IntBuffer status); - /** - * Original signature : void* initializeEncoder(uint8_t, uint32_t, bool, uint8_t, uint32_t, bool, bool, int32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:72
- * @deprecated use the safer methods {@link #initializeEncoder(byte, int, byte, byte, int, byte, byte, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #initializeEncoder(byte, int, byte, byte, int, byte, byte, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeEncoder(byte port_a_module, int port_a_pin, byte port_a_analog_trigger, byte port_b_module, int port_b_pin, byte port_b_analog_trigger, byte reverseDirection, IntByReference index, IntByReference status); - /** - * Original signature : void* initializeEncoder(uint8_t, uint32_t, bool, uint8_t, uint32_t, bool, bool, int32_t*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:72 - */ - public static native Pointer initializeEncoder(byte port_a_module, int port_a_pin, byte port_a_analog_trigger, byte port_b_module, int port_b_pin, byte port_b_analog_trigger, byte reverseDirection, IntBuffer index, IntBuffer status); - /** - * Original signature : void freeEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:75
- * @deprecated use the safer methods {@link #freeEncoder(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #freeEncoder(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void freeEncoder(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : void freeEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:75 - */ - public static native void freeEncoder(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : void startEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:76
- * @deprecated use the safer methods {@link #startEncoder(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #startEncoder(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void startEncoder(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : void startEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:76 - */ - public static native void startEncoder(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : void stopEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:77
- * @deprecated use the safer methods {@link #stopEncoder(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #stopEncoder(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void stopEncoder(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : void stopEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:77 - */ - public static native void stopEncoder(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : void resetEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:78
- * @deprecated use the safer methods {@link #resetEncoder(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #resetEncoder(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void resetEncoder(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : void resetEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:78 - */ - public static native void resetEncoder(Pointer encoder_pointer, IntBuffer status); - /** - * Raw value
- * Original signature : int32_t getEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:79
- * @deprecated use the safer methods {@link #getEncoder(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getEncoder(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getEncoder(Pointer encoder_pointer, IntByReference status); - /** - * Raw value
- * Original signature : int32_t getEncoder(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:79 - */ - public static native int getEncoder(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : double getEncoderPeriod(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:80
- * @deprecated use the safer methods {@link #getEncoderPeriod(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getEncoderPeriod(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native double getEncoderPeriod(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : double getEncoderPeriod(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:80 - */ - public static native double getEncoderPeriod(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : void setEncoderMaxPeriod(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:81
- * @deprecated use the safer methods {@link #setEncoderMaxPeriod(com.sun.jna.Pointer, double, java.nio.IntBuffer)} and {@link #setEncoderMaxPeriod(com.sun.jna.Pointer, double, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setEncoderMaxPeriod(Pointer encoder_pointer, double maxPeriod, IntByReference status); - /** - * Original signature : void setEncoderMaxPeriod(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:81 - */ - public static native void setEncoderMaxPeriod(Pointer encoder_pointer, double maxPeriod, IntBuffer status); - /** - * Original signature : bool getEncoderStopped(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:82
- * @deprecated use the safer methods {@link #getEncoderStopped(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getEncoderStopped(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getEncoderStopped(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : bool getEncoderStopped(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:82 - */ - public static native byte getEncoderStopped(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : bool getEncoderDirection(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:83
- * @deprecated use the safer methods {@link #getEncoderDirection(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getEncoderDirection(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getEncoderDirection(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : bool getEncoderDirection(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:83 - */ - public static native byte getEncoderDirection(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : void setEncoderReverseDirection(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:84
- * @deprecated use the safer methods {@link #setEncoderReverseDirection(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setEncoderReverseDirection(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setEncoderReverseDirection(Pointer encoder_pointer, byte reverseDirection, IntByReference status); - /** - * Original signature : void setEncoderReverseDirection(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:84 - */ - public static native void setEncoderReverseDirection(Pointer encoder_pointer, byte reverseDirection, IntBuffer status); - /** - * Original signature : void setEncoderSamplesToAverage(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:85
- * @deprecated use the safer methods {@link #setEncoderSamplesToAverage(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setEncoderSamplesToAverage(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setEncoderSamplesToAverage(Pointer encoder_pointer, int samplesToAverage, IntByReference status); - /** - * Original signature : void setEncoderSamplesToAverage(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:85 - */ - public static native void setEncoderSamplesToAverage(Pointer encoder_pointer, int samplesToAverage, IntBuffer status); - /** - * Original signature : uint32_t getEncoderSamplesToAverage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:86
- * @deprecated use the safer methods {@link #getEncoderSamplesToAverage(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getEncoderSamplesToAverage(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getEncoderSamplesToAverage(Pointer encoder_pointer, IntByReference status); - /** - * Original signature : uint32_t getEncoderSamplesToAverage(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:86 - */ - public static native int getEncoderSamplesToAverage(Pointer encoder_pointer, IntBuffer status); - /** - * Original signature : uint16_t getLoopTiming(int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:88
- * @deprecated use the safer methods {@link #getLoopTiming(java.nio.IntBuffer)} and {@link #getLoopTiming(com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native short getLoopTiming(IntByReference status); - /** - * Original signature : uint16_t getLoopTiming(int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:88 - */ - public static native short getLoopTiming(IntBuffer status); - /** - * Original signature : uint16_t getLoopTimingWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:89
- * @deprecated use the safer methods {@link #getLoopTimingWithModule(byte, java.nio.IntBuffer)} and {@link #getLoopTimingWithModule(byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native short getLoopTimingWithModule(byte module, IntByReference status); - /** - * Original signature : uint16_t getLoopTimingWithModule(uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:89 - */ - public static native short getLoopTimingWithModule(byte module, IntBuffer status); - /** - * Original signature : void* initializeSPI(uint8_t, uint32_t, uint8_t, uint32_t, uint8_t, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:93
- * @deprecated use the safer methods {@link #initializeSPI(byte, int, byte, int, byte, int, java.nio.IntBuffer)} and {@link #initializeSPI(byte, int, byte, int, byte, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeSPI(byte sclk_routing_module, int sclk_routing_pin, byte mosi_routing_module, int mosi_routing_pin, byte miso_routing_module, int miso_routing_pin, IntByReference status); - /** - * Original signature : void* initializeSPI(uint8_t, uint32_t, uint8_t, uint32_t, uint8_t, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:93 - */ - public static native Pointer initializeSPI(byte sclk_routing_module, int sclk_routing_pin, byte mosi_routing_module, int mosi_routing_pin, byte miso_routing_module, int miso_routing_pin, IntBuffer status); - /** - * Original signature : void cleanSPI(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:96
- * @deprecated use the safer methods {@link #cleanSPI(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #cleanSPI(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void cleanSPI(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void cleanSPI(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:96 - */ - public static native void cleanSPI(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPIBitsPerWord(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:97
- * @deprecated use the safer methods {@link #setSPIBitsPerWord(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setSPIBitsPerWord(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPIBitsPerWord(Pointer spi_pointer, int bits, IntByReference status); - /** - * Original signature : void setSPIBitsPerWord(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:97 - */ - public static native void setSPIBitsPerWord(Pointer spi_pointer, int bits, IntBuffer status); - /** - * Original signature : uint32_t getSPIBitsPerWord(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:98
- * @deprecated use the safer methods {@link #getSPIBitsPerWord(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getSPIBitsPerWord(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getSPIBitsPerWord(Pointer spi_pointer, IntByReference status); - /** - * Original signature : uint32_t getSPIBitsPerWord(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:98 - */ - public static native int getSPIBitsPerWord(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPIClockRate(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:99
- * @deprecated use the safer methods {@link #setSPIClockRate(com.sun.jna.Pointer, double, java.nio.IntBuffer)} and {@link #setSPIClockRate(com.sun.jna.Pointer, double, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPIClockRate(Pointer spi_pointer, double hz, IntByReference status); - /** - * Original signature : void setSPIClockRate(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:99 - */ - public static native void setSPIClockRate(Pointer spi_pointer, double hz, IntBuffer status); - /** - * Original signature : void setSPIMSBFirst(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:100
- * @deprecated use the safer methods {@link #setSPIMSBFirst(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setSPIMSBFirst(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPIMSBFirst(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void setSPIMSBFirst(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:100 - */ - public static native void setSPIMSBFirst(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPILSBFirst(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:101
- * @deprecated use the safer methods {@link #setSPILSBFirst(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setSPILSBFirst(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPILSBFirst(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void setSPILSBFirst(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:101 - */ - public static native void setSPILSBFirst(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPISampleDataOnFalling(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:102
- * @deprecated use the safer methods {@link #setSPISampleDataOnFalling(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setSPISampleDataOnFalling(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPISampleDataOnFalling(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void setSPISampleDataOnFalling(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:102 - */ - public static native void setSPISampleDataOnFalling(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPISampleDataOnRising(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:103
- * @deprecated use the safer methods {@link #setSPISampleDataOnRising(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setSPISampleDataOnRising(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPISampleDataOnRising(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void setSPISampleDataOnRising(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:103 - */ - public static native void setSPISampleDataOnRising(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPISlaveSelect(void*, uint8_t, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:104
- * @deprecated use the safer methods {@link #setSPISlaveSelect(com.sun.jna.Pointer, byte, int, java.nio.IntBuffer)} and {@link #setSPISlaveSelect(com.sun.jna.Pointer, byte, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPISlaveSelect(Pointer spi_pointer, byte ss_routing_module, int ss_routing_pin, IntByReference status); - /** - * Original signature : void setSPISlaveSelect(void*, uint8_t, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:104 - */ - public static native void setSPISlaveSelect(Pointer spi_pointer, byte ss_routing_module, int ss_routing_pin, IntBuffer status); - /** - * Original signature : void setSPILatchMode(void*, tFrameMode, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:106
- * @deprecated use the safer methods {@link #setSPILatchMode(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #setSPILatchMode(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPILatchMode(Pointer spi_pointer, int mode, IntByReference status); - /** - * Original signature : void setSPILatchMode(void*, tFrameMode, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:106 - */ - public static native void setSPILatchMode(Pointer spi_pointer, int mode, IntBuffer status); - /** - * Original signature : tFrameMode getSPILatchMode(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:107
- * @deprecated use the safer methods {@link #getSPILatchMode(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getSPILatchMode(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int getSPILatchMode(Pointer spi_pointer, IntByReference status); - /** - * Original signature : tFrameMode getSPILatchMode(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:107 - */ - public static native int getSPILatchMode(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPIFramePolarity(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:108
- * @deprecated use the safer methods {@link #setSPIFramePolarity(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setSPIFramePolarity(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPIFramePolarity(Pointer spi_pointer, byte activeLow, IntByReference status); - /** - * Original signature : void setSPIFramePolarity(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:108 - */ - public static native void setSPIFramePolarity(Pointer spi_pointer, byte activeLow, IntBuffer status); - /** - * Original signature : bool getSPIFramePolarity(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:109
- * @deprecated use the safer methods {@link #getSPIFramePolarity(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getSPIFramePolarity(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getSPIFramePolarity(Pointer spi_pointer, IntByReference status); - /** - * Original signature : bool getSPIFramePolarity(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:109 - */ - public static native byte getSPIFramePolarity(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPIClockActiveLow(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:110
- * @deprecated use the safer methods {@link #setSPIClockActiveLow(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setSPIClockActiveLow(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPIClockActiveLow(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void setSPIClockActiveLow(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:110 - */ - public static native void setSPIClockActiveLow(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void setSPIClockActiveHigh(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:111
- * @deprecated use the safer methods {@link #setSPIClockActiveHigh(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #setSPIClockActiveHigh(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSPIClockActiveHigh(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void setSPIClockActiveHigh(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:111 - */ - public static native void setSPIClockActiveHigh(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void applySPIConfig(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:112
- * @deprecated use the safer methods {@link #applySPIConfig(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #applySPIConfig(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void applySPIConfig(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void applySPIConfig(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:112 - */ - public static native void applySPIConfig(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : uint16_t getSPIOutputFIFOAvailable(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:113
- * @deprecated use the safer methods {@link #getSPIOutputFIFOAvailable(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getSPIOutputFIFOAvailable(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native short getSPIOutputFIFOAvailable(Pointer spi_pointer, IntByReference status); - /** - * Original signature : uint16_t getSPIOutputFIFOAvailable(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:113 - */ - public static native short getSPIOutputFIFOAvailable(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : uint16_t getSPINumReceived(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:114
- * @deprecated use the safer methods {@link #getSPINumReceived(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getSPINumReceived(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native short getSPINumReceived(Pointer spi_pointer, IntByReference status); - /** - * Original signature : uint16_t getSPINumReceived(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:114 - */ - public static native short getSPINumReceived(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : bool isSPIDone(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:115
- * @deprecated use the safer methods {@link #isSPIDone(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #isSPIDone(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isSPIDone(Pointer spi_pointer, IntByReference status); - /** - * Original signature : bool isSPIDone(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:115 - */ - public static native byte isSPIDone(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : bool hadSPIReceiveOverflow(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:116
- * @deprecated use the safer methods {@link #hadSPIReceiveOverflow(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #hadSPIReceiveOverflow(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte hadSPIReceiveOverflow(Pointer spi_pointer, IntByReference status); - /** - * Original signature : bool hadSPIReceiveOverflow(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:116 - */ - public static native byte hadSPIReceiveOverflow(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void writeSPI(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:117
- * @deprecated use the safer methods {@link #writeSPI(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #writeSPI(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void writeSPI(Pointer spi_pointer, int data, IntByReference status); - /** - * Original signature : void writeSPI(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:117 - */ - public static native void writeSPI(Pointer spi_pointer, int data, IntBuffer status); - /** - * Original signature : uint32_t readSPI(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:118
- * @deprecated use the safer methods {@link #readSPI(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #readSPI(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native int readSPI(Pointer spi_pointer, byte initiate, IntByReference status); - /** - * Original signature : uint32_t readSPI(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:118 - */ - public static native int readSPI(Pointer spi_pointer, byte initiate, IntBuffer status); - /** - * Original signature : void resetSPI(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:119
- * @deprecated use the safer methods {@link #resetSPI(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #resetSPI(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void resetSPI(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void resetSPI(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:119 - */ - public static native void resetSPI(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : void clearSPIReceivedData(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:120
- * @deprecated use the safer methods {@link #clearSPIReceivedData(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clearSPIReceivedData(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void clearSPIReceivedData(Pointer spi_pointer, IntByReference status); - /** - * Original signature : void clearSPIReceivedData(void*, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:120 - */ - public static native void clearSPIReceivedData(Pointer spi_pointer, IntBuffer status); - /** - * Original signature : bool doI2CTransaction(uint8_t, bool, uint8_t*, uint8_t, uint8_t*, uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:122
- * @deprecated use the safer methods {@link #doI2CTransaction(byte, byte, java.nio.ByteBuffer, byte, java.nio.ByteBuffer, byte, java.nio.IntBuffer)} and {@link #doI2CTransaction(byte, byte, com.sun.jna.Pointer, byte, com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte doI2CTransaction(byte address, byte compatibilityMode, Pointer dataToSend, byte sendSize, Pointer dataReceived, byte receiveSize, IntByReference status); - /** - * Original signature : bool doI2CTransaction(uint8_t, bool, uint8_t*, uint8_t, uint8_t*, uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:122 - */ - public static native byte doI2CTransaction(byte address, byte compatibilityMode, ByteBuffer dataToSend, byte sendSize, ByteBuffer dataReceived, byte receiveSize, IntBuffer status); - /** - * Original signature : bool doI2CTransactionWithModule(uint8_t, uint8_t, bool, uint8_t*, uint8_t, uint8_t*, uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:125
- * @deprecated use the safer methods {@link #doI2CTransactionWithModule(byte, byte, byte, java.nio.ByteBuffer, byte, java.nio.ByteBuffer, byte, java.nio.IntBuffer)} and {@link #doI2CTransactionWithModule(byte, byte, byte, com.sun.jna.Pointer, byte, com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte doI2CTransactionWithModule(byte module, byte address, byte compatibilityMode, Pointer dataToSend, byte sendSize, Pointer dataReceived, byte receiveSize, IntByReference status); - /** - * Original signature : bool doI2CTransactionWithModule(uint8_t, uint8_t, bool, uint8_t*, uint8_t, uint8_t*, uint8_t, int32_t*)
- * native declaration : target/native/include/HAL/Digital.h:125 - */ - public static native byte doI2CTransactionWithModule(byte module, byte address, byte compatibilityMode, ByteBuffer dataToSend, byte sendSize, ByteBuffer dataReceived, byte receiveSize, IntBuffer status); - /** - * Original signature : void* initializeSolenoidPort(void*, int32_t*)
- * native declaration : target/native/include/HAL/Solenoid.h:6
- * @deprecated use the safer methods {@link #initializeSolenoidPort(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #initializeSolenoidPort(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeSolenoidPort(Pointer port_pointer, IntByReference status); - /** - * Original signature : void* initializeSolenoidPort(void*, int32_t*)
- * native declaration : target/native/include/HAL/Solenoid.h:6 - */ - public static native Pointer initializeSolenoidPort(Pointer port_pointer, IntBuffer status); - /** - * Original signature : bool checkSolenoidModule(uint8_t)
- * native declaration : target/native/include/HAL/Solenoid.h:7 - */ - public static native byte checkSolenoidModule(byte module); - /** - * Original signature : bool getSolenoid(void*, int32_t*)
- * native declaration : target/native/include/HAL/Solenoid.h:9
- * @deprecated use the safer methods {@link #getSolenoid(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getSolenoid(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getSolenoid(Pointer solenoid_port_pointer, IntByReference status); - /** - * Original signature : bool getSolenoid(void*, int32_t*)
- * native declaration : target/native/include/HAL/Solenoid.h:9 - */ - public static native byte getSolenoid(Pointer solenoid_port_pointer, IntBuffer status); - /** - * Original signature : void setSolenoid(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Solenoid.h:10
- * @deprecated use the safer methods {@link #setSolenoid(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setSolenoid(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setSolenoid(Pointer solenoid_port_pointer, byte value, IntByReference status); - /** - * Original signature : void setSolenoid(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Solenoid.h:10 - */ - public static native void setSolenoid(Pointer solenoid_port_pointer, byte value, IntBuffer status); - /** - * Original signature : void* initializeWatchdog(int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:9
- * @deprecated use the safer methods {@link #initializeWatchdog(java.nio.IntBuffer)} and {@link #initializeWatchdog(com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeWatchdog(IntByReference status); - /** - * Original signature : void* initializeWatchdog(int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:9 - */ - public static native Pointer initializeWatchdog(IntBuffer status); - /** - * Original signature : void cleanWatchdog(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:10
- * @deprecated use the safer methods {@link #cleanWatchdog(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #cleanWatchdog(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void cleanWatchdog(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : void cleanWatchdog(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:10 - */ - public static native void cleanWatchdog(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : bool feedWatchdog(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:12
- * @deprecated use the safer methods {@link #feedWatchdog(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #feedWatchdog(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte feedWatchdog(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : bool feedWatchdog(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:12 - */ - public static native byte feedWatchdog(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : void killWatchdog(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:13
- * @deprecated use the safer methods {@link #killWatchdog(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #killWatchdog(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void killWatchdog(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : void killWatchdog(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:13 - */ - public static native void killWatchdog(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : double getWatchdogLastFed(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:14
- * @deprecated use the safer methods {@link #getWatchdogLastFed(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getWatchdogLastFed(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native double getWatchdogLastFed(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : double getWatchdogLastFed(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:14 - */ - public static native double getWatchdogLastFed(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : double getWatchdogExpiration(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:15
- * @deprecated use the safer methods {@link #getWatchdogExpiration(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getWatchdogExpiration(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native double getWatchdogExpiration(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : double getWatchdogExpiration(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:15 - */ - public static native double getWatchdogExpiration(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : void setWatchdogExpiration(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:16
- * @deprecated use the safer methods {@link #setWatchdogExpiration(com.sun.jna.Pointer, double, java.nio.IntBuffer)} and {@link #setWatchdogExpiration(com.sun.jna.Pointer, double, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setWatchdogExpiration(Pointer watchdog_pointer, double expiration, IntByReference status); - /** - * Original signature : void setWatchdogExpiration(void*, double, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:16 - */ - public static native void setWatchdogExpiration(Pointer watchdog_pointer, double expiration, IntBuffer status); - /** - * Original signature : bool getWatchdogEnabled(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:17
- * @deprecated use the safer methods {@link #getWatchdogEnabled(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #getWatchdogEnabled(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte getWatchdogEnabled(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : bool getWatchdogEnabled(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:17 - */ - public static native byte getWatchdogEnabled(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : void setWatchdogEnabled(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:18
- * @deprecated use the safer methods {@link #setWatchdogEnabled(com.sun.jna.Pointer, byte, java.nio.IntBuffer)} and {@link #setWatchdogEnabled(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setWatchdogEnabled(Pointer watchdog_pointer, byte enabled, IntByReference status); - /** - * Original signature : void setWatchdogEnabled(void*, bool, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:18 - */ - public static native void setWatchdogEnabled(Pointer watchdog_pointer, byte enabled, IntBuffer status); - /** - * Original signature : bool isWatchdogAlive(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:19
- * @deprecated use the safer methods {@link #isWatchdogAlive(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #isWatchdogAlive(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isWatchdogAlive(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : bool isWatchdogAlive(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:19 - */ - public static native byte isWatchdogAlive(Pointer watchdog_pointer, IntBuffer status); - /** - * Original signature : bool isWatchdogSystemActive(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:20
- * @deprecated use the safer methods {@link #isWatchdogSystemActive(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #isWatchdogSystemActive(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte isWatchdogSystemActive(Pointer watchdog_pointer, IntByReference status); - /** - * Original signature : bool isWatchdogSystemActive(void*, int32_t*)
- * native declaration : target/native/include/HAL/Watchdog.h:20 - */ - public static native byte isWatchdogSystemActive(Pointer watchdog_pointer, IntBuffer status); + //public static native byte checkRelayChannel(Pointer digital_port_pointer); /** * Original signature : void* initializeNotifier(initializeNotifier_ProcessQueue_callback*, int32_t*)
- * native declaration : target/native/include/HAL/Notifier.h:7
+ * native declaration : AthenaJava\target\native\include\HAL\Notifier.h:334
* @deprecated use the safer methods {@link #initializeNotifier(edu.wpi.first.wpilibj.hal.HALLibrary.initializeNotifier_ProcessQueue_callback, java.nio.IntBuffer)} and {@link #initializeNotifier(edu.wpi.first.wpilibj.hal.HALLibrary.initializeNotifier_ProcessQueue_callback, com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native Pointer initializeNotifier(HALLibrary.initializeNotifier_ProcessQueue_callback ProcessQueue, IntByReference status); + //@Deprecated + //public static native Pointer initializeNotifier(HALLibrary.initializeNotifier_ProcessQueue_callback ProcessQueue, IntByReference status); /** * Original signature : void* initializeNotifier(initializeNotifier_ProcessQueue_callback*, int32_t*)
- * native declaration : target/native/include/HAL/Notifier.h:7 + * native declaration : AthenaJava\target\native\include\HAL\Notifier.h:334 */ - public static native Pointer initializeNotifier(HALLibrary.initializeNotifier_ProcessQueue_callback ProcessQueue, IntBuffer status); + //public static native Pointer initializeNotifier(HALLibrary.initializeNotifier_ProcessQueue_callback ProcessQueue, IntBuffer status); /** * Original signature : void cleanNotifier(void*, int32_t*)
- * native declaration : target/native/include/HAL/Notifier.h:8
+ * native declaration : AthenaJava\target\native\include\HAL\Notifier.h:336
* @deprecated use the safer methods {@link #cleanNotifier(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #cleanNotifier(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native void cleanNotifier(Pointer notifier_pointer, IntByReference status); + //@Deprecated + //public static native void cleanNotifier(Pointer notifier_pointer, IntByReference status); /** * Original signature : void cleanNotifier(void*, int32_t*)
- * native declaration : target/native/include/HAL/Notifier.h:8 + * native declaration : AthenaJava\target\native\include\HAL\Notifier.h:336 */ - public static native void cleanNotifier(Pointer notifier_pointer, IntBuffer status); + //public static native void cleanNotifier(Pointer notifier_pointer, IntBuffer status); /** * Original signature : void updateNotifierAlarm(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Notifier.h:10
+ * native declaration : AthenaJava\target\native\include\HAL\Notifier.h:338
* @deprecated use the safer methods {@link #updateNotifierAlarm(com.sun.jna.Pointer, int, java.nio.IntBuffer)} and {@link #updateNotifierAlarm(com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native void updateNotifierAlarm(Pointer notifier_pointer, int triggerTime, IntByReference status); + //@Deprecated + //public static native void updateNotifierAlarm(Pointer notifier_pointer, int triggerTime, IntByReference status); /** * Original signature : void updateNotifierAlarm(void*, uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/Notifier.h:10 + * native declaration : AthenaJava\target\native\include\HAL\Notifier.h:338 */ - public static native void updateNotifierAlarm(Pointer notifier_pointer, int triggerTime, IntBuffer status); - /** - * Original signature : void* initializeInterrupts(uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:9
- * @deprecated use the safer methods {@link #initializeInterrupts(int, byte, java.nio.IntBuffer)} and {@link #initializeInterrupts(int, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native Pointer initializeInterrupts(int interruptIndex, byte watcher, IntByReference status); - /** - * Original signature : void* initializeInterrupts(uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:9 - */ - public static native Pointer initializeInterrupts(int interruptIndex, byte watcher, IntBuffer status); - /** - * Original signature : void cleanInterrupts(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:10
- * @deprecated use the safer methods {@link #cleanInterrupts(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #cleanInterrupts(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void cleanInterrupts(Pointer interrupt_pointer, IntByReference status); - /** - * Original signature : void cleanInterrupts(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:10 - */ - public static native void cleanInterrupts(Pointer interrupt_pointer, IntBuffer status); - /** - * Original signature : void waitForInterrupt(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:12
- * @deprecated use the safer methods {@link #waitForInterrupt(com.sun.jna.Pointer, float, java.nio.IntBuffer)} and {@link #waitForInterrupt(com.sun.jna.Pointer, float, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void waitForInterrupt(Pointer interrupt_pointer, double timeout, IntByReference status); - /** - * Original signature : void waitForInterrupt(void*, float, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:12 - */ - public static native void waitForInterrupt(Pointer interrupt_pointer, double timeout, IntBuffer status); - /** - * Original signature : void enableInterrupts(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:13
- * @deprecated use the safer methods {@link #enableInterrupts(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #enableInterrupts(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void enableInterrupts(Pointer interrupt_pointer, IntByReference status); - /** - * Original signature : void enableInterrupts(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:13 - */ - public static native void enableInterrupts(Pointer interrupt_pointer, IntBuffer status); - /** - * Original signature : void disableInterrupts(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:14
- * @deprecated use the safer methods {@link #disableInterrupts(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #disableInterrupts(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void disableInterrupts(Pointer interrupt_pointer, IntByReference status); - /** - * Original signature : void disableInterrupts(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:14 - */ - public static native void disableInterrupts(Pointer interrupt_pointer, IntBuffer status); - /** - * Original signature : double readInterruptTimestamp(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:15
- * @deprecated use the safer methods {@link #readInterruptTimestamp(com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #readInterruptTimestamp(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native double readInterruptTimestamp(Pointer interrupt_pointer, IntByReference status); - /** - * Original signature : double readInterruptTimestamp(void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:15 - */ - public static native double readInterruptTimestamp(Pointer interrupt_pointer, IntBuffer status); - /** - * Original signature : void requestInterrupts(void*, uint8_t, uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:16
- * @deprecated use the safer methods {@link #requestInterrupts(com.sun.jna.Pointer, byte, int, byte, java.nio.IntBuffer)} and {@link #requestInterrupts(com.sun.jna.Pointer, byte, int, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void requestInterrupts(Pointer interrupt_pointer, byte routing_module, int routing_pin, byte routing_analog_trigger, IntByReference status); - /** - * Original signature : void requestInterrupts(void*, uint8_t, uint32_t, bool, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:16 - */ - public static native void requestInterrupts(Pointer interrupt_pointer, byte routing_module, int routing_pin, byte routing_analog_trigger, IntBuffer status); - /** - * Original signature : void attachInterruptHandler(void*, InterruptHandlerFunction, void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:18
- * @deprecated use the safer methods {@link #attachInterruptHandler(com.sun.jna.Pointer, edu.wpi.first.wpilibj.hal.HALLibrary.InterruptHandlerFunction, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #attachInterruptHandler(com.sun.jna.Pointer, edu.wpi.first.wpilibj.hal.HALLibrary.InterruptHandlerFunction, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void attachInterruptHandler(Pointer interrupt_pointer, HALLibrary.InterruptHandlerFunction handler, Pointer param, IntByReference status); - /** - * Original signature : void attachInterruptHandler(void*, InterruptHandlerFunction, void*, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:18 - */ - public static native void attachInterruptHandler(Pointer interrupt_pointer, HALLibrary.InterruptHandlerFunction handler, Pointer param, IntBuffer status); - /** - * Original signature : void setInterruptUpSourceEdge(void*, bool, bool, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:20
- * @deprecated use the safer methods {@link #setInterruptUpSourceEdge(com.sun.jna.Pointer, byte, byte, java.nio.IntBuffer)} and {@link #setInterruptUpSourceEdge(com.sun.jna.Pointer, byte, byte, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native void setInterruptUpSourceEdge(Pointer interrupt_pointer, byte risingEdge, byte fallingEdge, IntByReference status); - /** - * Original signature : void setInterruptUpSourceEdge(void*, bool, bool, int32_t*)
- * native declaration : target/native/include/HAL/Interrupts.h:20 - */ - public static native void setInterruptUpSourceEdge(Pointer interrupt_pointer, byte risingEdge, byte fallingEdge, IntBuffer status); + //public static native void updateNotifierAlarm(Pointer notifier_pointer, int triggerTime, IntBuffer status); /** * Original signature : void delayTicks(int32_t)
- * native declaration : target/native/include/HAL/Utilities.h:10 + * native declaration : AthenaJava\target\native\include\HAL\Utilities.h:366 */ public static native void delayTicks(int ticks); /** * Original signature : void delayMillis(double)
- * native declaration : target/native/include/HAL/Utilities.h:11 + * native declaration : AthenaJava\target\native\include\HAL\Utilities.h:368 */ public static native void delayMillis(double ms); /** * Original signature : void delaySeconds(double)
- * native declaration : target/native/include/HAL/Utilities.h:12 + * native declaration : AthenaJava\target\native\include\HAL\Utilities.h:370 */ public static native void delaySeconds(double s); /** * Original signature : MUTEX_ID initializeMutex(uint32_t)
- * native declaration : target/native/include/HAL/Semaphore.h:33 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:385 */ - public static native Pointer initializeMutex(int flags); + public static native ByteBuffer initializeMutex(int flags); /** * Original signature : void deleteMutex(MUTEX_ID)
- * native declaration : target/native/include/HAL/Semaphore.h:34 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:387
+ * @deprecated use the safer methods {@link #deleteMutex(edu.wpi.first.wpilibj.hal.HALLibrary.MUTEX_ID)} and {@link #deleteMutex(com.sun.jna.Pointer)} instead */ - public static native void deleteMutex(Pointer sem); + //@Deprecated + //public static native void deleteMutex(Pointer sem); + /** + * Original signature : void deleteMutex(MUTEX_ID)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:387 + */ + public static native void deleteMutex(ByteBuffer sem); /** * Original signature : int8_t takeMutex(MUTEX_ID, int32_t)
- * native declaration : target/native/include/HAL/Semaphore.h:35 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:389
+ * @deprecated use the safer methods {@link #takeMutex(edu.wpi.first.wpilibj.hal.HALLibrary.MUTEX_ID, int)} and {@link #takeMutex(com.sun.jna.Pointer, int)} instead */ - public static native byte takeMutex(Pointer sem, int timeout); + //@Deprecated + //public static native byte takeMutex(Pointer sem, int timeout); + /** + * Original signature : int8_t takeMutex(MUTEX_ID, int32_t)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:389 + */ + public static native byte takeMutex(ByteBuffer sem, int timeout); /** * Original signature : int8_t giveMutex(MUTEX_ID)
- * native declaration : target/native/include/HAL/Semaphore.h:36 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:391
+ * @deprecated use the safer methods {@link #giveMutex(edu.wpi.first.wpilibj.hal.HALLibrary.MUTEX_ID)} and {@link #giveMutex(com.sun.jna.Pointer)} instead */ - public static native byte giveMutex(Pointer sem); + //@Deprecated + //public static native byte giveMutex(Pointer sem); + /** + * Original signature : int8_t giveMutex(MUTEX_ID)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:391 + */ + //public static native byte giveMutex(HALLibrary.MUTEX_ID sem); /** * Original signature : SEMAPHORE_ID initializeSemaphore(uint32_t, uint32_t)
- * native declaration : target/native/include/HAL/Semaphore.h:38 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:393 */ - public static native Pointer initializeSemaphore(int flags, int initial_value); + //public static native HALLibrary.SEMAPHORE_ID initializeSemaphore(int flags, int initial_value); /** * Original signature : void deleteSemaphore(SEMAPHORE_ID)
- * native declaration : target/native/include/HAL/Semaphore.h:39 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:395
+ * @deprecated use the safer methods {@link #deleteSemaphore(edu.wpi.first.wpilibj.hal.HALLibrary.SEMAPHORE_ID)} and {@link #deleteSemaphore(com.sun.jna.Pointer)} instead */ - public static native void deleteSemaphore(Pointer sem); + //@Deprecated + //public static native void deleteSemaphore(Pointer sem); + /** + * Original signature : void deleteSemaphore(SEMAPHORE_ID)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:395 + */ + //public static native void deleteSemaphore(HALLibrary.SEMAPHORE_ID sem); /** * Original signature : int8_t takeSemaphore(SEMAPHORE_ID, int32_t)
- * native declaration : target/native/include/HAL/Semaphore.h:40 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:397
+ * @deprecated use the safer methods {@link #takeSemaphore(edu.wpi.first.wpilibj.hal.HALLibrary.SEMAPHORE_ID, int)} and {@link #takeSemaphore(com.sun.jna.Pointer, int)} instead */ - public static native byte takeSemaphore(Pointer sem, int timeout); + //@Deprecated + //public static native byte takeSemaphore(Pointer sem, int timeout); + /** + * Original signature : int8_t takeSemaphore(SEMAPHORE_ID, int32_t)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:397 + */ + //public static native byte takeSemaphore(HALLibrary.SEMAPHORE_ID sem, int timeout); /** * Original signature : int8_t giveSemaphore(SEMAPHORE_ID)
- * native declaration : target/native/include/HAL/Semaphore.h:41 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:399
+ * @deprecated use the safer methods {@link #giveSemaphore(edu.wpi.first.wpilibj.hal.HALLibrary.SEMAPHORE_ID)} and {@link #giveSemaphore(com.sun.jna.Pointer)} instead */ - public static native byte giveSemaphore(Pointer sem); + //@Deprecated + //public static native byte giveSemaphore(Pointer sem); + /** + * Original signature : int8_t giveSemaphore(SEMAPHORE_ID)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:399 + */ + //public static native byte giveSemaphore(HALLibrary.SEMAPHORE_ID sem); /** * Original signature : MULTIWAIT_ID initializeMultiWait()
- * native declaration : target/native/include/HAL/Semaphore.h:43 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:401 */ - public static native Pointer initializeMultiWait(); + //public static native HALLibrary.MULTIWAIT_ID initializeMultiWait(); /** * Original signature : void deleteMultiWait(MULTIWAIT_ID)
- * native declaration : target/native/include/HAL/Semaphore.h:44 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:403
+ * @deprecated use the safer methods {@link #deleteMultiWait(edu.wpi.first.wpilibj.hal.HALLibrary.MULTIWAIT_ID)} and {@link #deleteMultiWait(com.sun.jna.Pointer)} instead */ - public static native void deleteMultiWait(Pointer sem); + //@Deprecated + //public static native void deleteMultiWait(Pointer sem); + /** + * Original signature : void deleteMultiWait(MULTIWAIT_ID)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:403 + */ + //public static native void deleteMultiWait(HALLibrary.MULTIWAIT_ID sem); /** * Original signature : int8_t takeMultiWait(MULTIWAIT_ID, int32_t)
- * native declaration : target/native/include/HAL/Semaphore.h:45 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:405
+ * @deprecated use the safer methods {@link #takeMultiWait(edu.wpi.first.wpilibj.hal.HALLibrary.MULTIWAIT_ID, int)} and {@link #takeMultiWait(com.sun.jna.Pointer, int)} instead */ - public static native byte takeMultiWait(Pointer sem, int timeout); + //@Deprecated + //public static native byte takeMultiWait(Pointer sem, int timeout); + /** + * Original signature : int8_t takeMultiWait(MULTIWAIT_ID, int32_t)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:405 + */ + //public static native byte takeMultiWait(HALLibrary.MULTIWAIT_ID sem, int timeout); /** * Original signature : int8_t giveMultiWait(MULTIWAIT_ID)
- * native declaration : target/native/include/HAL/Semaphore.h:46 + * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:407
+ * @deprecated use the safer methods {@link #giveMultiWait(edu.wpi.first.wpilibj.hal.HALLibrary.MULTIWAIT_ID)} and {@link #giveMultiWait(com.sun.jna.Pointer)} instead */ - public static native byte giveMultiWait(Pointer sem); + //@Deprecated + //public static native byte giveMultiWait(Pointer sem); + /** + * Original signature : int8_t giveMultiWait(MULTIWAIT_ID)
+ * native declaration : AthenaJava\target\native\include\HAL\Semaphore.h:407 + */ + //public static native byte giveMultiWait(HALLibrary.MULTIWAIT_ID sem); /** * Original signature : TASK spawnTask(char*, int, int, int, FUNCPTR, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)
- * native declaration : target/native/include/HAL/Task.h:47
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:420
* @deprecated use the safer methods {@link #spawnTask(java.nio.ByteBuffer, int, int, int, edu.wpi.first.wpilibj.hal.HALLibrary.FUNCPTR, int, int, int, int, int, int, int, int, int, int)} and {@link #spawnTask(com.sun.jna.Pointer, int, int, int, edu.wpi.first.wpilibj.hal.HALLibrary.FUNCPTR, int, int, int, int, int, int, int, int, int, int)} instead */ - @Deprecated - public static native NativeLongByReference spawnTask(Pointer name, int priority, int options, int stackSize, HALLibrary.FUNCPTR entryPt, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9); + //@Deprecated + //public static native HALLibrary.TASK spawnTask(Pointer name, int priority, int options, int stackSize, HALLibrary.FUNCPTR entryPt, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9); /** * Original signature : TASK spawnTask(char*, int, int, int, FUNCPTR, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)
- * native declaration : target/native/include/HAL/Task.h:47 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:420 */ - public static native NativeLongByReference spawnTask(ByteBuffer name, int priority, int options, int stackSize, HALLibrary.FUNCPTR entryPt, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9); + //public static native HALLibrary.TASK spawnTask(ByteBuffer name, int priority, int options, int stackSize, HALLibrary.FUNCPTR entryPt, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9); /** * Original signature : STATUS restartTask(TASK)
- * native declaration : target/native/include/HAL/Task.h:51 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:422
+ * @deprecated use the safer methods {@link #restartTask(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #restartTask(com.sun.jna.Pointer)} instead */ - public static native int restartTask(NativeLongByReference task); + //@Deprecated + //public static native int restartTask(Pointer task); + /** + * Original signature : STATUS restartTask(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:422 + */ + //public static native int restartTask(HALLibrary.TASK task); /** * Original signature : STATUS deleteTask(TASK)
- * native declaration : target/native/include/HAL/Task.h:52 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:424
+ * @deprecated use the safer methods {@link #deleteTask(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #deleteTask(com.sun.jna.Pointer)} instead */ - public static native int deleteTask(NativeLongByReference task); + //@Deprecated + //public static native int deleteTask(Pointer task); + /** + * Original signature : STATUS deleteTask(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:424 + */ + //public static native int deleteTask(HALLibrary.TASK task); /** * Original signature : STATUS isTaskReady(TASK)
- * native declaration : target/native/include/HAL/Task.h:53 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:426
+ * @deprecated use the safer methods {@link #isTaskReady(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #isTaskReady(com.sun.jna.Pointer)} instead */ - public static native int isTaskReady(NativeLongByReference task); + //@Deprecated + //public static native int isTaskReady(Pointer task); + /** + * Original signature : STATUS isTaskReady(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:426 + */ + //public static native int isTaskReady(HALLibrary.TASK task); /** * Original signature : STATUS isTaskSuspended(TASK)
- * native declaration : target/native/include/HAL/Task.h:54 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:428
+ * @deprecated use the safer methods {@link #isTaskSuspended(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #isTaskSuspended(com.sun.jna.Pointer)} instead */ - public static native int isTaskSuspended(NativeLongByReference task); + //@Deprecated + //public static native int isTaskSuspended(Pointer task); + /** + * Original signature : STATUS isTaskSuspended(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:428 + */ + //public static native int isTaskSuspended(HALLibrary.TASK task); /** * Original signature : STATUS suspendTask(TASK)
- * native declaration : target/native/include/HAL/Task.h:55 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:430
+ * @deprecated use the safer methods {@link #suspendTask(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #suspendTask(com.sun.jna.Pointer)} instead */ - public static native int suspendTask(NativeLongByReference task); + //@Deprecated + //public static native int suspendTask(Pointer task); + /** + * Original signature : STATUS suspendTask(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:430 + */ + //public static native int suspendTask(HALLibrary.TASK task); /** * Original signature : STATUS resumeTask(TASK)
- * native declaration : target/native/include/HAL/Task.h:56 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:432
+ * @deprecated use the safer methods {@link #resumeTask(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #resumeTask(com.sun.jna.Pointer)} instead */ - public static native int resumeTask(NativeLongByReference task); + //@Deprecated + //public static native int resumeTask(Pointer task); + /** + * Original signature : STATUS resumeTask(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:432 + */ + //public static native int resumeTask(HALLibrary.TASK task); /** * Original signature : STATUS verifyTaskID(TASK)
- * native declaration : target/native/include/HAL/Task.h:57 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:434
+ * @deprecated use the safer methods {@link #verifyTaskID(edu.wpi.first.wpilibj.hal.HALLibrary.TASK)} and {@link #verifyTaskID(com.sun.jna.Pointer)} instead */ - public static native int verifyTaskID(NativeLongByReference task); + //@Deprecated + //public static native int verifyTaskID(Pointer task); + /** + * Original signature : STATUS verifyTaskID(TASK)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:434 + */ + //public static native int verifyTaskID(HALLibrary.TASK task); /** * Original signature : STATUS setTaskPriority(TASK, int)
- * native declaration : target/native/include/HAL/Task.h:58 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:436
+ * @deprecated use the safer methods {@link #setTaskPriority(edu.wpi.first.wpilibj.hal.HALLibrary.TASK, int)} and {@link #setTaskPriority(com.sun.jna.Pointer, int)} instead */ - public static native int setTaskPriority(NativeLongByReference task, int priority); + //@Deprecated + //public static native int setTaskPriority(Pointer task, int priority); + /** + * Original signature : STATUS setTaskPriority(TASK, int)
+ * native declaration : AthenaJava\target\native\include\HAL\Task.h:436 + */ + //public static native int setTaskPriority(HALLibrary.TASK task, int priority); /** * Original signature : STATUS getTaskPriority(TASK, int*)
- * native declaration : target/native/include/HAL/Task.h:59
- * @deprecated use the safer methods {@link #getTaskPriority(com.sun.jna.ptr.NativeLongByReference, java.nio.IntBuffer)} and {@link #getTaskPriority(com.sun.jna.ptr.NativeLongByReference, com.sun.jna.ptr.IntByReference)} instead + * native declaration : AthenaJava\target\native\include\HAL\Task.h:438
+ * @deprecated use the safer methods {@link #getTaskPriority(edu.wpi.first.wpilibj.hal.HALLibrary.TASK, java.nio.IntBuffer)} and {@link #getTaskPriority(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native int getTaskPriority(NativeLongByReference task, IntByReference priority); + //@Deprecated + //public static native int getTaskPriority(Pointer task, IntByReference priority); /** * Original signature : STATUS getTaskPriority(TASK, int*)
- * native declaration : target/native/include/HAL/Task.h:59 + * native declaration : AthenaJava\target\native\include\HAL\Task.h:438 */ - public static native int getTaskPriority(NativeLongByReference task, IntBuffer priority); + //public static native int getTaskPriority(HALLibrary.TASK task, IntBuffer priority); /** * Original signature : void* getPort(uint8_t)
- * native declaration : target/native/include/HAL/HAL.h:31 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:446 */ - public static native Pointer getPort(byte pin); - /** - * Original signature : void* getPortWithModule(uint8_t, uint8_t)
- * native declaration : target/native/include/HAL/HAL.h:32 - */ - public static native Pointer getPortWithModule(byte module, byte pin); - /** - * Original signature : char* getHALErrorMessage(int32_t)
- * native declaration : target/native/include/HAL/HAL.h:33 - */ - public static native String getHALErrorMessage(int code); + //public static native Pointer getPort(byte pin); /** * Original signature : uint16_t getFPGAVersion(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:35
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:452
* @deprecated use the safer methods {@link #getFPGAVersion(java.nio.IntBuffer)} and {@link #getFPGAVersion(com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native short getFPGAVersion(IntByReference status); + //@Deprecated + //public static native short getFPGAVersion(IntByReference status); /** * Original signature : uint16_t getFPGAVersion(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:35 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:452 */ - public static native short getFPGAVersion(IntBuffer status); + //public static native short getFPGAVersion(IntBuffer status); /** * Original signature : uint32_t getFPGARevision(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:36
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:454
* @deprecated use the safer methods {@link #getFPGARevision(java.nio.IntBuffer)} and {@link #getFPGARevision(com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native int getFPGARevision(IntByReference status); + //@Deprecated + //public static native int getFPGARevision(IntByReference status); /** * Original signature : uint32_t getFPGARevision(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:36 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:454 */ - public static native int getFPGARevision(IntBuffer status); + //public static native int getFPGARevision(IntBuffer status); /** * Original signature : uint32_t getFPGATime(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:37
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:456
* @deprecated use the safer methods {@link #getFPGATime(java.nio.IntBuffer)} and {@link #getFPGATime(com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native int getFPGATime(IntByReference status); + //@Deprecated + //public static native int getFPGATime(IntByReference status); /** * Original signature : uint32_t getFPGATime(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:37 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:456 */ - public static native int getFPGATime(IntBuffer status); + //public static native int getFPGATime(IntBuffer status); /** * Original signature : void setFPGALED(uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:39
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:458
* @deprecated use the safer methods {@link #setFPGALED(int, java.nio.IntBuffer)} and {@link #setFPGALED(int, com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native void setFPGALED(int state, IntByReference status); + //@Deprecated + //public static native void setFPGALED(int state, IntByReference status); /** * Original signature : void setFPGALED(uint32_t, int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:39 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:458 */ public static native void setFPGALED(int state, IntBuffer status); /** * Original signature : int32_t getFPGALED(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:40
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:460
* @deprecated use the safer methods {@link #getFPGALED(java.nio.IntBuffer)} and {@link #getFPGALED(com.sun.jna.ptr.IntByReference)} instead */ - @Deprecated - public static native int getFPGALED(IntByReference status); + //@Deprecated + //public static native int getFPGALED(IntByReference status); /** * Original signature : int32_t getFPGALED(int32_t*)
- * native declaration : target/native/include/HAL/HAL.h:40 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:460 */ public static native int getFPGALED(IntBuffer status); /** - * Original signature : void FRC_NetworkCommunication_Reserve()
- * native declaration : target/native/include/HAL/HAL.h:45 + * Original signature : double testDouble(double)
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:462 */ - public static native void FRC_NetworkCommunication_Reserve(); + public static native double testDouble(double param); + /** + * Original signature : int32_t testInt32(int32_t)
+ * native declaration : AthenaJava\target\native\include\HAL\HAL.h:464 + */ + public static native int testInt32(int param); /** * Original signature : void NumericArrayResize()
- * native declaration : target/native/include/HAL/HAL.h:47 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:470 */ public static native void NumericArrayResize(); /** * Original signature : void RTSetCleanupProc()
- * native declaration : target/native/include/HAL/HAL.h:48 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:472 */ public static native void RTSetCleanupProc(); /** * Original signature : void EDVR_CreateReference()
- * native declaration : target/native/include/HAL/HAL.h:49 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:474 */ public static native void EDVR_CreateReference(); /** * Original signature : void Occur()
- * native declaration : target/native/include/HAL/HAL.h:50 + * native declaration : AthenaJava\target\native\include\HAL\HAL.h:476 */ public static native void Occur(); + /* public static final GlobalDouble kDefaultWatchdogExpiration = new GlobalDouble(HALLibrary.JNA_NATIVE_LIB, "kDefaultWatchdogExpiration"); public static final GlobalInt HAL_NO_WAIT = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "HAL_NO_WAIT"); public static final GlobalInt HAL_WAIT_FOREVER = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "HAL_WAIT_FOREVER"); public static final GlobalInt SEMAPHORE_Q_FIFO = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_Q_FIFO"); - public static final GlobalInt SEMAPHORE_Q_PRIORITY = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_Q_PRIORITY"); + */ + /* public static final GlobalInt SEMAPHORE_DELETE_SAFE = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_DELETE_SAFE"); public static final GlobalInt SEMAPHORE_INVERSION_SAFE = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_INVERSION_SAFE"); public static final GlobalInt SEMAPHORE_NO_WAIT = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_NO_WAIT"); - public static final GlobalInt SEMAPHORE_WAIT_FOREVER = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_WAIT_FOREVER"); + */ + /* public static final GlobalInt SEMAPHORE_EMPTY = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_EMPTY"); public static final GlobalInt SEMAPHORE_FULL = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "SEMAPHORE_FULL"); public static final GlobalInt VXWORKS_FP_TASK = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "VXWORKS_FP_TASK"); @@ -2294,50 +533,39 @@ public class HALLibrary implements Library { public static final GlobalInt solenoid_kNumDO7_0Elements = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "solenoid_kNumDO7_0Elements"); public static final GlobalInt interrupt_kNumSystems = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "interrupt_kNumSystems"); public static final GlobalInt kSystemClockTicksPerMicrosecond = new GlobalInt(HALLibrary.JNA_NATIVE_LIB, "kSystemClockTicksPerMicrosecond"); - - //// INT HACK STUFF - /// Analog - // Float - @Deprecated - public static native int getAnalogSampleRateIntHack(IntByReference status); - public static native int getAnalogSampleRateIntHack(IntBuffer status); - @Deprecated - public static native int getAnalogSampleRateWithModuleIntHack(byte module, IntByReference status); - public static native int getAnalogSampleRateWithModuleIntHack(byte module, IntBuffer status); - @Deprecated - public static native int getAnalogVoltageIntHack(Pointer analog_port_pointer, IntByReference status); - public static native int getAnalogVoltageIntHack(Pointer analog_port_pointer, IntBuffer status); - @Deprecated - public static native int getAnalogAverageVoltageIntHack(Pointer analog_port_pointer, IntByReference status); - public static native int getAnalogAverageVoltageIntHack(Pointer analog_port_pointer, IntBuffer status); - - // Double - @Deprecated - public static native void setAnalogSampleRateIntHack(int samplesPerSecond, IntByReference status); - public static native void setAnalogSampleRateIntHack(int samplesPerSecond, IntBuffer status); - @Deprecated - public static native void setAnalogSampleRateWithModuleIntHack(byte module, int samplesPerSecond, IntByReference status); - public static native void setAnalogSampleRateWithModuleIntHack(byte module, int samplesPerSecond, IntBuffer status); - @Deprecated - public static native int getAnalogVoltsToValueIntHack(Pointer analog_port_pointer, int voltage, IntByReference status); - public static native int getAnalogVoltsToValueIntHack(Pointer analog_port_pointer, int voltage, IntBuffer status); - @Deprecated - public static native void setAnalogTriggerLimitsVoltageIntHack(Pointer analog_trigger_pointer, int lower, int upper, IntByReference status); - - public static native void setAnalogTriggerLimitsVoltageIntHack(Pointer analog_trigger_pointer, int lower, int upper, IntBuffer status); - - /// PWM - // Double - @Deprecated - public static native void setPWMRateIntHack(int rate, IntByReference status); - public static native void setPWMRateIntHack(int rate, IntBuffer status); - @Deprecated - public static native void setPWMRateWithModuleIntHack(byte module, int rate, IntByReference status); - public static native void setPWMRateWithModuleIntHack(byte module, int rate, IntBuffer status); - @Deprecated - public static native void setPWMDutyCycleIntHack(Pointer pwmGenerator, int dutyCycle, IntByReference status); - public static native void setPWMDutyCycleIntHack(Pointer pwmGenerator, int dutyCycle, IntBuffer status); - @Deprecated - public static native void setPWMDutyCycleWithModuleIntHack(byte module, Pointer pwmGenerator, int dutyCycle, IntByReference status); - public static native void setPWMDutyCycleWithModuleIntHack(byte module, Pointer pwmGenerator, int dutyCycle, IntBuffer status); + */ + /* + public static class TASK extends PointerType { + public TASK(Pointer address) { + super(address); + } + public TASK() { + super(); + } + }; + public static class MUTEX_ID extends PointerType { + public MUTEX_ID(Pointer address) { + super(address); + } + public MUTEX_ID() { + super(); + } + }; + public static class MULTIWAIT_ID extends PointerType { + public MULTIWAIT_ID(Pointer address) { + super(address); + } + public MULTIWAIT_ID() { + super(); + } + }; + public static class SEMAPHORE_ID extends PointerType { + public SEMAPHORE_ID(Pointer address) { + super(address); + } + public SEMAPHORE_ID() { + super(); + } + }; + */ } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALUtil.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALUtil.java index ab938bc76f..e9821b3c27 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALUtil.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/HALUtil.java @@ -1,29 +1,53 @@ package edu.wpi.first.wpilibj.hal; import java.nio.IntBuffer; +import java.nio.ByteBuffer; -public class HALUtil { +public class HALUtil extends JNIWrapper { + public static final int NULL_PARAMETER = -5; + public static final int SAMPLE_RATE_TOO_HIGH = 1; + public static final int VOLTAGE_OUT_OF_RANGE = 2; + public static final int LOOP_TIMING_ERROR = 4; + public static final int INCOMPATIBLE_STATE = 15; + public static final int ANALOG_TRIGGER_PULSE_OUTPUT_ERROR = -11; + public static final int NO_AVAILABLE_RESOURCES = -4; + public static final int PARAMETER_OUT_OF_RANGE = -28; - public static void checkStatus(IntBuffer status) { + //public static final int SEMAPHORE_WAIT_FOREVER = -1; + //public static final int SEMAPHORE_Q_PRIORITY = 0x01; + + public static native ByteBuffer initializeMutexNormal(); + public static native void deleteMutex(ByteBuffer sem); + public static native byte takeMutex(ByteBuffer sem); + //public static native ByteBuffer initializeSemaphore(int initialValue); + //public static native void deleteSemaphore(ByteBuffer sem); + //public static native byte takeSemaphore(ByteBuffer sem, int timeout); + public static native short getFPGAVersion(IntBuffer status); + public static native int getFPGARevision(IntBuffer status); + public static native long getFPGATime(IntBuffer status); + + public static native String getHALErrorMessage(int code); + + public static void checkStatus(IntBuffer status) + { int s = status.get(0); - String message = "Code: " + s + ". " + HALLibrary.getHALErrorMessage(s); - if (s == 0) - return; - else if (s == HALLibrary.NULL_PARAMETER - || s == HALLibrary.SAMPLE_RATE_TOO_HIGH - || s == HALLibrary.VOLTAGE_OUT_OF_RANGE) - throw new IllegalArgumentException(message); - else if (s == HALLibrary.LOOP_TIMING_ERROR) // TODO: Make these a - // WPILibRuntimeException - throw new RuntimeException(message); - else if (s == HALLibrary.INCOMPATIBLE_STATE - || s == HALLibrary.ANALOG_TRIGGER_PULSE_OUTPUT_ERROR) - throw new IllegalStateException(message); - else if (s == HALLibrary.NO_AVAILABLE_RESOURCES) - throw new RuntimeException(message); - else - throw new RuntimeException("Unknown error. Code: " + s + ". " - + message); + if (s != 0) + { + String message = "Code: " + s + ". " + HALUtil.getHALErrorMessage(s); + if (s == HALUtil.NULL_PARAMETER + || s == HALUtil.SAMPLE_RATE_TOO_HIGH + || s == HALUtil.VOLTAGE_OUT_OF_RANGE) + throw new IllegalArgumentException(message); + else if (s == HALUtil.LOOP_TIMING_ERROR) + throw new RuntimeException(message); + else if (s == HALUtil.INCOMPATIBLE_STATE + || s == HALUtil.ANALOG_TRIGGER_PULSE_OUTPUT_ERROR) + throw new IllegalStateException(message); + else if (s == HALUtil.NO_AVAILABLE_RESOURCES) + throw new RuntimeException(message); + else + throw new RuntimeException("Unknown error. Code: " + s + ". " + message); + } } } diff --git a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java index c0786c213a..9bb7ab2eae 100644 --- a/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java +++ b/wpilibj/wpilibJava/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java @@ -20,7 +20,7 @@ public class JNIWrapper if( !libraryLoaded ) { // create temporary file - jniLibrary = File.createTempFile("libwpilibJavaJNI", "so"); + jniLibrary = File.createTempFile("libwpilibJavaJNI", ".so"); // flag for delete on exit jniLibrary.deleteOnExit(); @@ -28,7 +28,7 @@ public class JNIWrapper int readBytes; - InputStream is = JNIWrapper.class.getResourceAsStream("linux-arm/libwpilibJavaJNI.so"); + InputStream is = JNIWrapper.class.getResourceAsStream("/linux-arm/libwpilibJavaJNI.so"); OutputStream os = new FileOutputStream(jniLibrary); @@ -50,7 +50,7 @@ public class JNIWrapper libraryLoaded = true; } - System.loadLibrary(jniLibrary.getAbsolutePath()); + System.load(jniLibrary.getAbsolutePath()); } catch( Exception ex ) {