Code example for UsbDeviceConnection

Methods: controlTransfer

0
    private static final int USB_RT_ACM = UsbConstants.USB_TYPE_CLASS | USB_RECIP_INTERFACE;
 
    private static final int SET_LINE_CODING = 0x20;  // USB CDC 1.1 section 6.2
 
    private int sendAcmControlMessage(int request, int value, byte[] buf) {
        return mConnection.controlTransfer(USB_RT_ACM, request, value, 0, buf, buf != null ? buf.length : 0, 5000);
    } 
 
    private int setAcmLineCoding(int bitRate, int stopBits, int parity, int dataBits) {
        byte[] msg = {
                (byte) ( bitRate & 0xff),
                (byte) ((bitRate >> 8 ) & 0xff),
                (byte) ((bitRate >> 16) & 0xff),
                (byte) ((bitRate >> 24) & 0xff),
 
                (byte) stopBits,
                (byte) parity,
                (byte) dataBits};
        return sendAcmControlMessage(SET_LINE_CODING, 0, msg);
    } 
Connect your IDE to all the code out there  Get Codota for Java