(firmware_file, product_name, lua_name, defines, config, layout_file, rx_as_tx)
| 35 | return pos |
| 36 | |
| 37 | def appendToFirmware(firmware_file, product_name, lua_name, defines, config, layout_file, rx_as_tx): |
| 38 | product = (product_name.encode() + (b'\0' * 128))[0:128] |
| 39 | device = (lua_name.encode() + (b'\0' * 16))[0:16] |
| 40 | end = findFirmwareEnd(firmware_file) |
| 41 | firmware_file.seek(end, 0) |
| 42 | firmware_file.write(product) |
| 43 | firmware_file.write(device) |
| 44 | defines = (defines.encode() + (b'\0' * 512))[0:512] |
| 45 | firmware_file.write(defines) |
| 46 | if layout_file is not None: |
| 47 | try: |
| 48 | with open(layout_file) as h: |
| 49 | hardware = json.load(h) |
| 50 | if 'overlay' in config: |
| 51 | hardware.update(config['overlay']) |
| 52 | if rx_as_tx is not None: |
| 53 | if 'serial_rx' not in hardware or 'serial_tx' not in hardware: |
| 54 | sys.stderr.write(f'Cannot select this target as RX-as-TX\n') |
| 55 | exit(1) |
| 56 | if rx_as_tx == TXType.external and hardware['serial_rx']: |
| 57 | hardware['serial_rx'] = hardware['serial_tx'] |
| 58 | if 'led_red' not in hardware and 'led' in hardware: |
| 59 | hardware['led_red'] = hardware['led'] |
| 60 | del hardware['led'] |
| 61 | layout = (json.JSONEncoder().encode(hardware).encode() + (b'\0' * 2048))[0:2048] |
| 62 | firmware_file.write(layout) |
| 63 | except EnvironmentError: |
| 64 | sys.stderr.write(f'Error opening file "{layout_file}"\n') |
| 65 | exit(1) |
| 66 | else: |
| 67 | firmware_file.write(b'\0' * 2048) |
| 68 | if config is not None and 'logo_file' in config: |
| 69 | logo_file = f"hardware/logo/{config['logo_file']}" |
| 70 | with open(logo_file, 'rb') as f: |
| 71 | firmware_file.write(f.read()) |
| 72 | if config is not None and 'prior_target_name' in config: |
| 73 | firmware_file.write(b'\xBE\xEF\xCA\xFE') |
| 74 | firmware_file.write(config['prior_target_name'].upper().encode()) |
| 75 | firmware_file.write(b'\0') |
| 76 | |
| 77 | def doConfiguration(file, defines, config, moduletype, frequency, platform, device_name, rx_as_tx): |
| 78 | product_name = "Unified" |
no test coverage detected