Exemple #1
0
def main(argv):

    epilog = (util.drive_desc + "\n" + util.speed_desc + "\n" +
              util.tspec_desc)
    parser = util.ArgumentParser(usage='%(prog)s [options]', epilog=epilog)
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read")
    parser.add_argument("--tracks",
                        type=util.TrackSet,
                        metavar="TSPEC",
                        help="which tracks to erase")
    parser.add_argument("--hfreq",
                        action="store_true",
                        help="erase by writing a high-frequency signal")
    parser.add_argument("--fake-index",
                        type=util.period,
                        metavar="SPEED",
                        help="fake index pulses at SPEED")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        tracks = util.TrackSet('c=0-81:h=0-1')
        if args.tracks is not None:
            tracks.update_from_trackspec(args.tracks.trackspec)
        args.tracks = tracks
        print("Erasing %s" % (args.tracks))
        util.with_drive_selected(erase, usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #2
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to write (A,B,0,1,2)")
    parser.add_argument("--cyls",
                        type=int,
                        default=80,
                        help="number of drive cylinders")
    parser.add_argument("--passes",
                        type=int,
                        default=3,
                        help="number of passes across the cleaning disk")
    parser.add_argument("--linger",
                        type=int,
                        default=100,
                        help="linger time per step, milliseconds")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(clean, usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #3
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] file')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to write (A,B,0,1,2)")
    parser.add_argument("--scyl", type=int, default=0,
                        help="first cylinder to write")
    parser.add_argument("--ecyl", type=int, default=81,
                        help="last cylinder to write")
    parser.add_argument("--single-sided", action="store_true",
                        help="single-sided write")
    parser.add_argument("--double-step", action="store_true",
                        help="double-step drive heads")
    parser.add_argument("--erase-empty", action="store_true",
                        help="erase empty tracks (default: skip)")
    parser.add_argument("--no-verify", action="store_true",
                        help="disable verify")
    parser.add_argument("file", help="input filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])
    args.nr_sides = 1 if args.single_sided else 2

    try:
        usb = util.usb_open(args.device)
        image = open_image(args)
        util.with_drive_selected(write_from_image, usb, args, image)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #4
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to read (A,B,0,1,2)")
    parser.add_argument("--revs", type=int, default=3,
                        help="number of revolutions to read per track")
    parser.add_argument("--scyl", type=int, default=0,
                        help="first cylinder to read")
    parser.add_argument("--ecyl", type=int, default=81,
                        help="last cylinder to read")
    parser.add_argument("--single-sided", action="store_true",
                        help="single-sided read")
    parser.add_argument("--double-step", action="store_true",
                        help="double-step drive heads")
    parser.add_argument("file", help="output filename")
    parser.add_argument("device", nargs="?", default="auto",
                        help="serial device")
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])
    args.nr_sides = 1 if args.single_sided else 2

    try:
        usb = util.usb_open(args.device)
        image = open_image(args)
        util.with_drive_selected(read_to_image, usb, args, image)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #5
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] file')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to write (A,B,0,1,2)")
    parser.add_argument("--tracks", type=util.TrackSet,
                        help="which tracks to write")
    parser.add_argument("--erase-empty", action="store_true",
                        help="erase empty tracks (default: skip)")
    parser.add_argument("--no-verify", action="store_true",
                        help="disable verify")
    parser.add_argument("file", help="input filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        image = open_image(args)
        tracks = util.TrackSet('c=0-81:h=0-1')
        if args.tracks is not None:
            tracks.update_from_trackspec(args.tracks.trackspec)
        args.tracks = tracks
        print("Writing %s" % (args.tracks))
        util.with_drive_selected(write_from_image, usb, args, image)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #6
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to write (A,B,0,1,2)")
    parser.add_argument("--scyl",
                        type=int,
                        default=0,
                        help="first cylinder to write")
    parser.add_argument("--ecyl",
                        type=int,
                        default=81,
                        help="last cylinder to write")
    parser.add_argument("--single-sided",
                        action="store_true",
                        help="single-sided write")
    parser.add_argument("device",
                        nargs="?",
                        default="auto",
                        help="serial device")
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])
    args.nr_sides = 1 if args.single_sided else 2

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(erase, usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #7
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to write (A,B,0,1,2)")
    parser.add_argument("--tracks",
                        type=util.TrackSet,
                        help="which tracks to erase")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        tracks = util.TrackSet('c=0-81:h=0-1')
        if args.tracks is not None:
            tracks.update_from_trackspec(args.tracks.trackspec)
        args.tracks = tracks
        print("Erasing %s" % (args.tracks))
        util.with_drive_selected(erase, usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #8
0
def main(argv):

    epilog = (util.drive_desc)
    parser = util.ArgumentParser(usage='%(prog)s [options] cylinder',
                                 epilog=epilog)
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read")
    parser.add_argument("--force",
                        action="store_true",
                        help="allow extreme cylinders with no prompt")
    parser.add_argument("--motor-on",
                        action="store_true",
                        help="seek with drive motor activated")
    parser.add_argument("cylinder", type=int, help="cylinder to seek")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        struct.pack('b', args.cylinder)
    except struct.error:
        raise error.Fatal("Cylinder %d out of range" % args.cylinder)
    if not 0 <= args.cylinder <= 83 and not args.force:
        answer = input("Seek to extreme cylinder %d, Yes/No? " % args.cylinder)
        if answer != "Yes":
            return

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(seek, usb, args, motor=args.motor_on)
    except USB.CmdError as err:
        print("Command Failed: %s" % err)
Exemple #9
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] file')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read (A,B,0,1,2)")
    parser.add_argument("--format", help="disk format")
    parser.add_argument("--revs",
                        type=int,
                        help="number of revolutions to read per track")
    parser.add_argument("--tracks",
                        type=util.TrackSet,
                        help="which tracks to read")
    parser.add_argument("--rate", type=int, help="data rate (kbit/s)")
    parser.add_argument("--rpm", type=int, help="convert drive speed to RPM")
    parser.add_argument("--retries",
                        type=int,
                        default=3,
                        help="number of retries on decode failure")
    parser.add_argument("file", help="output filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    args.file, args.file_opts = util.split_opts(args.file)

    try:
        usb = util.usb_open(args.device)
        image_class = util.get_image_class(args.file)
        if not args.format and hasattr(image_class, 'default_format'):
            args.format = image_class.default_format
        decoder, def_tracks = None, None
        if args.format:
            try:
                mod = importlib.import_module('greaseweazle.codec.' +
                                              args.format)
                decoder = mod.decode_track
            except (ModuleNotFoundError, AttributeError) as ex:
                raise error.Fatal("Unknown format '%s'" % args.format) from ex
            def_tracks = util.TrackSet(mod.default_trackset)
            if args.revs is None: args.revs = mod.default_revs
        if def_tracks is None:
            def_tracks = util.TrackSet('c=0-81:h=0-1')
        if args.revs is None: args.revs = 3
        if args.tracks is not None:
            def_tracks.update_from_trackspec(args.tracks.trackspec)
        args.tracks = def_tracks

        print(("Reading %s revs=" % args.tracks) + str(args.revs))
        with open_image(args, image_class) as image:
            util.with_drive_selected(read_to_image,
                                     usb,
                                     args,
                                     image,
                                     decoder=decoder)
    except USB.CmdError as err:
        print("Command Failed: %s" % err)
Exemple #10
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] file')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read (A,B,0,1,2)")
    parser.add_argument("--format", help="disk format")
    parser.add_argument("--revs",
                        type=int,
                        help="number of revolutions to read per track")
    parser.add_argument("--scyl", type=int, help="first cylinder to read")
    parser.add_argument("--ecyl", type=int, help="last cylinder to read")
    parser.add_argument("--single-sided",
                        action="store_true",
                        help="single-sided read")
    parser.add_argument("--double-step",
                        action="store_true",
                        help="double-step drive heads")
    parser.add_argument("--rate", type=int, help="data rate (kbit/s)")
    parser.add_argument("--rpm", type=int, help="convert drive speed to RPM")
    parser.add_argument("file", help="output filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])
    args.nr_sides = 1 if args.single_sided else 2

    args.file, args.file_opts = util.split_opts(args.file)

    try:
        usb = util.usb_open(args.device)
        image_class = util.get_image_class(args.file)
        if not args.format and hasattr(image_class, 'default_format'):
            args.format = image_class.default_format
        decoder = None
        if args.format:
            try:
                mod = importlib.import_module('greaseweazle.codec.' +
                                              args.format)
                decoder = mod.decode_track
            except (ModuleNotFoundError, AttributeError) as ex:
                raise error.Fatal("Unknown format '%s'" % args.format) from ex
            if args.scyl is None: args.scyl = mod.default_cyls[0]
            if args.ecyl is None: args.ecyl = mod.default_cyls[1]
            if args.revs is None: args.revs = mod.default_revs
        if args.scyl is None: args.scyl = 0
        if args.ecyl is None: args.ecyl = 81
        if args.revs is None: args.revs = 3
        print("Reading c=%s s=%s revs=%d" % (range_str(
            args.scyl, args.ecyl), range_str(0, args.nr_sides - 1), args.revs))
        image = open_image(args, image_class)
        util.with_drive_selected(read_to_image,
                                 usb,
                                 args,
                                 image,
                                 decoder=decoder)
    except USB.CmdError as err:
        print("Command Failed: %s" % err)
Exemple #11
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--bootloader",
                        action="store_true",
                        help="display bootloader info (F7 only)")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    print_info_line('Host Tools', 'v%d.%d' % (version.major, version.minor))

    print('Greaseweazle:')

    try:
        usb = util.usb_open(args.device, mode_check=False)
    except serial.SerialException:
        print('  Not found')
        sys.exit(0)

    mode_switched = (usb.jumperless_update
                     and usb.update_mode != args.bootloader
                     and not (usb.update_mode and usb.update_jumpered))
    if mode_switched:
        usb = util.usb_reopen(usb, args.bootloader)

    port = usb.port_info

    if port.device:
        print_info_line('Device', port.device, tab=2)

    try:
        model = model_id[usb.hw_model][usb.hw_submodel]
    except KeyError:
        model = 'Unknown (0x%02X%02X)' % (usb.hw_model, usb.hw_submodel)
    print_info_line('Model', model, tab=2)

    fwver = 'v%d.%d' % (usb.major, usb.minor)
    if usb.update_mode:
        fwver += ' (Update Bootloader)'
    print_info_line('Firmware', fwver, tab=2)

    print_info_line('Serial',
                    port.serial_number if port.serial_number else 'Unknown',
                    tab=2)

    try:
        speed = speed_id[usb.usb_speed]
    except KeyError:
        speed = 'Unknown (0x%02X)' % usb.usb_speed
    print_info_line('USB Rate', speed, tab=2)

    if mode_switched:
        usb = util.usb_reopen(usb, not args.bootloader)
Exemple #12
0
def main(argv):

    parser = util.ArgumentParser(allow_abbrev=False,
                                 usage='%(prog)s [options] [file]')
    parser.add_argument("file", nargs="?", help="update filename")
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--force",
                        action="store_true",
                        help="force update even if firmware is older")
    parser.add_argument("--bootloader",
                        action="store_true",
                        help="update the bootloader (use with caution!)")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    if args.file is None:
        args.file, dat = download_latest()
    else:
        with open(args.file, "rb") as f:
            dat = f.read()

    try:
        usb = util.usb_open(args.device, mode_check=False)
        dat_version, dat = extract_update(usb, dat, args)
        print("Updating %s to v%u.%u..." %
              ("Bootloader" if args.bootloader else "Main Firmware",
               *dat_version))
        if not args.force and (usb.can_mode_switch
                               or args.bootloader == usb.update_mode):
            if args.bootloader != usb.update_mode:
                usb = util.usb_reopen(usb, is_update=args.bootloader)
                error.check(args.bootloader == usb.update_mode,
                            'Device did not mode switch as requested')
            if usb.version >= dat_version:
                if usb.update_mode and usb.can_mode_switch:
                    usb = util.usb_reopen(usb, is_update=False)
                raise error.Fatal('Device is running v%d.%d (>= v%d.%d). '
                                  'Use --force to update anyway.' %
                                  (usb.version + dat_version))
        usb = util.usb_mode_check(usb, is_update=not args.bootloader)
        update_firmware(usb, dat, args)
        if usb.update_mode and usb.can_mode_switch:
            util.usb_reopen(usb, is_update=False)
    except USB.CmdError as err:
        if err.code == USB.Ack.OutOfSRAM and args.bootloader:
            # Special warning for Low-Density F1 devices. The new bootloader
            # cannot be fully buffered in the limited RAM available.
            print("ERROR: Bootloader update unsupported on this device "
                  "(insufficient SRAM)")
        elif err.code == USB.Ack.OutOfFlash and not args.bootloader:
            print("ERROR: New firmware is too large for this device "
                  "(insufficient Flash memory)")
        else:
            print("Command Failed: %s" % err)
