Beispiel #1
0
 def capture1(self):
     """Capture one trace"""
     try:
         ac = AcquisitionController(self.getScope(), self.getTarget(), writer=None, auxList=self._auxList, keyTextPattern=self.getAcqPattern())
         ac.sigNewTextResponse.connect(self.sigNewTextResponse.emit)
         return ac.doSingleReading()
     except Warning:
         sys.excepthook(*sys.exc_info())
         return False
Beispiel #2
0
    def captureM(self, progressBar = None):
        """Capture multiple traces and save its result"""
        if not progressBar: progressBar = ProgressBarText()

        with progressBar:
            progressBar.setStatusMask("Current Segment = %d Current Trace = %d", (0,0))
            progressBar.setMaximum(self._numTraces)

            waveBuffer = None
            tcnt = 0
            setSize = self.tracesPerSet()
            for i in range(0, self._numTraceSets):
                if progressBar.wasAborted(): break
                if self.getTraceFormat() is not None:
                    currentTrace = self.getNewTrace(self.getTraceFormat())
                    # Load trace writer information
                    prefix = currentTrace.config.attr("prefix")[:-1]
                    currentTrace.config.setAttr("targetHW", self.getTarget().getName() if self.getTarget() is not None else "None")
                    currentTrace.config.setAttr("targetSW", os.path.split(Programmer.lastFlashedFile)[1])
                    currentTrace.config.setAttr("scopeName", self.getScope().getName() if self.getScope() is not None else "None")
                    currentTrace.config.setAttr("scopeSampleRate", 0)
                    currentTrace.config.setAttr("notes", "AckPattern: " + str(self.getAcqPattern()) + "; Aux: " + ', '.join(item.getName() for item in self._auxList if item))
                    currentTrace.setTraceHint(setSize)

                    if waveBuffer is not None:
                        currentTrace.setTraceBuffer(waveBuffer)
                else:
                    currentTrace = None
                    prefix = datetime.now().strftime('%Y.%m.%d-%H.%M.%S')

                for aux in self._auxList:
                    if aux:
                        aux.setPrefix(prefix)

                ac = AcquisitionController(self.getScope(), self.getTarget(), currentTrace, self._auxList, self.getAcqPattern())
                ac.setMaxtraces(setSize)
                ac.sigNewTextResponse.connect(self.sigNewTextResponse.emit)
                ac.sigTraceDone.connect(self.sigTraceDone.emit)
                __pb = lambda: progressBar.updateStatus(i*setSize + ac.currentTrace + 1, (i, ac.currentTrace))
                ac.sigTraceDone.connect(__pb)
                self.sigCampaignStart.emit(prefix)
                ac.doReadings(tracesDestination=self.project().traceManager(), progressBar=progressBar)
                self.sigCampaignDone.emit()
                self.project().saveAllSettings(os.path.dirname(currentTrace.config.configFilename()) + "/%s_settings.cwset" % prefix, onlyVisibles=True)
                tcnt += setSize

                if currentTrace is not None:
                    waveBuffer = currentTrace.traces  # Re-use the wave buffer to avoid memory reallocation

                if progressBar.wasAborted():
                    break

            if currentTrace is not None:
                currentTrace.unloadAllTraces()  # Required in order to make the GC work properly :(
                self._traceFormat.unloadAllTraces()
Beispiel #3
0
 def capture1(self):
     """Capture one trace"""
     try:
         aux_dict = self.getAuxFunctions(True)
         ac = AcquisitionController(self.getScope(), self.getTarget(), writer=None, aux=aux_dict, keyTextPattern=self.getAcqPattern())
         ac.sigNewTextResponse.connect(self.updateLastKeyText)
         if self.getTarget():
             self.getTarget().init()
         return ac.doSingleReading()
     except Warning:
         sys.excepthook(*sys.exc_info())
         return False
Beispiel #4
0
def acquisition_controller(scope,
                           target=None,
                           writer=None,
                           aux=None,
                           key_text_pattern=None):
    """Not required when running GUI"""
    ac = AcquisitionController(scope=scope,
                               target=target,
                               keyTextPattern=key_text_pattern)
    return ac
