Exemple #1
0
def get_firmware():
    if args.firmware:
        img = download(args.firmware)
    else:
        img = download_newest(DEFAULT_FIRMWARE_GLOB)
    assert 30 < (len(img) / 1024) <= 240, 'Invalid firmware size'
    return img
def get_firmware():
    if args.firmware:
        img = download(args.firmware)
    else:
        img = download_newest(DEFAULT_FIRMWARE_GLOB)
    assert 30 < (len(img) / 1024) <= 240, 'Invalid firmware size'
    return img
    except Exception as ex:
        fatal('Could not parse unique ID: %s', ex)

    info('Requesting signature for unique ID %s', ' '.join(['%02x' % x for x in unique_id]))
    gensign_response = api.generate_signature(unique_id, PRODUCT_NAME)
    firmware_with_signature = firmware_base.ljust(SIGNATURE_OFFSET, b'\xFF') + gensign_response.signature

    image_name = '-'.join(map(str, unique_id_integers)) + '.bin'
    with open(image_name, 'wb') as f:
        f.write(firmware_with_signature)
    os.chmod(image_name, 0o666)
    info('Signed image stored into %r', image_name)


with CLIWaitCursor():
    firmware_base = download(args.firmware)
    assert 0 < len(firmware_base) <= SIGNATURE_OFFSET, 'Firmware size is incorrect'

if args.generate_signed_image_for:
    generate_signed_image_for(args.generate_signed_image_for)
    exit(0)

if not args.iface:
    fatal('Iface is required')
execute_shell_command('ifconfig %s down && ip link set %s up type can bitrate %d sample-point 0.875',
                      args.iface, args.iface, bootloader.CAN_BITRATE, ignore_failure=True)


def load_and_start_firmware(bootloader_interface, firmware_image):
    while True:
        try:
Exemple #4
0
        error('CAN interface is not working')
        ok = False

    if not ok:
        fatal('Required interfaces are not available. Please check your hardware configuration. '
              'If this application is running on a virtual machine, make sure that hardware '
              'sharing is configured correctly.')

check_interfaces()

licensing_api = make_api_context_with_user_provided_credentials()

with CLIWaitCursor():
    print('Please wait...')
    if args.firmware:
        firmware_data = download(args.firmware)
    else:
        firmware_data = download_newest(DEFAULT_FIRMWARE_GLOB)
    assert 30 < (len(firmware_data) / 1024) <= 240, 'Invalid firmware size'


def process_one_device(set_device_info):
    out = input('1. Connect DroneCode Probe to the debug connector.\n'
                '2. Connect CAN to the first CAN1 connector on the device; terminate the other CAN1 connector.\n'
                '4. Connect an appropriate power supply (see the hardware specs for requirements).\n'
                '   Make sure the motor leads are NOT CONNECTED to anything.\n'
                '5. If you want to skip firmware upload, type F.\n'
                '6. Press ENTER.')

    skip_fw_upload = 'f' in out.lower()
    if not skip_fw_upload:
Exemple #5
0
    info('Requesting signature for unique ID %s',
         ' '.join(['%02x' % x for x in unique_id]))
    gensign_response = api.generate_signature(unique_id, PRODUCT_NAME)
    firmware_with_signature = firmware_base.ljust(
        SIGNATURE_OFFSET, b'\xFF') + gensign_response.signature

    image_name = '-'.join(map(str, unique_id_integers)) + '.bin'
    with open(image_name, 'wb') as f:
        f.write(firmware_with_signature)
    os.chmod(image_name, 0o666)
    info('Signed image stored into %r', image_name)


with CLIWaitCursor():
    firmware_base = download(args.firmware)
    assert 0 < len(
        firmware_base) <= SIGNATURE_OFFSET, 'Firmware size is incorrect'

if args.generate_signed_image_for:
    generate_signed_image_for(args.generate_signed_image_for)
    exit(0)

if not args.iface:
    fatal('Iface is required')
execute_shell_command(
    'ifconfig %s down && ip link set %s up type can bitrate %d sample-point 0.875',
    args.iface,
    args.iface,
    bootloader.CAN_BITRATE,
    ignore_failure=True)