static byte[] adaptArray(byte[] ftdiData)
    {
        int length = ftdiData.length;
        if(length > 64)
        {
            int n = 1;
            int p = 64;
            // Precalculate length without FTDI headers
            while(p < length)
            {
                n++;
                p = n*64;
            }
            int realLength = length - n*2;
            byte[] data = new byte[realLength];
            copyData(ftdiData, data);
            return data;
        }
        else if (length == 2) // special case optimization that returns the same instance.
        {
            return EMPTY_BYTE_ARRAY;
        }
        else
        {
            return Arrays.copyOfRange(ftdiData, 2, length);
        }
    }
@Test
    public void adaptEmptyByteArray() {
        byte[] onlyHeaders = {1, 2};
        byte[] adapted = FTDISerialDevice.adaptArray(onlyHeaders);
        Assert.assertEquals("Should be empty", 0, adapted.length);
        byte[] adaptAgain = FTDISerialDevice.adaptArray(onlyHeaders);
        Assert.assertSame("Should be the same instance of empty array", adapted, adaptAgain);
    }