Example #1
0
 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
Example #2
0
 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:]]
Example #3
0
 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:]]
Example #4
0
    def parsePacket(self, msg):
        if not 0xF7 in msg:
            print "printSampleDumpDataPacket: could not find EOX"
            return HandshakeMessage.NAK(packetnumber=self.lastpacket)
        
        cs = msg.index(0xF7)-1
        calced_cs = checksum(msg[1:cs])
        if self.debug:
            print "Sample Dump Data Packet"
            print "  Data:"
            print "    Packet count", msg[4]
            print "  checksum:", hex(msg[cs]), \
                "(calculated 0x%x)" % calced_cs
        if msg[cs] != calced_cs:
            print "Checksum mismatch:", hex(msg[cs]), "should be", hex(calced_cs)
            return HandshakeMessage.NAK(packetnumber=self.lastpacket)
        offset = 5
        format = int(self.header['sample_format'])

        if format == 14:
            self.data += msg[offset:offset+120]
        else:
            print format, "bit samples are not supported"
        self.lastpacket = msg[4]
        self.raw += msg
        self.packetcounter += 1
        self.bar.next()
        return HandshakeMessage.ACK(packetnumber=self.lastpacket)
Example #5
0
 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:]]
Example #6
0
 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:]]
Example #7
0
 def printFileDumpDataBlock(self, msg, prettyPrint=True):
     noctets = msg[5]
     offset = 6
     #data = []
     for i in xrange(noctets):
         #data += conv7_8(msg[offset:offset+8])
         offset += 8
     if prettyPrint and not self.debug:
         pass
     else:
         print "  Data:"
         print "    noctets:", noctets
         #print "       data:", data
         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:]]
Example #8
0
 def printFileDumpDataBlock(self,msg,prettyPrint=True):
     noctets = msg[5]
     offset=6
     #data = []
     for i in xrange(noctets):
         #data += conv7_8(msg[offset:offset+8])
         offset += 8
     if prettyPrint and not self.debug:
         pass
     else:
         print "  Data:"
         print "    noctets:", noctets
         #print "       data:", data
         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:]]
Example #9
0
 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
Example #10
0
 def handleStatusAnswer(self,msg,timestamp):
     self.sendSysEx( MSCEIMessage(fromName="D_WAIT"),timestamp=timestamp+1)
     offset= 5 + 3*8
     cc = msg[offset]
     cc_calc = checksum(msg[1:offset])
     if cc == cc_calc:
         self.sendSysEx( MSCEIMessage(fromName="D_ACK"),
                         timestamp=timestamp+2)
         if self.dump_ram:
             self.dump_on = True
             self.startDump("ramdump_%s.bin" % mktimestamp(), 2097060)
             time.sleep(0.1)
             self.sendSysEx( MSCEIMessage(fromName="F_ACK"),
                             timestamp=timestamp+3)
             return True
     else:
         self.sendSysEx( MSCEIMessage(fromName="D_NACK"),
                         timestamp=timestamp+2)
     return False
Example #11
0
 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
Example #12
0
 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:]]
Example #13
0
 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:]]