Пример #1
0
    def get(self, use_dict=False):
        '''|
        | Returns a packet from the sink data list. Overrides the method of the base HSD class
        | Before calling, first check the list with hasPacket()
        |________'''
        started = False
        packet = ''
        fdata = ''
        while len(self.snkDataList):
            pkt_tpl = self.snkDataList.pop(0)
    
            sop  = pkt_tpl[0]
            eop  = pkt_tpl[1]
            mty  = pkt_tpl[2]
            data = pkt_tpl[3]
            err  = pkt_tpl[4] # TODO: err not used

            if sop: 
                started = True
                       
            if started: 
                if eop:
                    data = self.packed_word(data, mty)
                    packet += data
                    fdata += data.encode('hex')
                    if self.filedump:
                        with open(self.filename, "a") as f:
                            f.write(fdata + '\n')    
                    return {"payload":packet} if use_dict else packet
                else: 
                    data = self.packed_word(data, 0)
                    packet += data
                    fdata += data.encode('hex')
            else:
                mylog.err('Wrong framing: ' + self.inst_name + ' (' + self.class_name + ')')
Пример #2
0
    def getStimuli(self, inData):
        '''|
        | Get stimuli data from file. Overrides the method of the base HSD class
        |________'''
        stim_data_rx = []
        try:
            with open(inData[0]["file"], 'rb') as myfile:
                for line in myfile.readlines():
                    stim_data_rx.append({"payload":line.strip().decode("hex")})
        except IOError:
            mylog.err("Stimuli file not found for " + self.inst_name + ":" + inData[0]["file"])

        return stim_data_rx
Пример #3
0
    def getStimuli(self, inData):
        '''|
        | Get stimuli data from file
        |________'''
        stim_data_rx = []
        pld = {}
        x = self._sig_names
        try:
            with open(inData[0]["file"], 'rb') as myfile:
                for line in myfile.readlines():
                    for name,pckt in zip(x, line.split()):
                        pld[name] = int(pckt)
                    stim_data_rx.append(pld)
                    pld = {}
        except IOError:
            mylog.err("Stimuli file not found for " + self.inst_name + ":" + inData[0]["file"])

        return stim_data_rx
Пример #4
0
    def getStimuli(self, inData):
        '''|
        | Get stimuli data from file
        |________'''
        stim_data_rx = []
        pld = {}
        x = self._sig_names
        try:
            with open(inData[0]["file"], 'rb') as myfile:
                for line in myfile.readlines():
                    for name, pckt in zip(x, line.split()):
                        pld[name] = int(pckt)
                    stim_data_rx.append(pld)
                    pld = {}
        except IOError:
            mylog.err("Stimuli file not found for " + self.inst_name + ":" +
                      inData[0]["file"])

        return stim_data_rx