public static int getAPDUService ( final byte [ ] apdu ) { if ( apdu . length < 2 ) throw new KNXIllegalArgumentException ( "getting APDU service from [0x" + toHex ( apdu , "" ) + "], APCI length < 2" ) ; // high 4 bits of APCI final int apci4 = ( apdu [ 0 ] & 0x03 ) << 2 | ( apdu [ 1 ] & 0xC0 ) >> 6 ; // lowest 6 bits of APCI final int apci6 = apdu [ 1 ] & 0x3f ; // group value codes // group read if ( apci4 == 0 ) { if ( apci6 == 0 ) return 0 ; } // group response else if ( apci4 == 1 ) return 0x40 ; // group write else if ( apci4 == 2 ) return 0x80 ; // individual address codes else if ( apci4 == 3 || apci4 == 4 || apci4 == 5 ) { if ( apci6 == 0 ) return apci4 << 6 ; } // ADC read code else if ( apci4 == 6 ) return apci4 << 6 ; else if ( apci4 == 7 ) { // extended memory r/w services use the same 4 MSB as the ADC response code if ( apdu . length > 5 || apci6 > 0x30 ) return apci4 << 6 | apci6 ; // ADC response code return apci4 << 6 ; } // memory codes else if ( apci4 == 8 || apci4 == 9 || apci4 == 10 ) return apci4 << 6 ; // the rest else return apci4 << 6 | apci6 ; // unknown codes final int code = apci4 << 6 | apci6 ; logger . warn ( "unknown APCI service code 0x" + Integer . toHexString ( code ) ) ; return code ; }
Returns the application layer service of a given protocol data unit .