Weird Looking: some sign code

some sign code

October 3, 2008 11:54am (6 years, 10 months and 18 hours ago)
So, what I’ve got here is my implementation of the favotech sign’s protocol in python.  As I’ve mentioned, it’s horrible.  From what I can tell, the sign supports basically the same protocol over TCP, UDP, and serial.  I’ve been using UDP over a crossover cable from a whitebox with two NICs, and that’s worked fine.

I’m using it inside a twisted app, mostly for all the batteries it includes.  I have a UDP server class that inherits from this class, but implements its own send_to_sign method.  This layout made reusing the code for different connection media a breeze.  Basic usage then looks something like this:

  self.set_text(0, '{y}OH HAI')
  self.set_text(1, 'I AM {f}THE{/f} SIGN')
  self.set_text(2, '{0}{ma} {dd}  {12}')

To dumb down the interface, a frame count of n actually creates a playlist containing n two-letter filenames, 'AA’…’ZZ’.  Calling set_text with a frame ID then sets the text of the corresponding file.  The set_text method has a dead simple markup language it can use to set text colors and stuff.

More to come, probably…


Oct 31, 2008 2:46am
BTW, the corrected time_sync method is:

   def time_sync(self):
       loc = localtime()
       self.send_message((5, 2, 2), data=
           [int(str(loc[0] % 1000), 16), 32, int(str(loc[1]), 16),
            int(str(loc[2]), 16), int(str(loc[3]), 16), int(str(loc[4]), 16),
            2, 6])

It took me a couple tries to figure this out because it all looked completely sane in the hex dumps of packets.

Leave a comment

Accepts BBCode with a few enhancements.