jAER project on SourceForge

net.sf.jaer.hardwareinterface.usb.toradex
Class ToradexOakG3AxisAccelerationSensor

java.lang.Object
  extended by de.thesycon.usbio.UsbIo
      extended by de.thesycon.usbio.UsbIoPipe
          extended by de.thesycon.usbio.UsbIoThread
              extended by de.thesycon.usbio.UsbIoReader
                  extended by net.sf.jaer.hardwareinterface.usb.toradex.ToradexOakG3AxisAccelerationSensor
All Implemented Interfaces:
de.thesycon.usbio.UsbIoErrorCodes, de.thesycon.usbio.UsbIoInterface, de.thesycon.usbio.UsbSpec, java.lang.Runnable, HardwareInterface

public class ToradexOakG3AxisAccelerationSensor
extends de.thesycon.usbio.UsbIoReader
implements HardwareInterface, de.thesycon.usbio.UsbIoErrorCodes

Interfaces to the Toradex Oak G 3 axis acceleration sensor. See Oak G user guide.)

To use this sensor, you must update the driver to the Thesycon USBIO driver in drivers/driver_ToradexAccelerometer. This takes a manual installation because Windows will always install the HID driver if it is allowed to. This installation is a bit tricky. Follow these steps:

  1. Plug in the sensor. Windows will install the default HID driver.
  2. Open the device manager. Find the "Human Interface Devices" device named "USB Human Interface Device" with the VID of 0x1b67 and PID of 0x000a. You can find this by double-clicking the device and clicking on the "Details" tab. Don't choose your mouse by mistake.
  3. Choose "Update driver" from the Driver tab. Choose "No, not this time" and "Install from a list or specific location". Then choose "Don't search, I will choose the driver to install." Choose "Have Disk..." and navigate to the driver_ToradexAccelerometer" folder in the drivers folder of jAER. Choose the "usbio.inf" file there.
  4. Now the "USBIO Toradex Oak G Accelerometer" should appear in the Hardware Update Wizard chooser. Select this device.

If you want to set sample rate or other parameters, then you need to install the default windows HID driver and use the OakG software to change the settings. Toradex does not sufficiently document their report format to allow customization except through their own (C) library functions. To avoid a JNI interface maintainance hassle, we use a pure java Thesycon interface here.

Author:
tobi

Nested Class Summary
 class ToradexOakG3AxisAccelerationSensor.Acceleration
          Encapsulates the most recent acceleration vector.
 
Field Summary
static float ACCEL_SCALE
           
static java.lang.String ACCEL_UNIT
           
static java.lang.String GUID
           
static float MAX_ACCEL
           
static float TIME_SCALE
           
static java.lang.String TIME_UNIT
           
 
Fields inherited from class de.thesycon.usbio.UsbIoThread
BufPool, MaxErrorCount, PendingList, T
 
Fields inherited from class de.thesycon.usbio.UsbIo
Handle
 