Exemple #13
0
def main(argv):

    epilog = "FORMAT options:\n" + formats.print_formats()
    parser = util.ArgumentParser(usage='%(prog)s [options] file',
                                 epilog=epilog)
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to write (A,B,0,1,2)")
    parser.add_argument("--format", help="disk format")
    parser.add_argument("--tracks", type=util.TrackSet,
                        help="which tracks to write")
    parser.add_argument("--erase-empty", action="store_true",
                        help="erase empty tracks (default: skip)")
    parser.add_argument("--no-verify", action="store_true",
                        help="disable verify")
    parser.add_argument("--retries", type=int, default=3,
                        help="number of retries on verify failure")
    parser.add_argument("--precomp", type=PrecompSpec,
                        help="write precompensation")
    parser.add_argument("file", help="input filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        image_class = util.get_image_class(args.file)
        if not args.format and hasattr(image_class, 'default_format'):
            args.format = image_class.default_format
        def_tracks, args.fmt_cls = None, None
        if args.format:
            try:
                args.fmt_cls = formats.formats[args.format]()
            except KeyError as ex:
                raise error.Fatal("""\
Unknown format '%s'
Known formats:\n%s"""
                                  % (args.format, formats.print_formats()))
            def_tracks = args.fmt_cls.default_tracks
        if def_tracks is None:
            def_tracks = util.TrackSet('c=0-81:h=0-1')
        if args.tracks is not None:
            def_tracks.update_from_trackspec(args.tracks.trackspec)
        args.tracks = def_tracks
        usb = util.usb_open(args.device)
        image = open_image(args, image_class)
        print("Writing " + str(args.tracks))
        if args.precomp is not None:
            print(args.precomp)
        if args.format:
            print("Format " + args.format)
        util.with_drive_selected(write_from_image, usb, args, image)
    except USB.CmdError as err:
        print("Command Failed: %s" % err)
Exemple #14
0
def main(argv):

    epilog = "FORMAT options:\n" + formats.print_formats()
    parser = util.ArgumentParser(usage='%(prog)s [options] in_file out_file',
                                 epilog=epilog)
    parser.add_argument("--format", help="disk format")
    parser.add_argument("--tracks",
                        type=util.TrackSet,
                        help="which tracks to convert")
    parser.add_argument("--rpm", type=int, help="convert drive speed to RPM")
    parser.add_argument("-n",
                        "--no-clobber",
                        action="store_true",
                        help="do not overwrite an existing file")
    parser.add_argument("in_file", help="input filename")
    parser.add_argument("out_file", help="output filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    args.out_file, args.out_file_opts = util.split_opts(args.out_file)

    in_image_class = util.get_image_class(args.in_file)
    if not args.format and hasattr(in_image_class, 'default_format'):
        args.format = in_image_class.default_format

    out_image_class = util.get_image_class(args.out_file)
    if not args.format and hasattr(out_image_class, 'default_format'):
        args.format = out_image_class.default_format

    decoder, def_tracks, args.fmt_cls = None, None, None
    if args.format:
        try:
            args.fmt_cls = formats.formats[args.format]()
        except KeyError as ex:
            raise error.Fatal("""\
Unknown format '%s'
Known formats:\n%s""" % (args.format, formats.print_formats()))
        decoder = args.fmt_cls.decode_track
        def_tracks = args.fmt_cls.default_tracks
    if def_tracks is None:
        def_tracks = util.TrackSet('c=0-81:h=0-1')
    if args.tracks is not None:
        def_tracks.update_from_trackspec(args.tracks.trackspec)
    args.tracks = def_tracks

    print("Converting %s" % args.tracks)
    if args.format:
        print("Format " + args.format)

    in_image = open_input_image(args, in_image_class)
    with open_output_image(args, out_image_class) as out_image:
        convert(args, in_image, out_image, decoder=decoder)
Exemple #15
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        measure_bandwidth(usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #16
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        usb.power_on_reset()
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #17
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("device", nargs="?", help="serial device")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        measure_bandwidth(usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #18
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--select",
                        type=int,
                        metavar="N",
                        help="delay after drive select (usecs)")
    parser.add_argument("--step",
                        type=int,
                        metavar="N",
                        help="delay between head steps (usecs)")
    parser.add_argument("--settle",
                        type=int,
                        metavar="N",
                        help="settle delay after seek (msecs)")
    parser.add_argument("--motor",
                        type=int,
                        metavar="N",
                        help="delay after motor on (msecs)")
    parser.add_argument("--watchdog",
                        type=int,
                        metavar="N",
                        help="quiescent time until drives reset (msecs)")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:

        usb = util.usb_open(args.device)

        if args.select:
            usb.select_delay = args.select
        if args.step:
            usb.step_delay = args.step
        if args.settle:
            usb.seek_settle_delay = args.settle
        if args.motor:
            usb.motor_delay = args.motor
        if args.watchdog:
            usb.watchdog_delay = args.watchdog

        print("Select Delay: %uus" % usb.select_delay)
        print("Step Delay: %uus" % usb.step_delay)
        print("Settle Time: %ums" % usb.seek_settle_delay)
        print("Motor Delay: %ums" % usb.motor_delay)
        print("Watchdog: %ums" % usb.watchdog_delay)

    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #19
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("device",
                        nargs="?",
                        default="auto",
                        help="serial device")
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        usb.power_on_reset()
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #20
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("--select",
                        type=int,
                        help="delay after drive select (usecs)")
    parser.add_argument("--step",
                        type=int,
                        help="delay between head steps (usecs)")
    parser.add_argument("--settle",
                        type=int,
                        help="settle delay after seek (msecs)")
    parser.add_argument("--motor",
                        type=int,
                        help="delay after motor on (msecs)")
    parser.add_argument("--auto-off",
                        type=int,
                        help="quiescent time until auto deselect (msecs)")
    parser.add_argument("device",
                        nargs="?",
                        default="auto",
                        help="serial device")
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:

        usb = util.usb_open(args.device)

        if args.select:
            usb.select_delay = args.select
        if args.step:
            usb.step_delay = args.step
        if args.settle:
            usb.seek_settle_delay = args.settle
        if args.motor:
            usb.motor_delay = args.motor
        if args.auto_off:
            usb.auto_off_delay = args.auto_off

        print("Select Delay: %uus" % usb.select_delay)
        print("Step Delay: %uus" % usb.step_delay)
        print("Settle Time: %ums" % usb.seek_settle_delay)
        print("Motor Delay: %ums" % usb.motor_delay)
        print("Auto Off: %ums" % usb.auto_off_delay)

    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #21
0
def main(argv):

    parser = util.ArgumentParser(allow_abbrev=False)
    parser.add_argument("file", nargs="?", help="update filename")
    parser.add_argument("device", nargs="?", help="serial device")
    parser.add_argument("--bootloader", action="store_true",
                        help="update the bootloader (use with caution!)")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device, is_update=not args.bootloader)
        update_firmware(usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #22
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to read (A,B,0,1,2)")
    parser.add_argument("--nr", type=int, default=1,
                        help="number of iterations")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(print_rpm, usb, args)
    except USB.CmdError as err:
        print("Command Failed: %s" % err)
Exemple #23
0
def pin_set(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] pin level')
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("pin", type=int, help="pin number")
    parser.add_argument("level", type=level, help="pin level (H,L)")
    parser.description = description
    parser.prog += ' pin set'
    args = parser.parse_args(argv[3:])

    try:
        usb = util.usb_open(args.device)
        usb.set_pin(args.pin, args.level)
        print("Pin %u is set %s" %
              (args.pin, ("Low (0v)", "High (5v)")[args.level]))
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #24
0
def pin_get(argv):

    epilog = (util.drive_desc)
    parser = util.ArgumentParser(usage='%(prog)s [options] pin',
                                 epilog=epilog)
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to read")
    parser.add_argument("pin", type=int, help="pin number")
    parser.description = description
    parser.prog += ' pin get'
    args = parser.parse_args(argv[3:])

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(_pin_get, usb, args, motor=False)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #25
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] cylinder')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read (A,B,0,1,2)")
    parser.add_argument("cylinder", type=int, help="cylinder to seek")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(seek, usb, args, motor=False)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #26
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("pin", type=int,
                        help="pin number")
    parser.add_argument("level", type=level,
                        help="pin level (H,L)")
    parser.add_argument("device", nargs="?", help="serial device")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    try:
        usb = util.usb_open(args.device)
        usb.set_pin(args.pin, args.level)
        print("Pin %u is set %s" %
              (args.pin, ("Low (0v)", "High (5v)")[args.level]))
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #27
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options] file')
    parser.add_argument("--device", help="greaseweazle device name")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read (A,B,0,1,2)")
    parser.add_argument("--revs",
                        type=int,
                        default=3,
                        help="number of revolutions to read per track")
    parser.add_argument("--scyl",
                        type=int,
                        default=0,
                        help="first cylinder to read")
    parser.add_argument("--ecyl",
                        type=int,
                        default=81,
                        help="last cylinder to read")
    parser.add_argument("--single-sided",
                        action="store_true",
                        help="single-sided read")
    parser.add_argument("--double-step",
                        action="store_true",
                        help="double-step drive heads")
    parser.add_argument("--rate", type=int, help="data rate (kbit/s)")
    parser.add_argument("--rpm", type=int, help="convert drive speed to RPM")
    parser.add_argument("file", help="output filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])
    args.nr_sides = 1 if args.single_sided else 2

    args.file, args.file_opts = util.split_opts(args.file)

    try:
        usb = util.usb_open(args.device)
        image = open_image(args)
        util.with_drive_selected(read_to_image, usb, args, image)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #28
0
def main(argv):

    parser = util.ArgumentParser()
    parser.add_argument("--drive", type=util.drive_letter, default='A',
                        help="drive to step (A,B,0,1,2)")
    parser.add_argument("--ecyl", type=int, default=81,
                        help="last cylinder in step range")
    parser.add_argument("--repeat", type=int, default=0,
                        help="times to repeat (0 = forever)")
    parser.add_argument("--wait", action='store_true',
                        help="wait for input between step cycles")
    parser.add_argument("device", nargs="?", default="auto",
                        help="serial device")
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])
    args.scyl = 0
    args.repeat = args.repeat if args.repeat else -1

    try:
        usb = util.usb_open(args.device)
        util.with_drive_selected(step, usb, args)
    except USB.CmdError as error:
        print("Command Failed: %s" % error)
