OpenCores
URL https://opencores.org/ocsvn/usb_fpga_1_2/usb_fpga_1_2/trunk

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [libusbJava-src/] [ch/] [ntb/] [usb/] [LibusbJava.java] - Diff between revs 4 and 8

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 8
Line 98... Line 98...
         * @param dev
         * @param dev
         *            The device to open.
         *            The device to open.
         * @return a handle used in future communication with the device. 0 if an
         * @return a handle used in future communication with the device. 0 if an
         *         error has occurred.
         *         error has occurred.
         */
         */
        public static native int usb_open(Usb_Device dev);
        public static native long usb_open(Usb_Device dev);
 
 
        /**
        /**
         * <code>usb_close</code> closes a device opened with
         * <code>usb_close</code> closes a device opened with
         * <code>usb_open</code>.
         * <code>usb_open</code>.
         *
         *
         * @param dev_handle
         * @param dev_handle
         *            The handle to the device.
         *            The handle to the device.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_close(int dev_handle);
        public static native int usb_close(long dev_handle);
 
 
        /**
        /**
         * Sets the active configuration of a device
         * Sets the active configuration of a device
         *
         *
         * @param dev_handle
         * @param dev_handle
Line 120... Line 120...
         * @param configuration
         * @param configuration
         *            The value as specified in the descriptor field
         *            The value as specified in the descriptor field
         *            bConfigurationValue.
         *            bConfigurationValue.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_set_configuration(int dev_handle,
        public static native int usb_set_configuration(long dev_handle,
                        int configuration);
                        int configuration);
 
 
        /**
        /**
         * Sets the active alternate setting of the current interface
         * Sets the active alternate setting of the current interface
         *
         *
Line 133... Line 133...
         * @param alternate
         * @param alternate
         *            The value as specified in the descriptor field
         *            The value as specified in the descriptor field
         *            bAlternateSetting.
         *            bAlternateSetting.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_set_altinterface(int dev_handle, int alternate);
        public static native int usb_set_altinterface(long dev_handle, int alternate);
 
 
        /**
        /**
         * Clears any halt status on an endpoint.
         * Clears any halt status on an endpoint.
         *
         *
         * @param dev_handle
         * @param dev_handle
         *            The handle to the device.
         *            The handle to the device.
         * @param ep
         * @param ep
         *            The value specified in the descriptor field bEndpointAddress.
         *            The value specified in the descriptor field bEndpointAddress.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_clear_halt(int dev_handle, int ep);
        public static native int usb_clear_halt(long dev_handle, int ep);
 
 
        /**
        /**
         * Resets a device by sending a RESET down the port it is connected to.<br>
         * Resets a device by sending a RESET down the port it is connected to.<br>
         * <br>
         * <br>
         * <b>Causes re-enumeration:</b> After calling <code>usb_reset</code>,
         * <b>Causes re-enumeration:</b> After calling <code>usb_reset</code>,
Line 158... Line 158...
         *
         *
         * @param dev_handle
         * @param dev_handle
         *            The handle to the device.
         *            The handle to the device.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_reset(int dev_handle);
        public static native int usb_reset(long dev_handle);
 
 
        /**
        /**
         * Claim an interface of a device.<br>
         * Claim an interface of a device.<br>
         * <br>
         * <br>
         * <b>Must be called!:</b> <code>usb_claim_interface</code> must be
         * <b>Must be called!:</b> <code>usb_claim_interface</code> must be
Line 174... Line 174...
         * @param interface_
         * @param interface_
         *            The value as specified in the descriptor field
         *            The value as specified in the descriptor field
         *            bInterfaceNumber.
         *            bInterfaceNumber.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_claim_interface(int dev_handle, int interface_);
        public static native int usb_claim_interface(long dev_handle, int interface_);
 
 
        /**
        /**
         * Releases a previously claimed interface
         * Releases a previously claimed interface
         *
         *
         * @param dev_handle
         * @param dev_handle
Line 186... Line 186...
         * @param interface_
         * @param interface_
         *            The value as specified in the descriptor field
         *            The value as specified in the descriptor field
         *            bInterfaceNumber.
         *            bInterfaceNumber.
         * @return 0 on success or < 0 on error.
         * @return 0 on success or < 0 on error.
         */
         */
        public static native int usb_release_interface(int dev_handle,
        public static native int usb_release_interface(long dev_handle,
                        int interface_);
                        int interface_);
 
 
        // Control Transfers
        // Control Transfers
        /**
        /**
         * Performs a control request to the default control pipe on a device. The
         * Performs a control request to the default control pipe on a device. The
Line 205... Line 205...
         * @param bytes
         * @param bytes
         * @param size
         * @param size
         * @param timeout
         * @param timeout
         * @return the number of bytes written/read or < 0 on error.
         * @return the number of bytes written/read or < 0 on error.
         */
         */
        public static native int usb_control_msg(int dev_handle, int requesttype,
        public static native int usb_control_msg(long dev_handle, int requesttype,
                        int request, int value, int index, byte[] bytes, int size,
                        int request, int value, int index, byte[] bytes, int size,
                        int timeout);
                        int timeout);
 
 
        /**
        /**
         * Retrieves the string descriptor specified by index and langid from a
         * Retrieves the string descriptor specified by index and langid from a
Line 219... Line 219...
         *            The handle to the device.
         *            The handle to the device.
         * @param index
         * @param index
         * @param langid
         * @param langid
         * @return the descriptor String or null
         * @return the descriptor String or null
         */
         */
        public static native String usb_get_string(int dev_handle, int index,
        public static native String usb_get_string(long dev_handle, int index,
                        int langid);
                        int langid);
 
 
        /**
        /**
         * <code>usb_get_string_simple</code> is a wrapper around
         * <code>usb_get_string_simple</code> is a wrapper around
         * <code>usb_get_string</code> that retrieves the string description
         * <code>usb_get_string</code> that retrieves the string description
Line 232... Line 232...
         * @param dev_handle
         * @param dev_handle
         *            The handle to the device.
         *            The handle to the device.
         * @param index
         * @param index
         * @return the descriptor String or null
         * @return the descriptor String or null
         */
         */
        public static native String usb_get_string_simple(int dev_handle, int index);
        public static native String usb_get_string_simple(long dev_handle, int index);
 
 
        /**
        /**
         * Retrieves a descriptor from the device identified by the type and index
         * Retrieves a descriptor from the device identified by the type and index
         * of the descriptor from the default control pipe.<br>
         * of the descriptor from the default control pipe.<br>
         * <br>
         * <br>
         * See {@link #usb_get_descriptor_by_endpoint(int, int, byte, byte, int)}
         * See {@link #usb_get_descriptor_by_endpoint(long, int, byte, byte, int)}
         * for a function that allows the control endpoint to be specified.
         * for a function that allows the control endpoint to be specified.
         *
         *
         * @param dev_handle
         * @param dev_handle
         *            The handle to the device.
         *            The handle to the device.
         * @param type
         * @param type
Line 250... Line 250...
         * @param size
         * @param size
         *            number of charactes which will be retrieved (the length of the
         *            number of charactes which will be retrieved (the length of the
         *            resulting String)
         *            resulting String)
         * @return the descriptor String or null
         * @return the descriptor String or null
         */
         */
        public static native String usb_get_descriptor(int dev_handle, byte type,
        public static native String usb_get_descriptor(long dev_handle, byte type,
                        byte index, int size);
                        byte index, int size);
 
 
        /**
        /**
         * Retrieves a descriptor from the device identified by the type and index
         * Retrieves a descriptor from the device identified by the type and index
         * of the descriptor from the control pipe identified by ep.
         * of the descriptor from the control pipe identified by ep.
Line 267... Line 267...
         * @param size
         * @param size
         *            number of charactes which will be retrieved (the length of the
         *            number of charactes which will be retrieved (the length of the
         *            resulting String)
         *            resulting String)
         * @return the descriptor String or null
         * @return the descriptor String or null
         */
         */
        public static native String usb_get_descriptor_by_endpoint(int dev_handle,
        public static native String usb_get_descriptor_by_endpoint(long dev_handle,
                        int ep, byte type, byte index, int size);
                        int ep, byte type, byte index, int size);
 
 
        // Bulk Transfers
        // Bulk Transfers
        /**
        /**
         * Performs a bulk write request to the endpoint specified by ep.
         * Performs a bulk write request to the endpoint specified by ep.
Line 282... Line 282...
         * @param bytes
         * @param bytes
         * @param size
         * @param size
         * @param timeout
         * @param timeout
         * @return the number of bytes written on success or < 0 on error.
         * @return the number of bytes written on success or < 0 on error.
         */
         */
        public static native int usb_bulk_write(int dev_handle, int ep,
        public static native int usb_bulk_write(long dev_handle, int ep,
                        byte[] bytes, int size, int timeout);
                        byte[] bytes, int size, int timeout);
 
 
        /**
        /**
         * Performs a bulk read request to the endpoint specified by ep.
         * Performs a bulk read request to the endpoint specified by ep.
         *
         *
Line 296... Line 296...
         * @param bytes
         * @param bytes
         * @param size
         * @param size
         * @param timeout
         * @param timeout
         * @return the number of bytes read on success or < 0 on error.
         * @return the number of bytes read on success or < 0 on error.
         */
         */
        public static native int usb_bulk_read(int dev_handle, int ep,
        public static native int usb_bulk_read(long dev_handle, int ep,
                        byte[] bytes, int size, int timeout);
                        byte[] bytes, int size, int timeout);
 
 
        // Interrupt Transfers
        // Interrupt Transfers
        /**
        /**
         * Performs an interrupt write request to the endpoint specified by ep.
         * Performs an interrupt write request to the endpoint specified by ep.
Line 311... Line 311...
         * @param bytes
         * @param bytes
         * @param size
         * @param size
         * @param timeout
         * @param timeout
         * @return the number of bytes written on success or < 0 on error.
         * @return the number of bytes written on success or < 0 on error.
         */
         */
        public static native int usb_interrupt_write(int dev_handle, int ep,
        public static native int usb_interrupt_write(long dev_handle, int ep,
                        byte[] bytes, int size, int timeout);
                        byte[] bytes, int size, int timeout);
 
 
        /**
        /**
         * Performs a interrupt read request to the endpoint specified by ep.
         * Performs a interrupt read request to the endpoint specified by ep.
         *
         *
Line 325... Line 325...
         * @param bytes
         * @param bytes
         * @param size
         * @param size
         * @param timeout
         * @param timeout
         * @return the number of bytes read on success or < 0 on error.
         * @return the number of bytes read on success or < 0 on error.
         */
         */
        public static native int usb_interrupt_read(int dev_handle, int ep,
        public static native int usb_interrupt_read(long dev_handle, int ep,
                        byte[] bytes, int size, int timeout);
                        byte[] bytes, int size, int timeout);
 
 
        /**
        /**
         * Returns the error string after an error occured.
         * Returns the error string after an error occured.
         *
         *
Line 357... Line 357...
         * @return the system error code or 100000 if no mapping has been found.
         * @return the system error code or 100000 if no mapping has been found.
         */
         */
        private static native int usb_error_no(int value);
        private static native int usb_error_no(int value);
 
 
        static {
        static {
 
//              System.out.println("os.name: " + System.getProperty("os.name"));
 
//              System.out.println("os.arch: " + System.getProperty("os.arch"));
                String os = System.getProperty("os.name");
                String os = System.getProperty("os.name");
                if (os.contains("Windows")) {
                if (os.contains("Windows")) {
                    LibLoader.load( "libusbJava" );
                    if ( System.getProperty("os.arch").equalsIgnoreCase("amd64") ) {
                } else {
                        LibLoader.load( "libusbJava64" );
 
                    }
 
                    else {
 
                        LibLoader.load( "libusbJava32" );
 
                    }
 
                }
 
                else if ( System.getProperty("os.arch").equalsIgnoreCase("amd64") ) {
 
                        LibLoader.load( "usbJava64" );
 
//                      System.err.println("loaded libusbJava64");
 
                }
 
                else {
                    try {
                    try {
                        LibLoader.load( "usbJavaSh" );
                        LibLoader.load( "usbJavaSh" );
//                      System.err.println("loaded libusbJavaSh");
//                      System.err.println("loaded libusbJavaSh");
                    }
                    }
                    catch ( UnsatisfiedLinkError e ) {
                    catch ( UnsatisfiedLinkError e ) {

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.