@@ -0,0 +1,2166 @@
+#!/usr/bin/env python%0A#  Copyright (C) 2014  Instituto Nokia de Tecnologia - INdT%0A#%0A#  This program is free software; you can redistribute it and/or modify%0A#  it under the terms of the GNU General Public License as published by%0A#  the Free Software Foundation; either version 2 of the License, or%0A#  (at your option) any later version.%0A#%0A#  This program is distributed in the hope that it will be useful,%0A#  but WITHOUT ANY WARRANTY; without even the implied warranty of%0A#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A#  GNU General Public License for more details.%0A#%0A#  You should have received a copy of the GNU General Public License%0A#  along with this program; if not, write to the Free Software%0A#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA%0Afrom __future__ import print_function%0Aimport re%0Aimport argparse%0Afrom binascii import crc_hqx%0Afrom pprint import pprint%0Aimport struct%0A%0Aif __name__ == %22__main__%22:%0A    parser = argparse.ArgumentParser(description=%22Parse nRF8001 setup data.%22)%0A    parser.add_argument(%22report%22, type=file,%0A            help=%22report generated by nRFgoStudio (ublue_setup.gen.out.txt)%22)%0A    args = parser.parse_args()%0A%0A    setup_data = None%0A    crc = 0xffff%0A    for line in args.report.readlines():%0A        if line.strip() == %22%5BSetup Data%5D%22:%0A            setup_data = %7B%7D%0A        if not line.strip() or setup_data is None:%0A            continue%0A        if not re.match(%22%5E%5B0-9A-F-%5D+$%22, line.strip()):%0A            continue%0A%0A        data = line.strip().split(%22-%22)%0A        assert int(data%5B0%5D, 16) == len(data%5B1:%5D)%0A        # Opcode: Setup (0x06)%0A        assert data%5B1%5D == '06'%0A        target = int(data%5B2%5D, 16)%0A        if not setup_data.get(target):%0A            setup_data%5Btarget%5D = %22%22%0A        setup_data%5Btarget%5D += %22%22.join(data%5B3:%5D)%0A%0A        if target == 0xf0:%0A            # Remove existing CRC when calculating new CRC%0A            data = data%5B:-2%5D%0A        crc = crc_hqx(%22%22.join(data).decode(%22hex%22), crc)%0A%0A    # Check CRC%0A    expected_crc = struct.unpack(%22%3EH%22,%0A            %22%22.join(setup_data%5B0xf0%5D.decode(%22hex%22)%5B-2:%5D))%5B0%5D%0A    assert crc == expected_crc%0A%0A    print(%22Setup Data:%22)%0A    pprint(setup_data)%0A

Add initial script for parsing Setup Data packets