computer<-->world connections
There are three new tools in the shed. List:
1. a Max/Jitter patch that will advance full resolution video frames while driving the Tobin through a whole roll of single frames film. Call it an automated digital optical printer
2. a Boarduino and prototype shield for interfacing with generalized MIDI streams
3. an interface to John Fletcher’s Integrating light meter (for lumpy time)
3. a plugin for chatbots that automates the jkerouac teletype project. News on that follows
The serialdaemon [http://cs.gmu.edu/~sean/cs685/uploads/Main/serialdaemon.c.zip] code allows me to route connnections on an arbitrary tcp port directly to the serial port. Now I can connect to that port and send characters to the tty-connect board for printing out on the teletype. First, compile serialdaemon.c
gcc serialdaemon.c
mv a.out serialdaemon
chmod 755 serialdaemon
mv serialdaemon /usr/local/bin/
- connect the keyspan and fire it up:
serialdaemon -serial /dev/tty.KeySerial1 -baud 38400 -port 10001 -indebug -outdebug
the only problem with this scheme is that it depends on the serialdaemon’s host being available from the Internet (ie, possessing a static IP). You could add another layer by putting the chat parser on the same host. Like this
[ Internet ] < –> [ ircbot -> chats -> cleaner -> rater -> filter -> serialdaemon ]
so the serialdaemon host needs to be a little smarter and more muscular than I had originally planned, but it makes for a more flexible framework.
I’m a bit fed up with Tcl and the eggdrop daemon. It’s solid enough but I don’t want to have to parse logfiles for periodic diffs. I would rather run a bot written in a familiar language that allows me to build a plugin. That plugin could then parse each line of chat and pass it to the rater. High-scoring lines could then be forwarded to the waiting port for output to the serial daemon and subsequent printing on the teleytpe.
Great! now how do I write a plugin? This one talks directly to the serial port obviating the need for a serial daemon. If everything’s going to live on one machine, this is probably the way to go.
class Rater(callbacks.Plugin):
"""Add the help for "@plugin help Rater" here
This should describe *how* to use this plugin.
"""
threaded = True
def __init__(self,thresh=50,db='/Users/dgoodwin/code/kerouacs_ear/_dbs/kerouac.bay'):
self.db = db
self.TTY = serial.Serial('/dev/tty.KeySerial1',38400)
self.TTY.write("\r\n ! ! ! ! ! ! ! HELLO JACK KEROUAC ! ! ! ! ! ! !")
threshstr = "\r\n ! ! ! ! ! ! ! THRESHOLD SET TO %s ! ! ! ! ! ! !\r\n" %(thresh)
self.TTY.write(threshstr)
self.guesser = Bayes()
self.guesser.load(fname=db)
self.thresh = thresh
self.debug = 0
def cleanup(self,sometext):
p = re.compile('^\[(.*)\> ')
q = re.compile('\\n')
clean = q.sub( '', sometext)
clean = p.sub( '', clean)
if self.debug: print 'the clean test is %s' %clean
return clean
def entrytemplate(self):
authors = ['hamilton','austen','rand','emerson','ginsberg','kerouac']
entry = {’timestamp’: 0.0,’text’:"",}
for a in authors:
entry[a] = 0
return entry
def rate(self,aline="never leave your house drunk"):
# set defaults
rating = self.entrytemplate()
rating['text'] = self.cleanup(aline)
score = self.guesser.guess(aline)
if self.debug: print ’score is %s’ %score
if self.debug: print ‘rating[text] is %s’ %rating['text']
for k,v in score:
if(v<0.01): v = 0.01
rating[ k ] = int(round (v*100) )
print "the rating was %s" %rating
if (rating['kerouac'] > self.thresh):
# send it to the SERIAL port!
try:
self.TTY.write(rating['text'] + ‘\r\n’)
except:
print "sorry, there’s a problem talking to the teletype"
then
myj.rate('[00:17] <shdow_ct> anyone out there’)
</shdow_ct>chatbots cinematography data representation installations notes projects serial port teletype tobin work
About this entry
You’re currently reading “computer<-->world connections,” an entry on cairndesign
- Published:
- 02.20.08 / 12pm
- Category:
- installations, notes, projects, work
Comments are closed
Comments are currently closed on this entry.