Class JniAdeptDepp
- All Implemented Interfaces:
RegisterIo
This class encapsulates and extends the Digilent Adept2 APIs through Jni calls.
Most target hardware now uses the Depp2 protocol in which the transaction buffer contains 4 header bytes. The first two bytes contain the payload length (that is, excluding the header bytes) and the second two bytes contain the register start offset. The byte order for the header bytes is little-endian.
Note that the hardware treats the MSB of the register start offset as a flag to activate the DEPP wait feature. Therefore the highest allowed offset is 0x7fff. The wait feature allows a subsequent transaction to be started immediately after the previous call returns and it will block until the previous transaction completes. This avoids the need for polling in many situations if the feature has been implemented in the hardware.
Most of the methods described here that read or write the hardware implement a locking mechanism to grant exclusive access to the hardware device. This only applies for calls from within the same program.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNative interface wrappers to Digilent Adept DEPP API.classA DEPP exception that encapsulates the DEPP error codes/messages.classstatic classNative interface wrappers to Digilent Adept DJTG API.static classNative interface wrappers to Digilent Adept DMGR API. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static ActionListenerDeprecated.(package private) static ActionListenerDeprecated.(package private) ActionListener -
Constructor Summary
ConstructorsConstructorDescriptionJniAdeptDepp(String dev) ConstructorJniAdeptDepp(String dev, ActionListener al) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMenuItems(JMenu menu) A convenience function to add some standard menu items to a menu.voidclose()Closes a devicevoidconnect()Starts a timer that periodically tries to connect to a device until it succeeds.voiddisable()Disables the DEPP protocol for the devicevoidStops a timer that periodically tries to connect to a devicevoidenable()Enables the DEPP protocol for the devicevoidget(byte[] addr, byte[] data) Gets multiple bytesvoidget(byte addr, byte[] buf) Gets single bytevoidget(int base, byte[] regs) Reads consecutive bytes from hardware (Depp2).voidget(int base, int addr, byte[] regs) Reads consecutive bytes from hardware (Depp2).byte[]getByteArray(int size) Deprecated.byte[]getByteArray(int size, int off) Deprecated.voidgetBytes(int base, int addr, byte[] regs) Reads consecutive bytes from legacy hardware.static PreferencesgetDevicePreferences(Class cl, String node) Deprecated.static voidimportHardware(String url) Deprecated.voidlock()Grants exclusive access to DEPP interface.makeDeviceComboBox(String selectedName, ActionListener aL, String filter) Deprecated.static JMenumakeDeviceMenu(String title, ActionListener aL) Deprecated.booleanOK()Deprecated.voidopen()Opens a devicevoidpop(byte base, byte[] buf) Deprecated.voidpush(byte base, byte[] buf) Deprecated.voidpush(int base, int len, int addr, byte[] buf, boolean waitFlag) Deprecated.voidput(byte[] buf) Puts multiple addr,byte pairsvoidput(byte base, byte data) Puts single addr,bytevoidput(int base, int addr, byte[] regs) Writes array of bytes to hardware (Depp2)<T extends Byte, Integer, Short, Long>
voidput(int base, int addr, T val) Writes a value to hardware in little-endian order (Depp2)voidput(int base, ByteBuffer bb) Writes byte buffer to hardware (Depp2)voidput1(int base, int addr, byte[] regs) Writes array of bytes to legacy hardware.static String[]Creates a dialog to allow the user to select a connected devicestatic StringselectDevice(String filter) Deprecated.static voidWrites information about enumerated devices to System.outvoidunlock()Releases access to DEPP interface.
-
Field Details
-
jtg
-
importHWAL
Deprecated.Import database of known hardware from web database.
- See Also:
-
enumerateAL
Deprecated. -
timerAL
ActionListener timerAL
-
-
Constructor Details
-
JniAdeptDepp
-
JniAdeptDepp
Constructor
- Parameters:
dev- Connection name of deviceal- ActionListener to replace default timer (can be null)
-
-
Method Details
-
addMenuItems
A convenience function to add some standard menu items to a menu.
- Parameters:
menu- The menu to which the items are added.
-
lock
public void lock()Grants exclusive access to DEPP interface.
Blocks until interface is available.
-
unlock
public void unlock()Releases access to DEPP interface.
-
OK
Deprecated. -
showEnumeratedDevices
public static void showEnumeratedDevices()Writes information about enumerated devices to System.out
-
connect
public void connect()Starts a timer that periodically tries to connect to a device until it succeeds.
-
disconnect
public void disconnect()Stops a timer that periodically tries to connect to a device
After stopping the timer, closes the device.
-
open
Opens a device
- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
close
-
enable
public void enable()Enables the DEPP protocol for the device
-
disable
public void disable()Disables the DEPP protocol for the device
-
get
Gets single byte
- Parameters:
addr- The register addressbuf- Array to receive the data- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
get
Gets multiple bytes
- Parameters:
addr- Array of addresses to readdata- Array to receive the data- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
put
Puts single addr,byte
- Parameters:
base- Address to writedata- Data to write- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
put
Puts multiple addr,byte pairs
- Parameters:
buf- Array of address/data pairs to write- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
put
public <T extends Byte, Integer, Short, Long> void put(int base, int addr, T val) throws RegisterIoException Writes a value to hardware in little-endian order (Depp2)
Consider using
put(int,java.nio.ByteBuffer)instead.Integer, Short, Long and Byte values are allowed, others result in RuntimeException.
- Type Parameters:
T- Type of value to write- Parameters:
base- DEPP base addressaddr- Register offsetval- Value to write- Throws:
RegisterIoException- RegisterIo exception
-
push
@Deprecated public void push(int base, int len, int addr, byte[] buf, boolean waitFlag) throws JniAdeptDepp.DeppException Deprecated.Writes array of bytes to hardware (Depp2)
Use
put(int,java.nio.ByteBuffer)instead.- Parameters:
base- DEPP base addresslen- Transaction lengthaddr- Register start offsetbuf- Values to writewaitFlag- If true, activates the DEPP wait in hardware- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
push
Deprecated.Writes array of bytes to hardware
Use
put(int,java.nio.ByteBuffer)instead.- Parameters:
base- DEPP base addressbuf- Values to write- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
pop
Deprecated.Reads array of bytes from hardware
Use
get(int,byte[])instead.- Parameters:
base- DEPP base addressbuf- Values to write- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
put1
Writes array of bytes to legacy hardware.
Avoid using this for new applications. May be required for some legacy hardware.
- Parameters:
base- DEPP base addressaddr- Register start offsetregs- Values to write- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
put
Writes array of bytes to hardware (Depp2)
In contrast to
put(int,java.nio.ByteBuffer)this method initialises the first four header bytes. The first two bytes are filled with the data payload length (regs.length-4) and the second two bytes are filled with the register start offset (addr). Any values in these locations in the array passed to this method will therefore be overwritten.- Specified by:
putin interfaceRegisterIo- Parameters:
base- DEPP base addressaddr- Register start offsetregs- Write transaction buffer, payload starting at byte 4- Throws:
RegisterIoException- Register I/O exception
-
put
Writes byte buffer to hardware (Depp2)
The buffer should contain the payload length (2 bytes, little-endian, excludes the 4 header bytes) followed by the register start offset (2 bytes, little-endian) followed by the data.
- Specified by:
putin interfaceRegisterIo- Parameters:
base- DEPP base addressbb- Write transaction buffer- Throws:
RegisterIoException- Register I/O exception
-
getBytes
Reads consecutive bytes from legacy hardware.
Reads regs.length bytes.
- Parameters:
base- DEPP base addressaddr- Register start offsetregs- Array to receive data- Throws:
JniAdeptDepp.DeppException- DEPP exception
-
get
Reads consecutive bytes from hardware (Depp2).
Reads regs.length bytes.
- Specified by:
getin interfaceRegisterIo- Parameters:
base- DEPP base addressaddr- Register start offsetregs- Array to receive data- Throws:
RegisterIoException- Register I/O exception
-
get
Reads consecutive bytes from hardware (Depp2).
Reads regs.length bytes.
This version of get is intended to be called after the header has been sent.
- Specified by:
getin interfaceRegisterIo- Parameters:
base- DEPP base addressregs- Array to receive data- Throws:
RegisterIoException- Register I/O exception
-
getByteArray
Deprecated. -
getByteArray
Deprecated. -
importHardware
Deprecated.Imports list of known hardware from web (legacy code)
- Parameters:
url- The URL of the XML data
-
makeDeviceMenu
Deprecated. -
selectDevice
Deprecated. -
selectConnectedDevice
Creates a dialog to allow the user to select a connected device
- Returns:
- Data describing selected device (or null if nothing selected)
-
makeDeviceComboBox
@Deprecated public static JComboBox<String> makeDeviceComboBox(String selectedName, ActionListener aL, String filter) Deprecated. -
getDevicePreferences
Deprecated.
-