public byte [] readControl (byte type, byte request,
                                short value, short index, short length)
    throws IOException
    {
        byte  data [] = new byte [length & 0xffff];
        long   status;

        if (length >= MAX_CONTROL_LENGTH
            || (type & ControlMessage.DIR_TO_HOST) == 0)
            throw new IllegalArgumentException ();
        if (fd < 0) {
            throw new USBException("Dev.readControl aborted",-USBException.IO_NotOpen);
        }
        if (MacOSX.trace)
            System.out.println (path
                                + ": Dev.readControl, rqt 0x" + Integer.toHexString (0xff & type)
                               + ", req 0x" + Integer.toHexString (0xff & request)
                               + ", value 0x" + Integer.toHexString (0xffff & value)
                               + ", index 0x" + Integer.toHexString (0xffff & index)
                               + ", len " + Integer.toString (0xffff & length)
                               );

        status = controlMsg (fd, type, request, value, index,
                             data, 0, (short) data.length);
        if (status >= 0) {
			int length_when_done = (int) status;
            if (length_when_done != data.length) {
                byte temp [] = new byte [length_when_done];
                System.arraycopy (data, 0, temp, 0, length_when_done);
                data = temp;
            }
            return data;
        } else throw new USBException ("control read error", (int)(-status));
    }