private static byte calculateChecksum ( byte [ ] buffer ) { byte checkSum = ( byte ) 0xFF ; for ( int i = 1 ; i < buffer . length - 1 ; i ++ ) { checkSum = ( byte ) ( checkSum ^ buffer [ i ] ) ; } logger . trace ( String . format ( "Calculated checksum = 0x%02X" , checkSum ) ) ; return checkSum ; }
Calculates a checksum for the specified buffer .