Exemple #29
0
def main(argv):

    epilog = (util.drive_desc + "\n" + util.speed_desc + "\n" +
              util.tspec_desc + "\nFORMAT options:\n" +
              formats.print_formats())
    parser = util.ArgumentParser(usage='%(prog)s [options] file',
                                 epilog=epilog)
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--drive",
                        type=util.drive_letter,
                        default='A',
                        help="drive to read")
    parser.add_argument("--format",
                        help="disk format (output is converted unless --raw)")
    parser.add_argument("--revs",
                        type=int,
                        metavar="N",
                        help="number of revolutions to read per track")
    parser.add_argument("--tracks",
                        type=util.TrackSet,
                        metavar="TSPEC",
                        help="which tracks to read")
    parser.add_argument("--raw",
                        action="store_true",
                        help="output raw stream (--format verifies only)")
    parser.add_argument("--fake-index",
                        type=util.period,
                        metavar="SPEED",
                        help="fake index pulses at SPEED")
    parser.add_argument("--adjust-speed",
                        type=util.period,
                        metavar="SPEED",
                        help="scale track data to effective drive SPEED")
    parser.add_argument("--retries",
                        type=int,
                        default=3,
                        metavar="N",
                        help="number of retries per seek-retry")
    parser.add_argument("--seek-retries",
                        type=int,
                        default=3,
                        metavar="N",
                        help="number of seek retries")
    parser.add_argument("-n",
                        "--no-clobber",
                        action="store_true",
                        help="do not overwrite an existing file")
    parser.add_argument("file", help="output filename")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    args.file, args.file_opts = util.split_opts(args.file)

    try:
        usb = util.usb_open(args.device)
        image_class = util.get_image_class(args.file)
        if not args.format and hasattr(image_class, 'default_format'):
            args.format = image_class.default_format
        decoder, def_tracks, args.fmt_cls = None, None, None
        if args.format:
            try:
                args.fmt_cls = formats.formats[args.format]()
            except KeyError as ex:
                raise error.Fatal("""\
Unknown format '%s'
Known formats:\n%s""" % (args.format, formats.print_formats()))
            decoder = args.fmt_cls.decode_track
            def_tracks = args.fmt_cls.default_tracks
            if args.revs is None: args.revs = args.fmt_cls.default_revs
        if def_tracks is None:
            def_tracks = util.TrackSet('c=0-81:h=0-1')
        if args.revs is None: args.revs = 3
        if args.tracks is not None:
            def_tracks.update_from_trackspec(args.tracks.trackspec)
        args.tracks = def_tracks

        print(("Reading %s revs=" % args.tracks) + str(args.revs))
        if args.format:
            print("Format " + args.format)
        with open_image(args, image_class) as image:
            util.with_drive_selected(read_to_image,
                                     usb,
                                     args,
                                     image,
                                     decoder=decoder)
    except USB.CmdError as err:
        print("Command Failed: %s" % err)
