Class ParsecJNI


public final class ParsecJNI extends StudicaJNIWrapper
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Index of the CAN FD bit-rate-switch flag (0 or 1).
    static final int
    Index of the CAN FD flag (0 or 1).
    static final int
    Index of the configured CAN ID.
    static final int
    Index of the distance-enabled flag (0 or 1).
    static final int
    Index of the firmware version as (major << 16 | minor << 8 | patch), or -1.
    static final int
    Index of the flag saying whether the zone mask is present (0 or 1).
    static final int
    Index of the output rate in Hz, or 0 if not reported.
    static final int
    Minimum length of the array passed to getConfig().
    static final int
    Index of the configuration version.
    static final int
    Index of the enabled-zone mask.
    static final int
    Index of the zone count, or 0 if not reported.
    static final int
    Minimum length of the info array passed to getScan().
    static final int
    Largest zone count (8x8 grid).
    static final short
    Distance of a zone without a valid reading.
    static final int
    Index of the frame counter.
    static final int
    Index of the monotonic arrival time, nanoseconds.
    static final int
    For createUsb: the Parsec on any USB port.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    createCan(int busId, int deviceId)
    Opens a Parsec on CAN.
    static int
    createSerial(String devicePath)
    Opens a Parsec on a serial device path.
    static int
    createUsb(int usbPort)
    Opens a Parsec on USB.
    static void
    destroy(int handle)
    Closes a device.
    static int
    getConfig(int handle, long[] out)
    Reads the device configuration.
    static int
    getScan(int handle, short[] distanceMm, long[] info)
    Copies the newest frame.
    static boolean
    isConnected(int handle)
    Returns whether data arrived recently.
    static int
    setOutputRate(int handle, int hz)
    Sets how often frames are sent.
    static int
    setRangingFrequency(int handle, int hz)
    Sets how often the sensor measures.
    static int
    setResolution(int handle, int zones)
    Selects the zone count.
    static int
    setZoneMask(int handle, long mask)
    Chooses which zones are measured.

    Methods inherited from class StudicaJNIWrapper

    forceLoad

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • USB_ANY

      public static final int USB_ANY
      For createUsb: the Parsec on any USB port.
      See Also:
    • MAX_ZONES

      public static final int MAX_ZONES
      Largest zone count (8x8 grid).
      See Also:
    • NO_READING

      public static final short NO_READING
      Distance of a zone without a valid reading.
      See Also:
    • SEQUENCE

      public static final int SEQUENCE
      Index of the frame counter.
      See Also:
    • TIMESTAMP_NS

      public static final int TIMESTAMP_NS
      Index of the monotonic arrival time, nanoseconds.
      See Also:
    • INFO_SIZE

      public static final int INFO_SIZE
      Minimum length of the info array passed to getScan().
      See Also:
    • CONFIG_VERSION

      public static final int CONFIG_VERSION
      Index of the configuration version.
      See Also:
    • CONFIG_DISTANCE_ENABLED

      public static final int CONFIG_DISTANCE_ENABLED
      Index of the distance-enabled flag (0 or 1).
      See Also:
    • CONFIG_CAN_FD

      public static final int CONFIG_CAN_FD
      Index of the CAN FD flag (0 or 1).
      See Also:
    • CONFIG_CAN_BRS

      public static final int CONFIG_CAN_BRS
      Index of the CAN FD bit-rate-switch flag (0 or 1).
      See Also:
    • CONFIG_CAN_ID

      public static final int CONFIG_CAN_ID
      Index of the configured CAN ID.
      See Also:
    • CONFIG_HAS_ZONE_MASK

      public static final int CONFIG_HAS_ZONE_MASK
      Index of the flag saying whether the zone mask is present (0 or 1).
      See Also:
    • CONFIG_ZONE_MASK

      public static final int CONFIG_ZONE_MASK
      Index of the enabled-zone mask.
      See Also:
    • CONFIG_FIRMWARE

      public static final int CONFIG_FIRMWARE
      Index of the firmware version as (major << 16 | minor << 8 | patch), or -1.
      See Also:
    • CONFIG_OUTPUT_RATE

      public static final int CONFIG_OUTPUT_RATE
      Index of the output rate in Hz, or 0 if not reported.
      See Also:
    • CONFIG_ZONES

      public static final int CONFIG_ZONES
      Index of the zone count, or 0 if not reported.
      See Also:
    • CONFIG_SIZE

      public static final int CONFIG_SIZE
      Minimum 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 index
      deviceId - 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

      public static int createSerial(String devicePath)
      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 device
      distanceMm - receives the distances, at least MAX_ZONES long
      info - 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 device
      hz - rate, 1-60 Hz
      Returns:
      status code
    • setResolution

      public static int setResolution(int handle, int zones)
      Selects the zone count.
      Parameters:
      handle - the device
      zones - 16 or 64
      Returns:
      status code
    • setRangingFrequency

      public static int setRangingFrequency(int handle, int hz)
      Sets how often the sensor measures.
      Parameters:
      handle - the device
      hz - 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 device
      mask - 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 device
      out - receives the configuration, at least CONFIG_SIZE long
      Returns:
      status code