Beispiel #5
0
    def captureM(self, progressBar=None, scope=None, target=None, project=None, aux_list=None, ktp=None, N=1, seg_size=None):
        """Capture multiple traces and save its result"""
        if not progressBar:
            progressBar = ProgressBarText()

        if seg_size is None:
            seg_size = 1000
        trace_mgr = project.traceManager() if project is not None else None
        trace_fmt = project.getTraceFormat() if project is not None else None
        aux_dict = aux_list.getDict(True) if aux_list is not None else None
        segments = int(math.ceil(N / float(seg_size)))

        with progressBar:
            progressBar.setStatusMask("Current Segment = %d Current Trace = %d", (0,0))
            progressBar.setMaximum(N)

            waveBuffer = None
            tcnt = 0
            for i in range(0, segments):
                if progressBar.wasAborted(): break

                this_seg_size = min(seg_size, N - i*seg_size)
                if trace_fmt is not None:
                    currentTrace = self.getNewTrace(trace_fmt)
                    # Load trace writer information
                    prefix = currentTrace.config.attr("prefix")[:-1]
                    currentTrace.config.setAttr("targetHW", target.getName() if target is not None else "None")
                    currentTrace.config.setAttr("targetSW", os.path.split(Programmer.lastFlashedFile)[1])
                    currentTrace.config.setAttr("scopeName", scope.getName() if scope is not None else "None")
                    notes_str = "AckPattern: " + str(ktp) + "; "
                    notes_str += "Aux: "
                    if aux_dict is not None:
                        for t in aux_dict.keys():
                            notes_str += "%s" % t + ", ".join([str(item) for item in aux_dict[t] if item])
                    currentTrace.config.setAttr("notes", notes_str)
                    currentTrace.setTraceHint(this_seg_size)

                    if waveBuffer is not None:
                        currentTrace.setTraceBuffer(waveBuffer)
                else:
                    currentTrace = None
                    prefix = datetime.now().strftime('%Y.%m.%d-%H.%M.%S')

                if aux_dict is not None:
                    for func in aux_dict['set_prefix']:
                        func(prefix)

                ac = AcquisitionController(scope, target, currentTrace, aux_dict, ktp)
                ac.setMaxtraces(this_seg_size)
                ac.sigNewTextResponse.connect(self.updateLastKeyText)
                ac.sigTraceDone.connect(self.sigTraceDone.emit)
                __pb = lambda: progressBar.updateStatus(i*seg_size + ac.currentTrace + 1, (i, ac.currentTrace))
                ac.sigTraceDone.connect(__pb)
                self.sigCampaignStart.emit(prefix)
                ac.doReadings(tracesDestination=trace_mgr, progressBar=progressBar)

                if currentTrace is not None:
                    project.saveAllSettings(os.path.dirname(currentTrace.config.configFilename()) + "/%s_settings.cwset" % prefix, onlyVisibles=True)
                    waveBuffer = currentTrace.traces  # Re-use the wave buffer to avoid memory reallocation
                self.sigCampaignDone.emit()
                tcnt += seg_size

                if progressBar.wasAborted():
                    break

            if currentTrace is not None:
                currentTrace.unloadAllTraces()  # Required in order to make the GC work properly :(
                trace_fmt.unloadAllTraces()
        return True
Beispiel #6
0
    def captureM(self, progressBar=None):
        """Capture multiple traces and save its result"""
        if not progressBar: progressBar = ProgressBarText()

        with progressBar:
            progressBar.setStatusMask(
                "Current Segment = %d Current Trace = %d", (0, 0))
            progressBar.setMaximum(self._numTraces)

            waveBuffer = None
            tcnt = 0
            setSize = self.tracesPerSet()
            for i in range(0, self._numTraceSets):
                if progressBar.wasAborted(): break
                if self.getTraceFormat() is not None:
                    currentTrace = self.getNewTrace(self.getTraceFormat())
                    # Load trace writer information
                    prefix = currentTrace.config.attr("prefix")[:-1]
                    currentTrace.config.setAttr(
                        "targetHW",
                        self.getTarget().getName()
                        if self.getTarget() is not None else "None")
                    currentTrace.config.setAttr(
                        "targetSW",
                        os.path.split(Programmer.lastFlashedFile)[1])
                    currentTrace.config.setAttr(
                        "scopeName",
                        self.getScope().getName()
                        if self.getScope() is not None else "None")
                    currentTrace.config.setAttr(
                        "notes", "AckPattern: " + str(self.getAcqPattern()) +
                        "; Aux: " +
                        ', '.join(item.getName()
                                  for item in self._auxList if item))
                    currentTrace.setTraceHint(setSize)

                    if waveBuffer is not None:
                        currentTrace.setTraceBuffer(waveBuffer)
                else:
                    currentTrace = None
                    prefix = datetime.now().strftime('%Y.%m.%d-%H.%M.%S')

                for aux in self._auxList:
                    if aux:
                        aux.setPrefix(prefix)

                ac = AcquisitionController(self.getScope(), self.getTarget(),
                                           currentTrace, self._auxList,
                                           self.getAcqPattern())
                ac.setMaxtraces(setSize)
                ac.sigNewTextResponse.connect(self.sigNewTextResponse.emit)
                ac.sigTraceDone.connect(self.sigTraceDone.emit)
                __pb = lambda: progressBar.updateStatus(
                    i * setSize + ac.currentTrace + 1, (i, ac.currentTrace))
                ac.sigTraceDone.connect(__pb)
                self.sigCampaignStart.emit(prefix)
                ac.doReadings(tracesDestination=self.project().traceManager(),
                              progressBar=progressBar)

                if currentTrace is not None:
                    self.project().saveAllSettings(
                        os.path.dirname(currentTrace.config.configFilename()) +
                        "/%s_settings.cwset" % prefix,
                        onlyVisibles=True)
                    waveBuffer = currentTrace.traces  # Re-use the wave buffer to avoid memory reallocation
                self.sigCampaignDone.emit()
                tcnt += setSize

                if progressBar.wasAborted():
                    break

            if currentTrace is not None:
                currentTrace.unloadAllTraces(
                )  # Required in order to make the GC work properly :(
                self._traceFormat.unloadAllTraces()
        return True