def send_key_old(key): #keys = {'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'away':10,'home':11,'off':12,'*':13,'#':14,'back':15,'ok':16,'panic':17,'next':18,'record off':19,'fire':14,'emergency':15} keys = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'away':10,'home':11,'off':12,'*':13,'#':14,'back':15,'ok':16,'panic':17,'next':18,'record off':19,'fire':20,'emergency':21} data = devices.make_packet(0xF2,1,chr(keys[key])) devices.s.write(data) p = devices.wait(1) return p.data
def read1(): #while 1: # try: data_size = devices.s.inWaiting() devices.s.read(data_size) data = devices.make_packet(0xF2,3,'') devices.s.write(data) #p = devices.wait(1,0.5) p = devices.wait(1) #return p.data return (p.data).strip()
def read(): data_size = devices.s.inWaiting() devices.s.read(data_size) p = None while p == None: data = devices.make_packet(0xF2,3,'') devices.s.write(data) #p = devices.wait(1) p = devices.wait(1,0.5) #return p.data return (p.data).strip()
def read_old(): data = devices.make_packet(0xF2,3,'') devices.s.write(data) p = devices.wait(1) #return p.data return (p.data).strip()
def send_key_fast(key,tm = 0.4): keys = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'away':10,'home':11,'off':12,'*':13,'#':14,'back':15,'ok':16,'panic':17,'next':18,'record off':19,'fire':20,'emergency':21} data = devices.make_packet(0xF2,1,chr(keys[key])) devices.s.read(devices.s.inWaiting()) devices.s.write(data) time.sleep(tm)