public class Hub
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
static int |
ERROR_COMMUNICATION
Communication error.
|
static int |
ERROR_INVALID_COMMAND
Invalid command INS.
|
static int |
ERROR_INVALID_LENGTH
Wrong data field length.
|
static int |
ERROR_NVRAM
Error with NV memory.
|
static int |
ERROR_SLAVE
Slave ID is not available.
|
static int |
ERROR_TIMEOUT
Timeout occurred during command reception.
|
static int |
EVENT_SLAVE_CONNECTED |
static int |
EVENT_SLAVE_DATA_RECEIVED |
static int |
EVENT_SLAVE_DISCONNECTED |
static int |
EVENT_SLAVE_OVERCURRENT |
static int |
SLAVE_STATE_DISCONNECTED
Slave is disconnected.
|
static int |
SLAVE_STATE_ERROR
Slave error state (i.e.
|
static int |
SLAVE_STATE_READY
Slave is ready.
|
static int |
SLAVE_STATE_UNKNOWN
Slave state is unknown.
|
static int |
SLAVE_TYPE_RS232
RS232 slave type.
|
static int |
SLAVE_TYPE_USB
USB slave type.
|
Constructor and Description |
---|
Hub(java.io.FileDescriptor fd)
Constructs a new instance of this class from given FileDescriptor
|
Hub(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Constructs a new instance of this class from given InputStream and OutputStream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.io.InputStream |
getDataInputStream(int slaveID)
Returns instance of InputStream associated with slave.
|
java.io.OutputStream |
getDataOutputStream(int slaveID)
Returns instance of OutputStream associated with slave.
|
int |
getSlaveState(int slaveID)
Get port state.
|
int |
getSlaveType(int slaveID)
Get slave type.
|
byte[] |
getUsbDeviceDescriptor(int slaveID)
Get USB device descriptor.
|
java.lang.String |
getUsbStringDescriptor(int slaveID)
Get USB string descriptor.
|
byte[] |
readNVRAM(int slaveID)
Read data from NV memory.
|
void |
setAppleChargeCurrent(int current)
Set Apple devices charge current.
|
void |
setBaudRate(int slaveID,
int baudRate)
Set RS232 baud rate.
|
static void |
setDebug(boolean on)
Enable or disable debug output.
|
void |
setSlaveConnectionListener(SlaveConnection connection)
Set slave connection listener.
|
void |
writeNVRAM(int slaveID,
byte[] data)
Write data to NV memory.
|
public static final int ERROR_INVALID_LENGTH
public static final int ERROR_SLAVE
public static final int ERROR_INVALID_COMMAND
public static final int ERROR_TIMEOUT
public static final int ERROR_COMMUNICATION
public static final int ERROR_NVRAM
public static final int SLAVE_TYPE_USB
public static final int SLAVE_TYPE_RS232
public static final int SLAVE_STATE_DISCONNECTED
public static final int SLAVE_STATE_READY
public static final int SLAVE_STATE_UNKNOWN
public static final int SLAVE_STATE_ERROR
public static final int EVENT_SLAVE_CONNECTED
public static final int EVENT_SLAVE_DISCONNECTED
public static final int EVENT_SLAVE_DATA_RECEIVED
public static final int EVENT_SLAVE_OVERCURRENT
public Hub(java.io.InputStream inputStream, java.io.OutputStream outputStream)
inputStream
- the input stream.outputStream
- the output stream.public Hub(java.io.FileDescriptor fd)
fd
- the file descriptor.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public static void setDebug(boolean on)
on
- true to enable debug output.public void setSlaveConnectionListener(SlaveConnection connection)
connection
- the slave connection listener.public int getSlaveType(int slaveID) throws java.io.IOException
slaveID
- slave identifier.java.io.IOException
- if an I/O error occurs.public int getSlaveState(int slaveID) throws java.io.IOException
slaveID
- slave identifier.java.io.IOException
- if an I/O error occurs.public void writeNVRAM(int slaveID, byte[] data) throws java.io.IOException
This command preserves data for each slave in a separate slot. If there is already data in slot, it will be overwritten. Data to be written can be up to 128 bytes. If empty data field is sent, data will be erased.
slaveID
- slave identifier.data
- data to be written in NV memory.java.io.IOException
- if an I/O error occurs.public byte[] readNVRAM(int slaveID) throws java.io.IOException
Return data written in NV memory for the selected slave ID.
slaveID
- slave identifier.java.io.IOException
- if an I/O error occurs.public void setBaudRate(int slaveID, int baudRate) throws java.io.IOException
slaveID
- slave identifier.baudRate
- the baud rate.java.io.IOException
- if an I/O error occurs.public byte[] getUsbDeviceDescriptor(int slaveID) throws java.io.IOException
Return device descriptor from specified slave, which should be of USB type.
slaveID
- slave identifier.java.io.IOException
- if an I/O error occurs.public java.lang.String getUsbStringDescriptor(int slaveID) throws java.io.IOException
slaveID
- slave identifier.java.io.IOException
- if an I/O error occurs.public void setAppleChargeCurrent(int current) throws java.io.IOException
This settings is stored in NV memory and is used for all slave channels.
current
- Charge current in mA.java.io.IOException
- if an I/O error occurs.public java.io.OutputStream getDataOutputStream(int slaveID) throws java.io.IOException
slaveID
- slave identifier.java.io.IOException
- IOException if an I/O error occurs.public java.io.InputStream getDataInputStream(int slaveID) throws java.io.IOException
slaveID
- slave identifier.java.io.IOException
- IOException if an I/O error occurs.