Package com.revrobotics.spark
Class SparkLowLevel
java.lang.Object
com.revrobotics.NativeResourceCleaner
com.revrobotics.spark.SparkLowLevel
- All Implemented Interfaces:
REVDevice,MotorController,AutoCloseable
- Direct Known Subclasses:
SparkBase
public abstract class SparkLowLevel
extends NativeResourceCleaner
implements MotorController, REVDevice, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classprotected static enumNested classes/interfaces inherited from class com.revrobotics.NativeResourceCleaner
NativeResourceCleaner.OnClean -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SparkLowLevel.SparkModelprotected final AtomicBooleanstatic final intstatic final intstatic final intstatic final intprotected final SparkLowLevel.MotorTypeprotected final long -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the SPARK ControllervoidCreate the sim gui Fault Manager for this Spark Deviceprotected NativeResourceCleaner.OnCleanNote: it is important that no reference to 'this' is taken in the implementation.intGet the configured Device ID of the SPARK.Get the firmware version of the SPARK as a string.intGet the firmware version of the SPARK.Get the motor type setting for the SPARK@Nullable SparkLowLevel.PeriodicStatus0@Nullable SparkLowLevel.PeriodicStatus1@Nullable SparkLowLevel.PeriodicStatus2@Nullable SparkLowLevel.PeriodicStatus3@Nullable SparkLowLevel.PeriodicStatus4@Nullable SparkLowLevel.PeriodicStatus5@Nullable SparkLowLevel.PeriodicStatus6@Nullable SparkLowLevel.PeriodicStatus7@Nullable SparkLowLevel.PeriodicStatus8@Nullable SparkLowLevel.PeriodicStatus9floatgetSafeFloat(float f) byte[]Get the unique serial number of the SPARK.voidsetCANMaxRetries(int numRetries) Set the maximum number of times to retry an RTR CAN frame.voidsetControlFramePeriodMs(int periodMs) Set the control frame send period for the native CAN Send thread.voidsetPeriodicFrameTimeout(int timeoutMs) Set the amount of time to wait for a periodic status frame before returning a timeout error.protected voidMethods inherited from class com.revrobotics.NativeResourceCleaner
registerCleanerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj.motorcontrol.MotorController
disable, get, getInverted, set, setInverted, setVoltage, setVoltage, stopMotor
-
Field Details
-
kAPIMajorVersion
public static final int kAPIMajorVersion -
kAPIMinorVersion
public static final int kAPIMinorVersion -
kAPIBuildVersion
public static final int kAPIBuildVersion -
kAPIVersion
public static final int kAPIVersion -
sparkHandle
protected final long sparkHandle -
isClosed
-
motorType
-
expectedSparkModel
-
-
Method Details
-
close
public void close()Closes the SPARK Controller- Specified by:
closein interfaceAutoCloseable
-
getCleanAction
Description copied from class:NativeResourceCleanerNote: it is important that no reference to 'this' is taken in the implementation.- Specified by:
getCleanActionin classNativeResourceCleaner- Returns:
- an action to run on clean
-
getFirmwareVersion
public int getFirmwareVersion()Get the firmware version of the SPARK.- Returns:
- uint32_t Firmware version integer. Value is represented as 4 bytes, Major.Minor.Build H.Build L
-
setControlFramePeriodMs
public void setControlFramePeriodMs(int periodMs) Set the control frame send period for the native CAN Send thread.- Parameters:
periodMs- The send period in milliseconds between 1ms and 100ms or set to 0 to disable periodic sends. Note this is not updated until the next call to Set() or SetReference().
-
getFirmwareString
Get the firmware version of the SPARK as a string.- Returns:
- std::string Human readable firmware version string
-
getSerialNumber
public byte[] getSerialNumber()Get the unique serial number of the SPARK. Not currently available.- Returns:
- byte[] Vector of bytes representig the unique serial number
-
getDeviceId
public int getDeviceId()Get the configured Device ID of the SPARK.- Returns:
- int device ID
-
getMotorType
Get the motor type setting for the SPARK- Returns:
- MotorType Motor type setting
-
setPeriodicFrameTimeout
public void setPeriodicFrameTimeout(int timeoutMs) Set the amount of time to wait for a periodic status frame before returning a timeout error. This timeout will apply to all periodic status frames for the SPARK motor controller.To prevent invalid timeout errors, the minimum timeout for a given periodic status is 2.1 times its period. To use the minimum timeout for all status frames, set timeoutMs to 0.
The default timeout is 500ms.
- Parameters:
timeoutMs- The timeout in milliseconds
-
getPeriodicStatus0
- Returns:
- periodic status 0, or null if it's not found
-
getPeriodicStatus1
- Returns:
- periodic status 1, or null if it's not found
-
getPeriodicStatus2
- Returns:
- periodic status 2, or null if it's not found
-
getPeriodicStatus3
- Returns:
- periodic status 3, or null if it's not found
-
getPeriodicStatus4
- Returns:
- periodic status 4, or null if it's not found
-
getPeriodicStatus5
- Returns:
- periodic status 5, or null if it's not found
-
getPeriodicStatus6
- Returns:
- periodic status 6, or null if it's not found
-
getPeriodicStatus7
- Returns:
- periodic status 7, or null if it's not found
-
getPeriodicStatus8
- Returns:
- periodic status 8, or null if it's not found
-
getPeriodicStatus9
- Returns:
- periodic status 9, or null if it's not found
-
setCANMaxRetries
public void setCANMaxRetries(int numRetries) Set the maximum number of times to retry an RTR CAN frame. This applies to calls such as SetParameter* and GetParameter* where a request is made to the SPARK motor controller and a response is expected. Anytime sending the request or receiving the response fails, it will retry the request a number of times, no more than the value set by this method. If an attempt succeeds, it will immediately return. The minimum number of retries is 0, where only a single attempt will be made and will return regardless of success or failure.The default maximum is 5 retries.
- Parameters:
numRetries- The maximum number of retries
-
getSafeFloat
public float getSafeFloat(float f) -
createSimFaultManager
public void createSimFaultManager()Create the sim gui Fault Manager for this Spark Device -
throwIfClosed
protected void throwIfClosed()
-