Package jmri.jmrix
Class UsbPortAdapter
java.lang.Object
jmri.jmrix.AbstractPortController
jmri.jmrix.UsbPortAdapter
- All Implemented Interfaces:
PortAdapter
- Direct Known Subclasses:
AnymaDMX_UsbPortAdapter
Enables basic setup of a USB interface for a jmrix implementation.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option -
Field Summary
FieldsFields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, manufacturerName, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, reconnectMaxAttempts, reconnectMaxInterval -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure all of the other jmrix widgets needed to work with this adapter.voidconnect()Open the connection.Get the InputStream from the port.Get the outputStream to the port.Get the list of USB locations with devices matching a single vendor/product ID combination.Get the device serial number.javax.usb.UsbDevicevoidrecover()This is called when a connection is initially lost.booleansendControlTransfer(int requestType, int request, int value, int index, byte[] data) send USB control transfervoidvoidsetProductID(Short value) voidsetSerialNumber(String serialNumber) Set the device serial number.voidsetVendorID(Short value) Methods inherited from class jmri.jmrix.AbstractPortController
closeConnection, configureOption1, configureOption2, configureOption3, configureOption4, dispose, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemConnectionMemo, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, purgeStream, reconnect, reconnectFromLoop, resetupConnection, safeSleep, setClosed, setDisabled, setManufacturer, setOpened, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName, status
-
Field Details
-
usbDevice
-
-
Constructor Details
-
UsbPortAdapter
-
-
Method Details
-
getVendorID
-
setVendorID
-
getProductID
-
setProductID
-
getSerialNumber
Get the device serial number.- Returns:
- the serial number or null if there is no serial number
-
setSerialNumber
Set the device serial number.- Parameters:
serialNumber- the serial number; if null, empty, or only containing whitespace, sets property to null
-
getUsbDevice
-
openPort
-
connect
Open the connection.- Throws:
IOException- if unable to connect
-
getInputStream
Get the InputStream from the port.- Specified by:
getInputStreamin interfacePortAdapter- Specified by:
getInputStreamin classAbstractPortController- Returns:
- the InputStream from the port
-
getOutputStream
Get the outputStream to the port.- Specified by:
getOutputStreamin interfacePortAdapter- Specified by:
getOutputStreamin classAbstractPortController- Returns:
- the outputStream to the port
-
recover
This is called when a connection is initially lost. After checking the allowConnectionRecovery flag, closes the connection, resets the open flag and attempts a reconnection.- Specified by:
recoverin interfacePortAdapter- Overrides:
recoverin classAbstractPortController
-
configure
Configure all of the other jmrix widgets needed to work with this adapter. -
getPortNames
Get the list of USB locations with devices matching a single vendor/product ID combination. These are "portNames" to match the calling API.- Returns:
- the list of locations with matching devices; this is an empty list if there are no matches
-
setPort
-
getCurrentPortName
- Specified by:
getCurrentPortNamein interfacePortAdapter- Specified by:
getCurrentPortNamein classAbstractPortController
-
sendControlTransfer
send USB control transfer- Parameters:
requestType- the request typerequest- the requestvalue- the valueindex- the indexdata- the data- Returns:
- true if successful sent
-