Fields inherited from interface de.thesycon.usbio.UsbIoErrorCodes
USBIO_ERR_ADDITIONAL_EVENT_SIGNALLED, USBIO_ERR_ALREADY_BOUND, USBIO_ERR_ALREADY_CONFIGURED, USBIO_ERR_BABBLE_DETECTED, USBIO_ERR_BAD_START_FRAME, USBIO_ERR_BTSTUFF, USBIO_ERR_BUFFER_OVERRUN, USBIO_ERR_BUFFER_UNDERRUN, USBIO_ERR_BULK_RESTRICTION, USBIO_ERR_CANCELED, USBIO_ERR_CONTROL_NOT_SUPPORTED, USBIO_ERR_CONTROL_RESTRICTION, USBIO_ERR_CRC, USBIO_ERR_DATA_BUFFER_ERROR, USBIO_ERR_DATA_OVERRUN, USBIO_ERR_DATA_TOGGLE_MISMATCH, USBIO_ERR_DATA_UNDERRUN, USBIO_ERR_DEMO_EXPIRED, USBIO_ERR_DEV_NOT_RESPONDING, USBIO_ERR_DEVICE_GONE, USBIO_ERR_DEVICE_NOT_FOUND, USBIO_ERR_DEVICE_NOT_OPEN, USBIO_ERR_DEVICE_NOT_PRESENT, USBIO_ERR_ENDPOINT_HALTED, USBIO_ERR_EP0_RESTRICTION, USBIO_ERR_ERROR_BUSY, USBIO_ERR_ERROR_SHORT_TRANSFER, USBIO_ERR_FAILED, USBIO_ERR_FIFO, USBIO_ERR_FRAME_CONTROL_NOT_OWNED, USBIO_ERR_FRAME_CONTROL_OWNED, USBIO_ERR_INSUFFICIENT_RESOURCES, USBIO_ERR_INTERFACE_NOT_FOUND, USBIO_ERR_INTERNAL_HC_ERROR, USBIO_ERR_INTERRUPT_RESTRICTION, USBIO_ERR_INVALID_CONFIGURATION_DESCRIPTOR, USBIO_ERR_INVALID_DEVICE_STATE, USBIO_ERR_INVALID_DIRECTION, USBIO_ERR_INVALID_FUNCTION_PARAM, USBIO_ERR_INVALID_INBUFFER, USBIO_ERR_INVALID_IOCTL, USBIO_ERR_INVALID_ISO_PACKET, USBIO_ERR_INVALID_OUTBUFFER, USBIO_ERR_INVALID_PARAM, USBIO_ERR_INVALID_PARAMETER, USBIO_ERR_INVALID_PIPE_FLAGS, USBIO_ERR_INVALID_PIPE_HANDLE, USBIO_ERR_INVALID_POWER_STATE, USBIO_ERR_INVALID_RECIPIENT, USBIO_ERR_INVALID_TYPE, USBIO_ERR_INVALID_URB_FUNCTION, USBIO_ERR_ISO_NA_LATE_USBPORT, USBIO_ERR_ISO_NOT_ACCESSED_BY_HW, USBIO_ERR_ISO_NOT_ACCESSED_LATE, USBIO_ERR_ISO_RESTRICTION, USBIO_ERR_ISO_TD_ERROR, USBIO_ERR_ISOCH_REQUEST_FAILED, USBIO_ERR_LOAD_SETUP_API_FAILED, USBIO_ERR_NO_BANDWIDTH, USBIO_ERR_NO_MEMORY, USBIO_ERR_NO_SUCH_DEVICE_INSTANCE, USBIO_ERR_NOT_ACCESSED, USBIO_ERR_NOT_BOUND, USBIO_ERR_NOT_CONFIGURED, USBIO_ERR_NOT_SUPPORTED, USBIO_ERR_OPEN_PIPES, USBIO_ERR_OUT_OF_ADDRESS_SPACE, USBIO_ERR_OUT_OF_MEMORY, USBIO_ERR_PENDING_REQUESTS, USBIO_ERR_PID_CHECK_FAILURE, USBIO_ERR_PIPE_NOT_FOUND, USBIO_ERR_PIPE_RESTRICTION, USBIO_ERR_PIPE_SIZE_RESTRICTION, USBIO_ERR_POOL_EMPTY, USBIO_ERR_POWER_DOWN, USBIO_ERR_REQUEST_FAILED, USBIO_ERR_RESERVED1, USBIO_ERR_RESERVED2, USBIO_ERR_SET_CONFIG_FAILED, USBIO_ERR_SET_CONFIGURATION_FAILED, USBIO_ERR_STALL_PID, USBIO_ERR_STATUS_NOT_MAPPED, USBIO_ERR_SUCCESS, USBIO_ERR_TIMEOUT, USBIO_ERR_TOO_MUCH_ISO_PACKETS, USBIO_ERR_UNEXPECTED_PID, USBIO_ERR_USBD_BUFFER_TOO_SMALL, USBIO_ERR_USBD_INTERFACE_NOT_FOUND, USBIO_ERR_USBD_TIMEOUT, USBIO_ERR_VERSION_MISMATCH, USBIO_ERR_VID_RESTRICTION, USBIO_ERR_XACT_ERROR
 
Fields inherited from interface de.thesycon.usbio.UsbIoInterface
DevicePowerStateD0, DevicePowerStateD1, DevicePowerStateD2, DevicePowerStateD3, INFINITE, PipeTypeBulk, PipeTypeControl, PipeTypeInterrupt, PipeTypeIsochronous, RecipientDevice, RecipientEndpoint, RecipientInterface, RecipientOther, RequestTypeClass, RequestTypeVendor, USBIO_DEVICE_INFOFLAG_HIGH_SPEED, USBIO_ENABLE_REMOTE_WAKEUP, USBIO_INFOFLAG_CHECKED_BUILD, USBIO_INFOFLAG_DEMO_VERSION, USBIO_INFOFLAG_LIGHT_VERSION, USBIO_INFOFLAG_VS_LIGHT_VERSION, USBIO_RESET_DEVICE_ON_CLOSE, USBIO_SHORT_TRANSFER_OK, USBIO_START_TRANSFER_ASAP, USBIO_UNCONFIGURE_ON_CLOSE
 
Fields inherited from interface de.thesycon.usbio.UsbSpec
AUDIO_CS_ENDPOINT_TYPE, AUDIO_CS_INTERFACE_TYPE, USB_CONFIGURATION_DESCRIPTOR_TYPE, USB_DEVICE_DESCRIPTOR_TYPE, USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE, USB_ENDPOINT_DESCRIPTOR_TYPE, USB_HID_DESCRIPTOR_TYPE, USB_INTERFACE_DESCRIPTOR_TYPE, USB_INTERFACE_POWER_DESCRIPTOR_TYPE, USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE, USB_STRING_DESCRIPTOR_TYPE
 
Constructor Summary
ToradexOakG3AxisAccelerationSensor()
          Constructs a new ToradexOakG3AxisAccelerationSensor.
 
