SerialManagerpublic class SerialManager extends Object
Fields Summary |
---|
private static final String | TAG | private final android.content.Context | mContext | private final ISerialManager | mService |
Methods Summary |
---|
public java.lang.String[] | getSerialPorts()Returns a string array containing the names of available serial ports
try {
return mService.getSerialPorts();
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in getSerialPorts", e);
return null;
}
| public SerialPort | openSerialPort(java.lang.String name, int speed)Opens and returns the {@link android.hardware.SerialPort} with the given name.
The speed of the serial port must be one of:
50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600,
19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000,
1500000, 2000000, 2500000, 3000000, 3500000 or 4000000
try {
ParcelFileDescriptor pfd = mService.openSerialPort(name);
if (pfd != null) {
SerialPort port = new SerialPort(name);
port.open(pfd, speed);
return port;
} else {
throw new IOException("Could not open serial port " + name);
}
} catch (RemoteException e) {
Log.e(TAG, "exception in UsbManager.openDevice", e);
}
return null;
|
|