def printDirectoryAnswer(self,msg): offset=20 data = [] for i in xrange(2): data += conv7_8(msg[offset:offset+8]) offset += 8 datadict = { "type" : msg[5], "bank" : msg[6], "perf" : msg[7], "filename1" : repr(str(bytearray(msg[8:19]))), "fileflags" : msg[19], "datastr" : hexdump(data), "info.Time" : convertToShort(data[0:2]), "info.Date" : convertToShort(data[2:4]), "info.Length" : convertToLong(data[4:8]), "info.InstrID" : data[8], "info.FileID" : data[9], "filename2" : repr(str(bytearray(msg[offset:offset+11]))), } offset += 11 print " Data:" for k,v in sorted(datadict.iteritems()): print " %s:" % k, v print " checksum:", hex(msg[offset]), \ "(calculated 0x%x)" % checksum(msg[1:offset]) if msg[offset+1] != 0xF7: print " remaining bytes:", [hex(b) for b in msg[offset+1:]]
def printDirectoryAnswer(self, msg): offset = 20 data = [] for i in xrange(2): data += conv7_8(msg[offset:offset + 8]) offset += 8 datadict = { "type": msg[5], "bank": msg[6], "perf": msg[7], "filename1": repr(str(bytearray(msg[8:19]))), "fileflags": msg[19], "datastr": hexdump(data), "info.Time": struct.unpack('>H', list2str(data[0:2]))[0], "info.Date": struct.unpack('>H', list2str(data[2:4]))[0], "info.Length": struct.unpack('>I', list2str(data[4:8]))[0], "info.InstrID": data[8], "info.FileID": data[9], "filename2": repr(str(bytearray(msg[offset:offset + 11]))), } offset += 11 print " Data:" for k, v in sorted(datadict.iteritems()): print " %s:" % k, v print " checksum:", hex(msg[offset]), \ "(calculated 0x%x)" % checksum(msg[1:offset]) if msg[offset + 1] != 0xF7: print " remaining bytes:", [hex(b) for b in msg[offset + 1:]]
def handleFileDumpHeader(self,msg,timestamp): self.sendSysEx( MSCEIMessage(fromName="F_WAIT"),timestamp=timestamp+1) offset=17 data = [] for i in xrange(2): data += conv7_8(msg[offset:offset+8]) offset += 8 location = '' while msg[offset] != 0: location += chr(msg[offset]) offset += 1 offset+=1 cc = msg[offset] cc_calc = checksum(msg[1:offset]) if cc == cc_calc: filename = str(bytearray(msg[5:16])).strip() length = struct.unpack('>I',list2str(data[4:8]))[0] self.startDump(filename,length) self.dump(data[8:]) self.sendSysEx( MSCEIMessage(fromName="F_ACK"), timestamp=timestamp+2) else: self.sendSysEx( MSCEIMessage(fromName="F_NACK"), timestamp=timestamp+2) return True
def printFileDumpHeader(self,msg,swapDateTime=False,prettyPrint=True): offset=17 data = [] for i in xrange(2): data += conv7_8(msg[offset:offset+8]) offset += 8 location = '' while msg[offset] != 0: location += chr(msg[offset]) offset += 1 offset+=1 datadict = { "filename" : str(bytearray(msg[5:16])), "flags" : msg[16], "info.Time" : timeToStr(convertToShort(data[2:4]) if swapDateTime else convertToShort(data[0:2])), "info.Date" : dateToStr(convertToShort(data[0:2]) if swapDateTime else convertToShort(data[2:4])), "info.Length" : convertToLong(data[4:8]), "info.DeviceClass" : data[8], "info.DeviceSubClass": data[9], "info.DeviceRelease" : data[10], "info.FileType" : data[11], "info.FileFormat" : data[12], "location" : location, } if prettyPrint and not self.debug: if datadict["filename"] == "="*11: print "%13s %8s %10s %8s %2s %2s %2s %2s %2s %2s %s" % \ ("Filename".center(13), "Size".center(8), "Date".center(8), "Time".center(8), "Fl", "Ty", "Fo", "Cl", "SC", "Re", "Path") print "-"*80 else: print "%13s %8d %10s %8s %2s %2s %2s %2s %2s %2s %s" % \ (datadict["filename"].ljust(13), datadict["info.Length"], datadict["info.Date"], datadict["info.Time"], datadict["flags"], datadict["info.FileType"], datadict["info.FileFormat"], datadict["info.DeviceClass"], datadict["info.DeviceSubClass"], datadict["info.DeviceRelease"], repr(prettyPath(datadict["location"]))) else: print " Data:" for k,v in sorted(datadict.iteritems()): print " %s:" % k, v print " checksum:", hex(msg[offset]), \ "(calculated 0x%x)" % checksum(msg[1:offset]) if msg[offset+1] != 0xF7: print " remaining bytes:", [hex(b) for b in msg[offset+1:]]
def printFileDumpHeader(self, msg, swapDateTime=False, prettyPrint=True): offset = 17 data = [] for i in xrange(2): data += conv7_8(msg[offset:offset + 8]) offset += 8 location = '' while msg[offset] != 0: location += chr(msg[offset]) offset += 1 offset += 1 timestr = list2str(data[2:4]) if swapDateTime else list2str(data[0:2]) datestr = list2str(data[0:2]) if swapDateTime else list2str(data[2:4]) datadict = { "filename": str(bytearray(msg[5:16])), "flags": msg[16], "info.Time": time2str(struct.unpack('>H', timestr)[0]), "info.Date": date2str(struct.unpack('>H', datestr)[0]), "info.Length": struct.unpack('>I', list2str(data[4:8]))[0], "info.DeviceClass": data[8], "info.DeviceSubClass": data[9], "info.DeviceRelease": data[10], "info.FileType": data[11], "info.FileFormat": data[12], "location": location, } if prettyPrint and not self.debug: if datadict["filename"] == "=" * 11: print "%13s %8s %10s %8s %2s %2s %2s %2s %2s %2s %s" % \ ("Filename".center(13), "Size".center(8), "Date".center(8), "Time".center(8), "Fl", "Ty", "Fo", "Cl", "SC", "Re", "Path") print "-" * 80 else: print "%13s %8d %10s %8s %2s %2s %2s %2s %2s %2s %s" % \ (datadict["filename"].ljust(13), datadict["info.Length"], datadict["info.Date"], datadict["info.Time"], datadict["flags"], datadict["info.FileType"], datadict["info.FileFormat"], datadict["info.DeviceClass"], datadict["info.DeviceSubClass"], datadict["info.DeviceRelease"], repr(pretty_path(datadict["location"]))) else: print " Data:" for k, v in sorted(datadict.iteritems()): print " %s:" % k, v print " checksum:", hex(msg[offset]), \ "(calculated 0x%x)" % checksum(msg[1:offset]) if msg[offset + 1] != 0xF7: print " remaining bytes:", [hex(b) for b in msg[offset + 1:]]
def handleDataDump(self,msg,timestamp): self.sendSysEx( MSCEIMessage(fromName="D_WAIT")) noctets = msg[5] offset=6 data = [] for i in xrange(noctets): data += conv7_8(msg[offset:offset+8]) offset += 8 cc = msg[offset] cc_calc = checksum(msg[1:offset]) if cc == cc_calc: self.dump(data) self.sendSysEx( MSCEIMessage(fromName="D_ACK"), timestamp=timestamp+2) else: self.sendSysEx( MSCEIMessage(fromName="D_NACK"), timestamp=timestamp+2) return True
def handleDirectoryAnswer(self,msg,timestamp): #time.sleep(0.1) self.sendSysEx( MSCEIMessage(fromName="D_WAIT"),timestamp=timestamp+1) offset = 8 + 11 + 1 data = [] for i in xrange(2): data += conv7_8(msg[offset:offset+8]) offset += 8 offset += 11 cc = msg[offset] cc_calc = checksum(msg[1:offset]) if cc == cc_calc: filename = str(bytearray(msg[8:19])).strip() length = struct.unpack('>I',list2str(data[4:8]))[0] self.startDump(filename,length) #time.sleep(0.1) self.sendSysEx( MSCEIMessage(fromName="D_ACK"), timestamp=timestamp+2) else: self.sendSysEx( MSCEIMessage(fromName="D_NACK"), timestamp=timestamp+2) return True
def printStatusAnswer(self, msg): offset = 5 data = [] for i in xrange(3): data += conv7_8(msg[offset:offset + 8]) offset += 8 datadict = { "iClass": data[0], "iSubClass": data[1], "iRelease": data[2], "TotalMem": struct.unpack('>I', list2str(data[4:8]))[0], "FreeMem": struct.unpack('>I', list2str(data[8:12]))[0], "FreeSampleMem": struct.unpack('>I', list2str(data[12:16]))[0], "ReadyFor": tuple(data[16:18]), "ActBankPerf": tuple(data[18:20]), } print " Data:" for k, v in sorted(datadict.iteritems()): print " %s:" % k, v print " checksum:", hex(msg[offset]), \ "(calculated 0x%x)" % checksum(msg[1:offset]) if msg[offset + 1] != 0xF7: print " remaining bytes:", [hex(b) for b in msg[offset + 1:]]
def printStatusAnswer(self,msg): offset=5 data = [] for i in xrange(3): data += conv7_8(msg[offset:offset+8]) offset += 8 datadict = { "iClass" : data[0], "iSubClass" : data[1], "iRelease" : data[2], "TotalMem" : convertToLong(data[4:8]), "FreeMem" : convertToLong(data[8:12]), "FreeSampleMem": convertToLong(data[12:16]), "ReadyFor" : tuple(data[16:18]), "ActBankPerf" : tuple(data[18:20]), } print " Data:" for k,v in sorted(datadict.iteritems()): print " %s:" % k, v print " checksum:", hex(msg[offset]), \ "(calculated 0x%x)" % checksum(msg[1:offset]) if msg[offset+1] != 0xF7: print " remaining bytes:", [hex(b) for b in msg[offset+1:]]