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/] [examples/] [all/] [ucecho/] [UCEcho.java] - Diff between revs 2 and 3

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

Rev 2 Rev 3
Line 31... Line 31...
    public final static String helpMsg = new String (
    public final static String helpMsg = new String (
                "Parameters:\n"+
                "Parameters:\n"+
                "    -d <number>       Device Number (default: 0)\n" +
                "    -d <number>       Device Number (default: 0)\n" +
                "    -f                Force uploads\n" +
                "    -f                Force uploads\n" +
                "    -p                Print bus info\n" +
                "    -p                Print bus info\n" +
                "    -w                Enable certain workarounds which may be required for vmware + windows\n"+
                "    -w                Enable certain workarounds\n"+
                "    -h                This help" );
                "    -h                This help" );
 
 
    public ParameterException (String msg) {
    public ParameterException (String msg) {
        super( msg + "\n" + helpMsg );
        super( msg + "\n" + helpMsg );
    }
    }
Line 46... Line 46...
// *****************************************************************************
// *****************************************************************************
class UCEcho extends Ztex1v1 {
class UCEcho extends Ztex1v1 {
 
 
// ******* UCEcho **************************************************************
// ******* UCEcho **************************************************************
// constructor
// constructor
    public UCEcho ( ZtexDevice1 pDev ) throws UsbException, ZtexDescriptorException {
    public UCEcho ( ZtexDevice1 pDev ) throws UsbException {
        super ( pDev );
        super ( pDev );
    }
    }
 
 
// ******* claimInterface ******************************************************
// ******* claimInterface ******************************************************
// claims interface 0
// claims interface 0
Line 69... Line 69...
 
 
// ******* echo ****************************************************************
// ******* echo ****************************************************************
// writes a string to Endpoint 4, reads it back from Endpoint 2 and writes the output to System.out
// writes a string to Endpoint 4, reads it back from Endpoint 2 and writes the output to System.out
    public void echo ( String input ) throws UsbException {
    public void echo ( String input ) throws UsbException {
        byte buf[] = input.getBytes();
        byte buf[] = input.getBytes();
        int i = LibusbJava.usb_bulk_write(handle, 0x04, buf, buf.length, 1000);
        int i = LibusbJava.usb_bulk_write(handle(), 0x04, buf, buf.length, 1000);
        if ( i<0 )
        if ( i<0 )
            throw new UsbException("Error sending data: " + LibusbJava.usb_strerror());
            throw new UsbException("Error sending data: " + LibusbJava.usb_strerror());
        System.out.println("Send "+i+" bytes: `"+input+"'" );
        System.out.println("Send "+i+" bytes: `"+input+"'" );
 
 
        try {
        try {
Line 81... Line 81...
        }
        }
            catch ( InterruptedException e ) {
            catch ( InterruptedException e ) {
        }
        }
 
 
        buf = new byte[1024];
        buf = new byte[1024];
        i = LibusbJava.usb_bulk_read(handle, 0x82, buf, 1024, 1000);
        i = LibusbJava.usb_bulk_read(handle(), 0x82, buf, 1024, 1000);
        if ( i<0 )
        if ( i<0 )
            throw new UsbException("Error receiving data: " + LibusbJava.usb_strerror());
            throw new UsbException("Error receiving data: " + LibusbJava.usb_strerror());
        System.out.println("Read "+i+" bytes: `"+new String(buf,0,i)+"'" );
        System.out.println("Read "+i+" bytes: `"+new String(buf,0,i)+"'" );
    }
    }
 
 

powered by: WebSVN 2.1.0

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