def search_and_instantiate_plotters():
    """Dynamically searches and instantiates all found plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type."""

    print("Scanning serial ports...")
    ports = list(scan_serial_ports().values())
    print("Found ports:")
    print("  " + "\n  ".join(ports))

    ## get serial ports that have a plotter connected...
    print("\nSniffing for plotters in all serial ports...")
    plotters_found = sniff_ports_for_plotters(ports)
    if len(plotters_found) == 0:
        print("Found no plotter connected to any of the serial ports.")
        print("Is your plotter on?\n")
        ## return a list so we don't get a python error when trying
        ## to index the result.
        return [None]
    else:
        for serial_address, pln in list(plotters_found.items()):
            print("   Found plotter %s in port %s" % (pln, serial_address))
    ## instantiate a plotter for every port with a plotter...
    result = []
    for serial_address, pln in list(plotters_found.items()):
        plotter = _instantiate_plotter(serial_address, pln)
        result.append(plotter)
    return result
def search_and_instantiate_plotters( ):
    '''Dynamically searches and instantiates all found plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type.'''

    from chiplotle.tools.plottertools import instantiate_plotter_from_id
    from chiplotle.tools.plottertools import interactive_choose_plotter

    print 'Scanning serial ports...'
    ports = scan_serial_ports( ).values( )
    print 'Found ports:'
    print '  ' + '\n  '.join(ports)

    ## get serial ports that have a plotter connected...
    print '\nSniffing for plotters in all serial ports...'
    plotters_found = sniff_ports_for_plotters(ports)
    if len(plotters_found) == 0:
        print 'Found no plotter connected to any of the serial ports.'
        print 'Is your plotter on?\n'
        ## return a list so we don't get a python error when trying
        ## to index the result.
        return [None]
    else:
        for serial_address, pln in plotters_found.items( ):
            print '   Found plotter %s in port %s' % (pln, serial_address)
    ## instantiate a plotter for every port with a plotter...
    result = [ ]
    for serial_address, pln in plotters_found.items( ):
        plotter = _instantiate_plotter(serial_address, pln)
        result.append(plotter)
    return result
def search_and_instantiate_plotters():
    '''Dynamically searches and instantiates all found plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type.'''

    from chiplotle.tools.plottertools import instantiate_plotter_from_id
    from chiplotle.tools.plottertools import interactive_choose_plotter

    print 'Scanning serial ports...'
    ports = scan_serial_ports().values()
    print 'Found ports:'
    print '  ' + '\n  '.join(ports)

    ## get serial ports that have a plotter connected...
    print '\nSniffing for plotters in all serial ports...'
    plotters_found = sniff_ports_for_plotters(ports)
    if len(plotters_found) == 0:
        print 'Found no plotter connected to any of the serial ports.'
        print 'Is your plotter on?\n'
        ## return a list so we don't get a python error when trying
        ## to index the result.
        return [None]
    else:
        for serial_address, pln in plotters_found.items():
            print '   Found plotter %s in port %s' % (pln, serial_address)
    ## instantiate a plotter for every port with a plotter...
    result = []
    for serial_address, pln in plotters_found.items():
        plotter = _instantiate_plotter(serial_address, pln)
        result.append(plotter)
    return result
Exemple #4
0
def instantiate_plotters():
    """Instantiates all found and available plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type."""

    from chiplotle.tools.plottertools import search_and_instantiate_plotters

    map = get_config_value("serial_port_to_plotter_map")
    ## if user has set fixed port to plotter mapping...
    if map is not None:
        result = []
        for k, v in list(map.items()):
            p = _instantiate_plotter(k, v)
            result.append(p)
    else:
        result = search_and_instantiate_plotters()
    return result
def instantiate_plotters( ):
    '''Instantiates all found and available plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type.'''

    from chiplotle.tools.plottertools import search_and_instantiate_plotters

    map = get_config_value('serial_port_to_plotter_map')
    ## if user has set fixed port to plotter mapping...
    if map is not None:
        result = [ ]
        for k, v in map.items( ):
            p = _instantiate_plotter(k, v)
            result.append(p)
    else:
        result = search_and_instantiate_plotters( )
    return result