Method Summary
 void bufErrorHandler(de.thesycon.usbio.UsbIoBuf buf)
           
 ToradexOakG3AxisAccelerationSensor.Acceleration getAcceleration()
          Returns the latest sampled acceleration values.
 java.beans.PropertyChangeSupport getSupport()
          Get the support and add yourself as a property change listener to obtain notifications of new sensor readings
 java.lang.String getTypeName()
          get text name of interface, e.g.
static void main(java.lang.String[] args)
           
 void onThreadExit()
           
 void open()
          Opens the device driver and gets a handle to the device which is internally maintained.
 void processBuffer(de.thesycon.usbio.UsbIoBuf buf)
           
 void processData(de.thesycon.usbio.UsbIoBuf buf)
           
 void startThread(int MaxIoErrorCount)
           
 
Methods inherited from class de.thesycon.usbio.UsbIoReader
run
 
Methods inherited from class de.thesycon.usbio.UsbIoThread
allocateBuffers, freeBuffers, shutdownThread
 
Methods inherited from class de.thesycon.usbio.UsbIoPipe
abortPipe, bind, getPipeParameters, pipeControlTransferIn, pipeControlTransferOut, queryPipeStatistics, read, readSync, readSync, resetPipe, resetPipeStatistics, setPipeParameters, setupPipeStatistics, unbind, waitForCompletion, waitForCompletion, write, writeSync, writeSync
 
Methods inherited from class de.thesycon.usbio.UsbIo
acquireDevice, classOrVendorInRequest, classOrVendorOutRequest, clearFeature, close, createDeviceList, cyclePort, destroyDeviceList, errorText, finalize, getBandwidthInfo, getConfiguration, getConfigurationDescriptor, getConfigurationInfo, getCurrentFrameNumber, getDescriptor, getDescriptor, getDeviceDescriptor, getDeviceInfo, getDeviceParameters, getDevicePowerState, getDriverInfo, getInterface, getStatus, getStringDescriptor, isCheckedBuild, isDemoVersion, isLightVersion, isOpen, isOperatingAtHighSpeed, open, releaseDevice, resetDevice, setConfiguration, setDescriptor, setDeviceParameters, setDevicePowerState, setFeature, setInterface, unconfigureDevice
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jaer.hardwareinterface.HardwareInterface
close, isOpen
 

Field Detail

GUID

public static java.lang.String GUID

TIME_SCALE

public static final float TIME_SCALE
See Also:
Constant Field Values

ACCEL_SCALE

public static final float ACCEL_SCALE
See Also:
Constant Field Values

TIME_UNIT

public static final java.lang.String TIME_UNIT
See Also:
Constant Field Values

ACCEL_UNIT

public static final java.lang.String ACCEL_UNIT
See Also:
Constant Field Values

MAX_ACCEL

public static final float MAX_ACCEL
See Also:
Constant Field Values
Constructor Detail

ToradexOakG3AxisAccelerationSensor

public ToradexOakG3AxisAccelerationSensor()
Constructs a new ToradexOakG3AxisAccelerationSensor. Use open() to start reading valoues.

Method Detail

processBuffer

public void processBuffer(de.thesycon.usbio.UsbIoBuf buf)
Specified by:
processBuffer in class de.thesycon.usbio.UsbIoThread

processData

public void processData(de.thesycon.usbio.UsbIoBuf buf)
Overrides:
processData in class de.thesycon.usbio.UsbIoThread

bufErrorHandler

public void bufErrorHandler(de.thesycon.usbio.UsbIoBuf buf)
Specified by:
bufErrorHandler in class de.thesycon.usbio.UsbIoThread

onThreadExit

public void onThreadExit()
Specified by:
onThreadExit in class de.thesycon.usbio.UsbIoThread

getTypeName

public java.lang.String getTypeName()
Description copied from interface: HardwareInterface
get text name of interface, e.g. "CypressFX2" or "SiLabsC8051F320"

Specified by:
getTypeName in interface HardwareInterface

open

public void open()
          throws HardwareInterfaceException
Description copied from interface: HardwareInterface
Opens the device driver and gets a handle to the device which is internally maintained.

Specified by:
open in interface HardwareInterface
Throws:
HardwareInterfaceException - if there is a problem. Diagnostics are printeds.

startThread

public void startThread(int MaxIoErrorCount)
Overrides:
startThread in class de.thesycon.usbio.UsbIoThread

main

public static final void main(java.lang.String[] args)

getAcceleration

public ToradexOakG3AxisAccelerationSensor.Acceleration getAcceleration()
Returns the latest sampled acceleration values. Note that this method is thread-safe but the underlying Acceleration object can change its contents if a new reading is captured.

Returns:
the (reused) acceleration object

getSupport

public java.beans.PropertyChangeSupport getSupport()
Get the support and add yourself as a property change listener to obtain notifications of new sensor readings


jAER project on SourceForge