コード例 #1
0
def flash_connectivity(comport, jlink_snr):
    flasher = Flasher(serial_port=comport, snr=jlink_snr)
    if flasher.fw_check():
        print("Board already flashed with connectivity firmware.")
    else:
        print("Flashing connectivity firmware...")
        flasher.fw_flash()
        print("Connectivity firmware flashed.")
    flasher.reset()
    time.sleep(1)
コード例 #2
0
def ble(package, conn_ic_id, port, connect_delay, name, address, jlink_snr,
        flash_connectivity):
    """
    Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU.
    This requires a second nRF device, connected to this computer, with connectivity firmware
    loaded. The connectivity device will perform the DFU procedure onto the target device.
    """
    ble_driver_init(conn_ic_id)
    if name is None and address is None:
        name = 'DfuTarg'
        click.echo(
            "No target selected. Default device name: {} is used.".format(
                name))

    if port is None and jlink_snr is not None:
        port = get_port_by_snr(jlink_snr)

    elif port is None:
        port = enumerate_ports()
        if port is None:
            click.echo(
                "\nNo Segger USB CDC ports found, please connect your board.")
            return

    if flash_connectivity:
        flasher = Flasher(serial_port=port, snr=jlink_snr)
        if flasher.fw_check():
            click.echo("Board already flashed with connectivity firmware.")
        else:
            click.echo("Flashing connectivity firmware...")
            flasher.fw_flash()
            click.echo("Connectivity firmware flashed.")
        flasher.reset()
        time.sleep(1)

    logger.info("Using connectivity board at serial port: {}".format(port))
    ble_backend = DfuTransportBle(serial_port=str(port),
                                  target_device_name=str(name),
                                  target_device_addr=str(address))
    ble_backend.register_events_callback(DfuEvent.PROGRESS_EVENT,
                                         update_progress)
    dfu = Dfu(zip_file_path=package,
              dfu_transport=ble_backend,
              connect_delay=connect_delay)

    if logger.getEffectiveLevel() > logging.INFO:
        with click.progressbar(length=dfu.dfu_get_total_size()) as bar:
            global global_bar
            global_bar = bar
            dfu.dfu_send_images()
    else:
        dfu.dfu_send_images()

    click.echo("Device programmed.")
コード例 #3
0
ファイル: __main__.py プロジェクト: hakonfam/pc-nrfutil
def ble(package, conn_ic_id, port, name, address, jlink_snr, flash_connectivity):
    ble_driver_init(conn_ic_id)
    """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU."""
    if name is None and address is None:
        name = 'DfuTarg'
        click.echo("No target selected. Default device name: {} is used.".format(name))

    if port is None and jlink_snr is not None:
        click.echo("Please specify also serial port.")
        return

    elif port is None:
        port = enumerate_ports()
        if port is None:
            click.echo("\nNo Segger USB CDC ports found, please connect your board.")
            return

    if flash_connectivity:
        flasher = Flasher(serial_port=port, snr = jlink_snr) 
        if flasher.fw_check():
            click.echo("Board already flashed with connectivity firmware.")
        else:
            click.echo("Flashing connectivity firmware...")
            flasher.fw_flash()
            click.echo("Connectivity firmware flashed.")
        flasher.reset()
        time.sleep(1)

    logger.info("Using connectivity board at serial port: {}".format(port))
    ble_backend = DfuTransportBle(serial_port=str(port),
                                  target_device_name=str(name),
                                  target_device_addr=str(address))
    ble_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress)
    dfu = Dfu(zip_file_path = package, dfu_transport = ble_backend)

    if logger.getEffectiveLevel() > logging.INFO: 
        with click.progressbar(length=dfu.dfu_get_total_size()) as bar:
            global global_bar
            global_bar = bar
            dfu.dfu_send_images()
    else:
        dfu.dfu_send_images()

    click.echo("Device programmed.")
コード例 #4
0
    def test_programming(self):
        settings = Settings.current()

        serial_ports = BLEDriver.enum_serial_ports()

        # Check that from enumeration matches
        # kits provided from settings
        found_ports = list(map(lambda port: port.port, serial_ports))

        for serial_port in settings.serial_ports:
            self.assertIn(serial_port, found_ports)

        for serial_port in serial_ports:
            if serial_port.port in settings.serial_ports:
                serial_number = serial_port.serial_number
                logger.info("%s/%s deleting existing firmware",
                            serial_port.port, serial_number)

                flasher = Flasher(serial_port=serial_port.port)
                flasher.erase()

                self.assertFalse(
                    flasher.fw_check(),
                    "#{} must be programmed because it is erased".format(
                        serial_number),
                )

                flasher.fw_flash()
                logger.info("%s/%s programmed", serial_port.port,
                            serial_number)

                self.assertTrue(
                    flasher.fw_check(),
                    "#{} is programmed, shall not be programmed again".format(
                        serial_number),
                )

                # Try to use the device with leading zeroes in serial number removed
                flasher = Flasher(snr=serial_port.serial_number.lstrip('0'))
                flasher.reset()

                logger.info("%s/%s programmed successfully", serial_port.port,
                            serial_number)
コード例 #5
0
ファイル: __main__.py プロジェクト: Jeoy5460/pc-nrfutil
def ble(package, port, name, address, jlink_snr, flash_connectivity):
    """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU."""
    if name is None and address is None:
        name = 'DfuTarg'
        click.echo("No target selected. Default device name: {} is used.".format(name))

    if port is None and jlink_snr is not None:
        click.echo("Please specify also serial port.")
        return

    elif port is None:
        port = enumerate_ports()

    if flash_connectivity:
        flasher = Flasher(serial_port=port, snr = jlink_snr) 
        if flasher.fw_check():
            click.echo("Connectivity already flashed with firmware.")
        else:
            click.echo("Flashing connectivity ")
            flasher.fw_flash()
            click.echo("Connectivity flashed")
        flasher.reset()
        time.sleep(1)

    ble_backend = DfuTransportBle(serial_port=str(port),
                                  target_device_name=str(name),
                                  target_device_addr=str(address))
    ble_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress)
    dfu = Dfu(zip_file_path = package, dfu_transport = ble_backend)

    with click.progressbar(length=dfu.dfu_get_total_size()) as bar:
        global global_bar
        global_bar = bar
        dfu.dfu_send_images()

    click.echo("Device programmed.")
コード例 #6
0
args.name = ' '.join(args.name)
comport = args.com[0]
jlink_snr =  args.snr[0]
flash_connectivity = True
logging.basicConfig(format='%(message)s', level=logging.INFO)

if flash_connectivity:
        flasher = Flasher(serial_port=comport, snr = jlink_snr)
        if flasher.fw_check():
            logger.info("Board already flashed with connectivity firmware.")
        else:
            logger.info("Flashing connectivity firmware...")
            flasher.fw_flash()
            logger.info("Connectivity firmware flashed.")
        flasher.reset()
        time.sleep(1)


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created'



#Bind socket to local host and port
try:
    s.bind((HOST, PORT))
except socket.error as msg:
    print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
    sys.exit()