Class ParsecJNI
java.lang.Object
com.studica.frc.jni.StudicaJNIWrapper
com.studica.frc.jni.ParsecJNI
Raw JNI bindings for the Parsec driver. Use
Parsec instead.
Create methods return a positive handle, or a negative status code on failure. Other methods return a status code (0 on success) unless noted.
-
Nested Class Summary
Nested classes/interfaces inherited from class StudicaJNIWrapper
StudicaJNIWrapper.Helper -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndex of the CAN FD bit-rate-switch flag (0 or 1).static final intIndex of the CAN FD flag (0 or 1).static final intIndex of the configured CAN ID.static final intIndex of the distance-enabled flag (0 or 1).static final intIndex of the firmware version as (major << 16 | minor << 8 | patch), or -1.static final intIndex of the flag saying whether the zone mask is present (0 or 1).static final intIndex of the output rate in Hz, or 0 if not reported.static final intMinimum length of the array passed to getConfig().static final intIndex of the configuration version.static final intIndex of the enabled-zone mask.static final intIndex of the zone count, or 0 if not reported.static final intMinimum length of the info array passed to getScan().static final intLargest zone count (8x8 grid).static final shortDistance of a zone without a valid reading.static final intIndex of the frame counter.static final intIndex of the monotonic arrival time, nanoseconds.static final intFor createUsb: the Parsec on any USB port. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcreateCan(int busId, int deviceId) Opens a Parsec on CAN.static intcreateSerial(String devicePath) Opens a Parsec on a serial device path.static intcreateUsb(int usbPort) Opens a Parsec on USB.static voiddestroy(int handle) Closes a device.static intgetConfig(int handle, long[] out) Reads the device configuration.static intgetScan(int handle, short[] distanceMm, long[] info) Copies the newest frame.static booleanisConnected(int handle) Returns whether data arrived recently.static intsetOutputRate(int handle, int hz) Sets how often frames are sent.static intsetRangingFrequency(int handle, int hz) Sets how often the sensor measures.static intsetResolution(int handle, int zones) Selects the zone count.static intsetZoneMask(int handle, long mask) Chooses which zones are measured.Methods inherited from class StudicaJNIWrapper
forceLoad
-
Field Details
-
USB_ANY
public static final int USB_ANYFor createUsb: the Parsec on any USB port.- See Also:
-
MAX_ZONES
public static final int MAX_ZONESLargest zone count (8x8 grid).- See Also:
-
NO_READING
public static final short NO_READINGDistance of a zone without a valid reading.- See Also:
-
SEQUENCE
public static final int SEQUENCEIndex of the frame counter.- See Also:
-
TIMESTAMP_NS
public static final int TIMESTAMP_NSIndex of the monotonic arrival time, nanoseconds.- See Also:
-
INFO_SIZE
public static final int INFO_SIZEMinimum length of the info array passed to getScan().- See Also:
-
CONFIG_VERSION
public static final int CONFIG_VERSIONIndex of the configuration version.- See Also:
-
CONFIG_DISTANCE_ENABLED
public static final int CONFIG_DISTANCE_ENABLEDIndex of the distance-enabled flag (0 or 1).- See Also:
-
CONFIG_CAN_FD
public static final int CONFIG_CAN_FDIndex of the CAN FD flag (0 or 1).- See Also:
-
CONFIG_CAN_BRS
public static final int CONFIG_CAN_BRSIndex of the CAN FD bit-rate-switch flag (0 or 1).- See Also:
-
CONFIG_CAN_ID
public static final int CONFIG_CAN_IDIndex of the configured CAN ID.- See Also:
-
CONFIG_HAS_ZONE_MASK
public static final int CONFIG_HAS_ZONE_MASKIndex of the flag saying whether the zone mask is present (0 or 1).- See Also:
-
CONFIG_ZONE_MASK
public static final int CONFIG_ZONE_MASKIndex of the enabled-zone mask.- See Also:
-
CONFIG_FIRMWARE
public static final int CONFIG_FIRMWAREIndex of the firmware version as (major << 16 | minor << 8 | patch), or -1.- See Also:
-
CONFIG_OUTPUT_RATE
public static final int CONFIG_OUTPUT_RATEIndex of the output rate in Hz, or 0 if not reported.- See Also:
-
CONFIG_ZONES
public static final int CONFIG_ZONESIndex of the zone count, or 0 if not reported.- See Also:
-
CONFIG_SIZE
public static final int CONFIG_SIZEMinimum length of the array passed to getConfig().- See Also:
-
-
Method Details
-
createCan
public static int createCan(int busId, int deviceId) Opens a Parsec on CAN.- Parameters:
busId- CAN bus indexdeviceId- CAN device ID, 0-63- Returns:
- a handle, or a negative status code
-
createUsb
public static int createUsb(int usbPort) Opens a Parsec on USB.- Parameters:
usbPort- SystemCore USB port label 0-3, or USB_ANY- Returns:
- a handle, or a negative status code
-
createSerial
Opens a Parsec on a serial device path.- Parameters:
devicePath- e.g. "/dev/ttyACM0"- Returns:
- a handle, or a negative status code
-
destroy
public static void destroy(int handle) Closes a device. Safe with an invalid handle.- Parameters:
handle- the device
-
isConnected
public static boolean isConnected(int handle) Returns whether data arrived recently.- Parameters:
handle- the device- Returns:
- true if connected
-
getScan
public static int getScan(int handle, short[] distanceMm, long[] info) Copies the newest frame.- Parameters:
handle- the devicedistanceMm- receives the distances, at least MAX_ZONES longinfo- receives the frame details, at least INFO_SIZE long- Returns:
- the zone count, 0 if no recent frame, or a negative status code
-
setOutputRate
public static int setOutputRate(int handle, int hz) Sets how often frames are sent.- Parameters:
handle- the devicehz- rate, 1-60 Hz- Returns:
- status code
-
setResolution
public static int setResolution(int handle, int zones) Selects the zone count.- Parameters:
handle- the devicezones- 16 or 64- Returns:
- status code
-
setRangingFrequency
public static int setRangingFrequency(int handle, int hz) Sets how often the sensor measures.- Parameters:
handle- the devicehz- 1-60 Hz at 16 zones, 1-15 Hz at 64- Returns:
- status code
-
setZoneMask
public static int setZoneMask(int handle, long mask) Chooses which zones are measured.- Parameters:
handle- the devicemask- bit i enables zone i; must be non-zero- Returns:
- status code
-
getConfig
public static int getConfig(int handle, long[] out) Reads the device configuration.- Parameters:
handle- the deviceout- receives the configuration, at least CONFIG_SIZE long- Returns:
- status code
-