Exemple #30
0
def main(argv):

    parser = util.ArgumentParser(usage='%(prog)s [options]')
    parser.add_argument("--device", help="device name (COM/serial port)")
    parser.add_argument("--bootloader", action="store_true",
                        help="display bootloader info (F7 only)")
    parser.description = description
    parser.prog += ' ' + argv[1]
    args = parser.parse_args(argv[2:])

    print_info_line('Host Tools', 'v%d.%d' % (version.major, version.minor))

    print('Device:')

    try:
        usb = util.usb_open(args.device, mode_check=False)
    except serial.SerialException:
        print('  Not found')
        sys.exit(0)

    mode_switched = usb.can_mode_switch and usb.update_mode != args.bootloader
    if mode_switched:
        usb = util.usb_reopen(usb, args.bootloader)
        
    port = usb.port_info

    if port.device:
        print_info_line('Port', port.device, tab=2)

    try:
        model = model_id[usb.hw_model][usb.hw_submodel]
        if usb.hw_model != 8:
            model = 'Greaseweazle ' + model
    except KeyError:
        model = 'Unknown (0x%02X%02X)' % (usb.hw_model, usb.hw_submodel)
    print_info_line('Model', model, tab=2)

    fwver = 'v%d.%d' % (usb.major, usb.minor)
    if usb.update_mode:
        fwver += ' (Update Bootloader)'
    print_info_line('Firmware', fwver, tab=2)

    print_info_line('Serial', port.serial_number if port.serial_number
                    else 'Unknown', tab=2)

    try:
        speed = speed_id[usb.usb_speed]
    except KeyError:
        speed = 'Unknown (0x%02X)' % usb.usb_speed
    print_info_line('USB Rate', speed, tab=2)

    usb_update_mode, usb_version = usb.update_mode, usb.version

    if mode_switched:
        usb = util.usb_reopen(usb, not args.bootloader)

    if not usb_update_mode:
        latest_version = latest_firmware()
        if latest_version > usb_version:
            print('\n*** New firmware v%d.%d is available' % latest_version)
            util.print_update_instructions(usb)