public int getChannel(int channel) throws Exception, IllegalArgumentException {
        int value = 0;
        checkChannel(channel);
        //write
        int wdata[] = {devAdr.getWriteAddress(), controlByte | channel};
        writeI2C(wdata);
        //read
        int rdata[] = {devAdr.getReadAddress()};
        if (channel == lastChannel) {
            int temp[] = readI2C(rdata, 1);
            value = temp[0];
        } else {
            int temp[] = readI2C(rdata, 2);
            value = temp[1];
        }
        lastChannel = channel;

        //mark not used channels invalid
        if ((((controlByte & INPUT_MODE_1) == INPUT_MODE_1)
                || ((controlByte & INPUT_MODE_2) == INPUT_MODE_2))
                && channel == 3) {

            value = -1;
            lastChannel = -1;
        } else if (((controlByte & INPUT_MODE_3) == INPUT_MODE_3)
                && (channel == 2 || channel == 3)) {

            value = -1;
            lastChannel = -1;
        }
        return value;
    }