drepetto / chiplotle

Now that's a spicy plotter library
http://chiplotle.org
GNU General Public License v3.0
33 stars 20 forks source link

Parallel port support #8

Closed mo-nonym closed 3 years ago

mo-nonym commented 4 years ago

Chiplotle supports serial port communication but why not parallel port communication ?

My serial connection (with an FTDI chip USB adapter...) didn't work yet.

When connecting the plotter with an USB - parallel port adapter, it is recognized by my system (ls /dev/usb/) and to send a file to the plotter the command cat drawing.hpgl > /dev/usb/lp0 is enough. (N.B. The user has to be in the lp group; I sent larger files and the buffering seems to work just fine)

Could we make Chiplotle recognize and work with devices connected via a parallel port ? (i.e. lp and tty)

Here my current workaround, moving a pen:

from shutil import copyfile
from datetime import datetime
# Chiplotle
from chiplotle.hpgl.commands import PA
from chiplotle.tools import io

def get_time_id():
    """
    generate a unique ID
    """
    time = datetime.now()
    id = time.strftime('%Y%m%d%H%M%S')
    return id

def make_hpgl_file(plot):
    """
    create the file to be printed
    """
    file_name = get_time_id() + '.hpgl'  
    path = sys.path[0]+'/tmp/' 
    file = path + file_name
    # write the hpgl instructions to the file
    io.save_hpgl(plot, file)
    return file

def send_to_plotter(hpgl_file):
    """
    copy file to printer to launch execution
    plotter is recognized as printer on prallel port
    """
    try:
        # equals CL $ cat drawing.hpgl > dev/usb/lp0
        copyfile(hpgl_file, '/dev/usb/lp0')
    except Exception as e:
        print(
            '[ERROR]\t\tCheck if plotter is plugged in [with $ ls /dev/usb/]' + str(e))

while True:
    # enter coordinate tuples where to move the pen
    new_location = input('Where to go ? ')

    plot = [PA([new_location])]

    # execute plot
    file = make_hpgl_file(plot)
    send_to_plotter(file)

My only guess is that the starting point would be in the search_and_instantiate_plotters() function...

mo-nonym commented 3 years ago

Solved with this workaround: https://gitlab.com/mononym/chiplotle-on-parallel-port

yitzhakpaul commented 2 years ago

Solved with this workaround: https://gitlab.com/mononym/chiplotle-on-parallel-port

any chance you’d be able to share this? The link seems dead.