|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.moxa.mxuportapi.MxUPortService
public class MxUPortService
The MxUPortService class offers service routines for MxUPorts in your system. These routines should
be used before accessing MxUPort. For example, the program should use
getPortInfoList
to get the list of MxUPort in your system
before using any MxUPort object.
Nested Class Summary | |
---|---|
static class |
MxUPortService.DeviceID
This class represents the supported UPort for MxUPort API. |
Constructor Summary | |
---|---|
MxUPortService()
|
Method Summary | |
---|---|
static int |
getDeviceInfoListCount(android.hardware.usb.UsbManager usbManager)
Returns the number of available UPort devices in the system. |
static java.util.List<MxUPort> |
getPortInfoList(android.hardware.usb.UsbManager usbManager)
Builds and returns a new List< MxUPort > from the attached UPort
, or returns null if a UPort is not available in system. |
static int |
requestPermission(android.content.Context context,
android.hardware.usb.UsbManager usbManager,
java.lang.String actionName,
int vid,
int pid,
android.content.BroadcastReceiver usbReceiver)
Requests USB permission to access; should get user's permission to access the USB device. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MxUPortService()
Method Detail |
---|
public static int getDeviceInfoListCount(android.hardware.usb.UsbManager usbManager)
usbManager
- The UsbManager object returned from getSystemService().
public static java.util.List<MxUPort> getPortInfoList(android.hardware.usb.UsbManager usbManager)
MxUPort
> from the attached UPort
, or returns null
if a UPort is not available in system. The ports
are sorted in the sequence they are discovered.
Example:
// Get a MxUPort list from current system
UsbManager mUsbManager = (UsbManager)getSystemService(Context.USB_SERVICE);
List<MxUPort> mPortList = MxUPortService.getPortInfoList(mUsbManager);
if( mPortList!=null ){
// Process more tasks
}
usbManager
- The UsbManager object returned from getSystemService().
MxUPort
>, or null
if no UPort is found.public static int requestPermission(android.content.Context context, android.hardware.usb.UsbManager usbManager, java.lang.String actionName, int vid, int pid, android.content.BroadcastReceiver usbReceiver)
Call this method to request the 1st parent USB device of MxUPort and return the remaining USB devices that need to get permission.
context
- The Context from the application. It is usually 'this'.usbManager
- The UsbManager object returned from getSystemService().actionName
- The unique name for specifying the permission request. It
is usually $(APP_NAME).USB_PERMISSION.vid
- Vendor ID. Give both vid and pid to narrow the MxUPorts inquiry.
Give both vid and pid with zero for all Moxa devices.pid
- Product ID. Give both vid and pid to narrow the MxUPorts inquiry.
Give both vid and pid with zero for all Moxa devices.usbReceiver
- A BroadcastReceiver object to receive the permission result.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |