Esempio n. 1
0
    def read_register_and_xml(self, settingsfile, xmlfile):
        if xmlfile is not None:
            try:
                with open(xmlfile) as infile:
                    xml = infile.read()
            except IOError:
                print("can't read {}".format(xmlfile))
                sys.exit(1)
        else:
            xml = self.dsptk.generic_request(COMMAND_XML,
                                             COMMAND_XML_RESPONSE).decode()
            if xml is None or len(xml) == 0:
                print("server did not provide XML file")
                sys.exit(1)

        xmlprofile = XmlProfile()
        try:
            xmlprofile.read_from_text(xml)
        except:
            print("can't parse XML profile")
            sys.exit(1)

        try:
            registerfile = SettingsFile(settingsfile, xmlprofile.samplerate())
        except:
            print("can't parse settings file")
            sys.exit(1)

        return (registerfile, xmlprofile)
Esempio n. 2
0
    def store_attributes(self, attributes):
        '''
        Store specific attributes from RAM into DSP EEPROM
        '''
        xml = self.dsptk.generic_request(COMMAND_XML, COMMAND_XML_RESPONSE)
        if len(xml) == 0:
            print("can't retrieve XML file from server")
            sys.exit(1)

        xmlprofile = XmlProfile()
        xmlprofile.read_from_text(xml.decode("utf-8", errors="replace"))

        replace = {}

        for attribute in attributes:
            (addr, length) = xmlprofile.get_addr_length(attribute)
            if addr is None:
                continue

            while length > 0:
                data = self.dsptk.sigmatcp.read_data(
                    addr, self.dsptk.dsp.WORD_LENGTH)
                replace[addr] = data
                addr += 1
                length -= 1

        xmlprofile.replace_eeprom_cells(replace)
        xmlprofile.replace_ram_cells(replace)
        self.write_back_xml(xmlprofile)
Esempio n. 3
0
    def read_xml_profile():
        SigmaTCPHandler.xml = XmlProfile(SigmaTCPHandler.dspprogramfile)
        cs = SigmaTCPHandler.xml.get_meta("checksum")
        logging.debug("checksum from XML: %s", cs)
        SigmaTCPHandler.checksum_xml = None
        if cs is not None:
            SigmaTCPHandler.checksum_xml = bytearray()
            for i in range(0, len(cs), 2):
                octet = int(cs[i:i + 2], 16)
                SigmaTCPHandler.checksum_xml.append(octet)

        checksum_mem = SigmaTCPHandler.program_checksum()
        checksum_xml = SigmaTCPHandler.checksum_xml
        logging.info("checksum memory: %s, xmlfile: %s", checksum_mem,
                     checksum_xml)

        if (checksum_xml is not None) and (checksum_xml != 0):
            if (checksum_xml != checksum_mem):
                logging.error("checksums do not match, aborting")
                SigmaTCPHandler.checksum_error = True
                return
        else:
            logging.info("DSP profile doesn't have a checksum, "
                         "might be different from the program running now")

        SigmaTCPHandler.checksum_error = False
Esempio n. 4
0
def demo():
    xml = XmlProfile("sample_files/xml/4way-iir.xml")
    xml.write_xml("/tmp/x.xml")
    fs = xml.samplerate()
    rf = SettingsFile("sample_files/simple-settings.txt", fs)
    print(rf.values)
    rf.update_xml_profile(xml)
    print("writing y.xml")
    xml.write_xml("/tmp/y.xml")
    rf = SettingsFile("sample_files/settings.txt", fs)
    print(rf.values)
    rf.update_xml_profile(xml)
    print("writing z.xml")
    xml.write_xml("/tmp/z.xml")
Esempio n. 5
0
    def store_attributes(self, attributes=None):
        '''
        Store specific attributes from RAM into DSP EEPROM
        '''
        xml = self.dsptk.generic_request(COMMAND_XML,
                                         COMMAND_XML_RESPONSE)
        if len(xml) == 0:
            print("can't retrieve XML file from server")
            sys.exit(1)

        xmlprofile = XmlProfile()
        xmlprofile.read_from_text(xml.decode("utf-8", errors="replace"))

        replace = {}

        if attributes is None:
            print("checking attribute tags from XML profile")
            attributes = xmlprofile.get_storable_registers()

        if len(attributes) == 0:
            print("no storable attributes found in XML, using default set")
            attributes = REGISTER_ATTRIBUTES

        for attribute in attributes:
            (addr, length) = xmlprofile.get_addr_length(attribute)
            if addr is None:
                continue

            while length > 0:
                data = self.dsptk.sigmatcp.read_data(addr,
                                                     self.dsptk.dsp.WORD_LENGTH)
                replace[addr] = data
                addr += 1
                length -= 1

            print("storing {}".format(attribute))

        xmlprofile.replace_eeprom_cells(replace)
        xmlprofile.replace_ram_cells(replace)
        self.write_back_xml(xmlprofile)
Esempio n. 6
0
 def merge_params_into_xml(self, xmlfile):
     """
     Add the metadata into a XML DSP project file.
     """
     xml = XmlProfile(xmlfile)
     param_list = self.param_list()
     xml.update_metadata(param_list)
     xml.write_xml(xmlfile)
     return param_list
Esempio n. 7
0
 def merge_params_into_xml(self, xmlfile):
     xml = XmlProfile(xmlfile)
     param_list = self.param_list()
     xml.update_metadata(param_list)
     xml.write_xml(xmlfile)
     return param_list