Pi4jMultiThread/src/pi4jmultithread/Pi4jMultiThread.java
/**
     * @param args the command line arguments
     */
@param args the command line arguments
@param args the command line arguments
public static void main(String[] args) throws InterruptedException, IOException {
        final byte PIC_ADDR = 0x18; 
        final int FRAME_LEN = 10;   
        final Console console = new Console();
        console.title("<-- Pi4j multithread test -->");
        console.promptForExit();
        try {
            int[] ids = I2CFactory.getBusIds();
            console.println("Found follow I2C busses: " + Arrays.toString(ids));
        } catch (IOException exception) {
            console.println("I/O error during fetch of I2C busses occurred: "+exception.getMessage());
        }
        for (int number = I2CBus.BUS_0; number <= I2CBus.BUS_17; ++number) {
            try {
                @SuppressWarnings("unused")
                I2CBus bus = I2CFactory.getInstance(number);
                console.println("Supported I2C bus " + number + " found");
            } catch (IOException exception) {
                console.println("I/O error on I2C bus " + number + " occurred");
            } catch (I2CFactory.UnsupportedBusNumberException exception) {
                console.println("Unsupported I2C bus " + number + " required");
            }
        }
        I2CBus i2c;
        try {
            i2c = I2CFactory.getInstance(I2CBus.BUS_1);
            I2CDevice device = i2c.getDevice(PIC_ADDR);
        } catch (I2CFactory.UnsupportedBusNumberException ex) {
            Logger.getLogger(Pi4jMultiThread.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
public static void main ( String [ ] args ) throws InterruptedException , IOException { final byte PIC_ADDR = 0x18 ; final int FRAME_LEN = 10 ; final Console console = new Console ( ) ; console . title ( "<-- Pi4j multithread test -->" ) ; console . promptForExit ( ) ; try { int [ ] ids = I2CFactory . getBusIds ( ) ; console . println ( "Found follow I2C busses: " + Arrays . toString ( ids ) ) ; } catch ( IOException exception ) { console . println ( "I/O error during fetch of I2C busses occurred: " + exception . getMessage ( ) ) ; } for ( int number = I2CBus . BUS_0 ; number <= I2CBus . BUS_17 ; ++ number ) { try { @ SuppressWarnings ( "unused" ) I2CBus bus = I2CFactory . getInstance ( number ) ; console . println ( "Supported I2C bus " + number + " found" ) ; } catch ( IOException exception ) { console . println ( "I/O error on I2C bus " + number + " occurred" ) ; } catch ( I2CFactory . UnsupportedBusNumberException exception ) { console . println ( "Unsupported I2C bus " + number + " required" ) ; } } I2CBus i2c ; try { i2c = I2CFactory . getInstance ( I2CBus . BUS_1 ) ; I2CDevice device = i2c . getDevice ( PIC_ADDR ) ; } catch ( I2CFactory . UnsupportedBusNumberException ex ) { Logger . getLogger ( Pi4jMultiThread . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } }
@param args the command line arguments
@param args the command line arguments
// address of the pic // length of a data frame // print program title/header // allow for user to exit program using CTRL-C // fetch all available busses // find available busses // get the I2C bus to communicate on