def UpdateText(self): text = self.GenerateNewsText() if self.text != text: self.text = text msg = Message.WriteText(self.text, disk_partition=self.partition, file_label=self.file_label) self.led_sign.SendMessage(msg) time.sleep(1)
def signon(): msg = Message.TurnSignOn() ser = serial.Serial(PORT, BAUD_RATE) x = ser.write(msg) resp = ser.read() ser.flushInput() ser.flushOutput() ser.close()
def Service(self): if (self.last_update is None): self.last_update = time.time() current_time = time.time() elapsed_time = current_time - self.last_update if (elapsed_time >= self.update_interval): update_time_msg = Message.SetSystemTime() self.led_sign.SendMessage(update_time_msg) time.sleep(1) screen_msg = self.UpdateText() self.led_sign.SendMessage(screen_msg) time.sleep(1) self.last_update = current_time
def signoff(): ''' Turn LED sign off ''' msg = Message.TurnSignOff(goodbyeMsg=False) ser = serial.Serial(PORT, BAUD_RATE) x = ser.write(msg) resp = ser.read() ser.flushInput() ser.flushOutput() ser.close()
def main(ip="172.16.16.2" , port=9520 , texts=""): ser = socket(AF_INET, SOCK_STREAM) addr = (ip, port) ser.connect(addr) # Turn Sign On ser.send(Message.TurnSignOn()) time.sleep(0.2) # files = [] if True: for i in range(len(texts)): files.append(generateTextScreen(str(texts[i]) , name=str(i) + ".nmg")) for f in files: debug_print("Writing file..." + f.label + " to drive: " + f.drive) if f.type == 'T': data = Message.WriteTextFilewithChecksum(f) debug_print(data) ser.send(data) elif f.type == 'P': for packetNumber in range(0,f.numPackets): debug_print("Writing image " + f.label + " do drive: " + f.drive + " packet number: " + str(packetNumber)) ser.send(Message.WritePictureFileWithChecksum(f, packetNumber=packetNumber)) time.sleep(0.2) ss = SEQUENTSYS(files) # just write the playlist as a system file playlist = Message.WriteSystemFile(ss) debug_print("Writing playlist...") debug_print(playlist) ser.send(playlist) debug_print("Script complete.") ser.close() sys.exit(0)
def CheckEmail(self): pop3 = poplib.POP3_SSL(self.pop3_server, self.port) pop3.user(self.user) pop3.pass_(self.pw) messages = [pop3.retr(i) for i in range(1, len(pop3.list()[1]) + 1)] # Concat message pieces: messages = ["\n".join(mssg[1]) for mssg in messages] #Parse message intom an email object: messages = [parser.Parser().parsestr(mssg) for mssg in messages] for message in messages: subject = message['subject'] sender = message['from'] msg = '{nonein}{noneout}{red}{7x6}{flashon}Email from:{flashoff}' msg = msg + '{nl}{amber}' + sender + '{nl}{nonein}{noneout}{flashon}{green}subj:{flashoff}{amber}' + subject #print msg self.email_queue.append(Message.EmergencyMessage(msg, t=25)) pop3.quit()
#!/usr/bin/env python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.StringFile("Hello there. this is a new writefie implementation.", file_label='hello.txt') port = '/dev/ttyACM0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
files = [] if True: files.append(TextFile(test, "FT.nmg", drive='D')) #port = '/dev/ttyUSB0' #port = '/dev/ttyACM0' port = '/dev/ttyVIRTUAL' baudRate = 19200 ser = serial.Serial(port, baudRate) if True: for f in files: print("Writing file..." + f.label + " to drive: " + f.drive) if f.type == 'T': ser.write(Message.WriteTextFilewithChecksum(f)) elif f.type == 'P': for packetNumber in range(0,f.numPackets): print("Writing image " + f.label + " do drive: " + f.drive + " packet number: " + str(packetNumber)) ser.write(Message.WritePictureFileWithChecksum(f, packetNumber=packetNumber)) time.sleep(1) time.sleep(1) if True: # the actual playlist is a SEQUENT.SYS ss = SEQUENTSYS(files) # just write the playlist as a system file playlist = Message.WriteSystemFile(ss) print("Writing playlist...") ser.write(playlist)
#!/usr/bin/env python # vim: set ts=2 expandtab: import serial from JetFileII import Message from config import PORT from config import BAUD_RATE msg = Message.SetSystemTime() print msg.encode('hex') #port = '/dev/ttyUSB0' #baudRate = 19200 ser = serial.Serial(PORT, BAUD_RATE) x = ser.write(msg) ser.close()
forecast_temp_low_2 = str( int(celsius2farenheight(float( weather['forecasts'][1]['low'])))).encode('UTF-8') forecast_temp_high_2 = str( int(celsius2farenheight(float( weather['forecasts'][1]['high'])))).encode('UTF-8') forecast_text_2 = weather['forecasts'][1]['text'].encode('UTF-8') text = '{pause=10}{typesetOff}{fastest}{amber}{7x6}{moverightin}{moverightout}Currently: {green}' + condition + '{nl}' text = '{typesetOff}{fastest}{amber}{7x6}{moverightin}{moverightout}Currently: {green}' + condition.encode( 'UTF-8') + '{nl}' text = text + '{amber}{moveleftin}{moveleftout}Temp: {red}' + temp + ' degrees{nl}' text = text + '{amber}{moverightin}{moverightout}Humidity: {green}' + humidity + '%{nl}' text = text + '{amber}{moveleftin}{moveleftout}Wind: {red}' + wind + 'mph{nl}' text = text + '{newframe}{fastest}{amber}{7x6}{moveupin}{movedownout}Forecast:{nl}' text = text + '{green}' + time_1 + '{nl}' text = text + '{red}Low:' + forecast_temp_low_1 + ' High: ' + forecast_temp_high_1 + '{nl}' text = text + '{amber}' + forecast_text_1 + '{nl}' text = text + '{newframe}{fastest}{amber}{7x6}{movedownin}{moveupout}Forecast:{nl}' text = text + '{green}' + time_2 + '{nl}' text = text + '{red}Low:' + forecast_temp_low_2 + ' High: ' + forecast_temp_high_2 + '{nl}' text = text + '{amber}' + forecast_text_2 + '{nl}' msg = Message.WriteText(text, file_label='WEATHER.TXT') port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
from JetFileII import Message from JetFileII import TextFile from JetFileII import PictureFile from JetFileII import SEQUENTSYS displayMsg = Message.DisplayControlWithoutChecksum import time pic = PictureFile('../images/awesome.bmp', 'xd.bmp', 'D') #pic = PictureFile('../images/g.bmp', 'newg1.bmp', 'D') #pic = PictureFile('../images/mario.bmp', 'mario.bmp', 'D') #port = '/dev/ttyUSB0' #port = '/dev/ttyACM0' port = '/dev/ttyVIRTUAL' baudRate = 19200 ser = serial.Serial(port, baudRate) #debug incorrect checksum #ser.write(Message.WritePictureFileWithChecksum(pic, packetNumber=0)) for packetNumber in range(0, pic.numPackets): print("Writing image packet " + str(packetNumber)) ser.write( Message.WritePictureFileWithChecksum(pic, packetNumber=packetNumber)) time.sleep(1) print("Script complete.") ser.close()
displayMsg = Message.DisplayControlWithoutChecksum import re #currently static values for my display groupAddr = 1 unitAddr = 1 port = '/dev/ttyUSB0' baudRate = 19200 widthPixels = 128 heightPixels = 32 ser = serial.Serial(port, baudRate) msg = Message.getSystemFile() h = ":".join("{:02x}".format(ord(c)) for c in msg) print(h) time.sleep(1) # 'U\xa7O\x13V\x00\x00\x00\x00\x00\xab\xcd\x02\x02\x06\x00SEQUENT.SYS\x00V\x00\x00\x00\x00\x00\x00\x00V\x00\x01\x00\x01\x00\x00\x00SQ\x04\x00\x03\x00\x00\x00ET\x0f\x80\xd8\x07\x03\x10\x00\x00\x01\x01\xd8\x07\x03\x10\x00\x00\x01\x01\xb0\x00\x00\x00ABET\x0f\x80\xd8\x07\x03\x10\x00\x00\x01\x01\xd8\x07\x03\x10\x00\x00\x01\x01\xb0\x00\x00\x00ACET\x0f\x80\xd8\x07\x03\x10\x00\x00\x01\x01\xd8\x07\x03\x10\x00\x00\x01\x01\xb0\x00\x00\x00AD' print("************getting playlist**********") print(msg) x = ser.write(msg) s = ser.read(len(msg)) print("************response**********") print(s) h = ":".join("{:02x}".format(ord(c)) for c in s) print(h)
#!/usr/bin/python # vim: set ts=2 expandtab: import serial from JetFileII import Message from struct import * led_sign_width = 128 led_sign_height = 32 #data = bytearray(led_sign_width*led_sign_height/8)#one bit per pixel data = '\xff' * (led_sign_width*led_sign_height/8) msgs = Message.DynamicDisplay(data) #print msg.encode("hex") #print 'size of message is ' + str(len(msg)) port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) for i,msg in enumerate(msgs): #binary_msg = unpack('C',msg) print "MSG " + str(i) + ':' + msg.encode("hex") x = ser.write(msg) ser.close()
#!/usr/bin/python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.WriteText("Hello there. this is a new writefie implementation.") #print msg.encode("hex") #print 'size of message is ' + str(len(msg)) port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
#!/usr/bin/env python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.AutoTest() #port = '/dev/ttyUSB0' port = '/dev/ttyACM0' #port = '/dev/ttyVIRTUAL' baudrate = 19200 ser = serial.Serial(port, baudrate, timeout=None) x = ser.write(msg) y = ser.read() ser.flushInput() ser.flushOutput() ser.close()
#!/usr/bin/env python # vim: set ts=2 expandtab: ''' Write a text file using v2.0 protocol with checksum v2.0 supports filenames up to 12 characters ''' import serial from JetFileII import Message from JetFileII import TextFile file = TextFile( '{pause=5}{middle}{moveRightIn}{moveLeftOut}{b16x12}{green}{hhmin_12hr}{nl}{amber}{7x6}{dow_abbr}, {month_abbr} {date} {yyyy}', "AB.nmg", drive='D') #port = '/dev/ttyS0' port = '/dev/ttyUSB0' #port = '/dev/ttyACM0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(Message.WriteTextFilewithChecksum(file)) ser.close()
#!/usr/bin/python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.TurnSignOff(goodbyeMsg=False) #print msg.encode("hex") #print 'size of message is ' + str(len(msg)) port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
# # playlist.py # John O'Neil # Wednesday, March 13th 2013 # # Exercise the playlist commands in JetFileII protocol # #****************************************************************************** import serial from JetFileII import Message import time msgs = [] msgs.append( Message.File('Today:{mm/dd/yy}{nl}{hhmin_12hr}:{sec}', file_label='time.TXT')) msgs.append(Message.File('WEATHER', file_label='WEATHER.TXT')) #msgs.append( Message.File('NEWS',file_label='NEWS.TXT') ) #msgs.append( Message.File('SPORTS',file_label='SPORTS.TXT') ) playlist = Message.WriteSystemFile(Message.Playlist(msgs)) #print "Playlist is: " + playlist.encode('hex') #print playlist port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) time.sleep(1)
#!/usr/bin/python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.TurnSignOn() #print msg.encode("hex") #print 'size of message is ' + str(len(msg)) port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
#!/usr/bin/env python # vim: set ts=2 expandtab: #****************************************************************************** # # emergencymessage.py # Hit sign with an async emergency message # #****************************************************************************** import serial import time from JetFileII import Message msg = Message.EmergencyMessage('This is an Emergency!') #port = '/dev/ttyUSB0' port = '/dev/ttyACM0' #port = '/dev/ttyVIRTUAL' baudRate = 19200 ser = serial.Serial(port, baudRate) ser.write(msg) ser.close()
#!/usr/bin/env python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.StopCountdown() #print msg.encode("hex") #print 'size of message is ' + str(len(msg)) port = '/dev/ttyUSB0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
#!/usr/bin/env python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.StopTest() #port = '/dev/ttyUSB0' port = '/dev/ttyACM0' #port = '/dev/ttyVIRTUAL' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) y = ser.read() ser.flushInput() ser.flushOutput() ser.close()
#!/usr/bin/env python # vim: set ts=2 expandtab: import serial from JetFileII import Message msg = Message.StartCountdown(day=10, hour=10, minute=10, second=10) #msg = Message.EmergencyMessage("What's going on?") #print msg.encode("hex") #print 'size of message is ' + str(len(msg)) port = '/dev/ttyUSB0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()
except IOError: print 'ERROR. Problem opening file ' + input_filename sys.exit(1) print 'Uploading file ' + input_filename + ' as file ' + uploaded_filename #print "length of data is " + str(len(data)) #print "and data is " + data.encode('hex') #print data print("length of data is : " + str(len(data))) large_picture = True if large_picture: msgs = Message.Picture(data,file_label=uploaded_filename) msg = None else: msgs = [] msg = Message.UploadSmallPicture(data,partition='E', msgId=1) port = '/dev/ttyACM0' baudRate = 19200 ser = serial.Serial(port, baudRate) for m in msgs: x = ser.write(m) time.sleep(1) if msg:
print 'USAGE: bitmap.py <bmp file to upload to sign> <filename to write on sign E partition>' sys.exit(1) input_filename = sys.argv[1] uploaded_filename = sys.argv[2] #get a microsoft formatted bitmap data = None try: with open(input_filename, "r") as myfile: data = myfile.read() except IOError: print 'ERROR. Problem opening file ' + input_filename sys.exit(1) print 'Uploading file ' + input_filename + ' as file ' + uploaded_filename #print "length of data is " + str(len(data)) #print "and data is " + data.encode('hex') #print data msgs = Message.Picture(data, file_label=uploaded_filename) port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) for msg in msgs: x = ser.write(msg) time.sleep(1) ser.close()
def UpdateText(self): msg = Message.WriteText(self.message, disk_partition=self.partition, file_label=self.file_label) self.led_sign.SendMessage(msg) time.sleep(1)
def GeneratePlaylistEntry(self): return Message.File(self.message, file_label=self.file_label, partition=self.partition)
# and send it to my LED sign. # This is a test in preparation for an integrated LED sign server type daemon # that could have something like this as just one small dedicated 'process'. # # REQUIRES: debian package "python-pywapi" available in Ubuntu 12.04 or # google code. # #****************************************************************************** import pywapi import serial import time import datetime from time import mktime from datetime import datetime from JetFileII import Message displayMsg = Message.DisplayControlWithoutChecksum msg = Message.EmergencyMessage('Hello there. How are you?') print msg.encode("hex") print 'size of message is ' + str(len(msg)) port = '/dev/ttyS0' baudRate = 19200 ser = serial.Serial(port, baudRate) x = ser.write(msg) ser.close()