You are viewing joel

Previous Entry | Next Entry


UPDATE: I've made lots of little updates to this.

I'm at SHDH26 right now. We now have a fancy login system that prints out name tags for you!

Tom Harrison, Ernesto S., and David S. had most of the system working last night, with the exception of the automatic label printer. This morning rndmcnlly and I got the printer working in about 2 hours!

Here is how we did it:

First we had to get the printer working on a Mac, this was pretty easy. We downloaded the drivers and set up the printer though the normal means.

After that we wrote the following two files:


"~/.enscriptrc":


Media: Label 162 288 10 10 152 278


  • Use the command enscript --list-media to make sure that your .enscriptrc is being parsed.
  • Use man enscript for more info
  • The numbers are in Postscript points!




"~/printer_server.py":


from twisted.web.resource import Resource
from twisted.web import server
from twisted.internet import reactor

from subprocess import *

class Launcher(Resource):
        isLeaf = True
        def render_POST(self, request):
                names = ['first_name', 'last_name']
                items = map((lambda l: request.args[l][0]), names)
                page = "\n".join(items)
                p = Popen(["enscript", "-r", "-B", "-f", "Helvetica35", "-MLabel"],stdin=PIPE)
                p.stdin.write(page)
                p.stdin.close()
                return page



reactor.listenTCP(1080, server.Site(Launcher()))
reactor.run()


(rndmcnlly  wrote all the python, I just figured out the enscript syntax)

Once the files were written, we ran the printer server using the "python printer_server.py command.

The printer server above listens on port TCP 1080, we had to change the port number because Comcast sucks and blocks that port.

The server listens on port 1080 for a HTTP POST and prints the value "first_name" on the first line and "last_name" on the second line.

Labels are printed by the web application sending a HTTP POST to the port of the computer connected to the printer - we had to set up port forwarding to get this working.

Unfortunately we didn't have time to implement Lee Felsenstein's suggestion to let people "tag" themselves. We'll have that working by the next SHDH - maybe even just let people go freeform on their tags.

Tom's end goal for this is to eventually have a "DevHouse Appliance" that other people could easily set up to do the same thing!

Comments

( 2 comments — Leave a comment )
krellan
Aug. 31st, 2008 01:27 am (UTC)
Nice! Hi there :)
Glad you got it working.
shevek
Nov. 16th, 2008 06:04 pm (UTC)
The label printer was incredibly cool. It was neat to see a piece of technology work so fluidly. :-)
( 2 comments — Leave a comment )

Profile

joel
Joel Franusic
Website

Latest Month

March 2009
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    
Powered by LiveJournal.com
Designed by Lilia Ahner