FileDocCategorySizeDatePackage
SerialManager.javaAPI DocAndroid 5.1 API2634Thu Mar 12 22:22:10 GMT 2015android.hardware

SerialManager

public class SerialManager extends Object
hide

Fields Summary
private static final String
TAG
private final android.content.Context
mContext
private final ISerialManager
mService
Constructors Summary
public SerialManager(android.content.Context context, ISerialManager service)
{@hide}


          
         
        mContext = context;
        mService = service;
    
Methods Summary
public java.lang.String[]getSerialPorts()
Returns a string array containing the names of available serial ports

return
names of available serial ports

        try {
            return mService.getSerialPorts();
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException in getSerialPorts", e);
            return null;
        }
    
public SerialPortopenSerialPort(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

param
name of the serial port
param
speed at which to open the serial port
return
the serial port

        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;