class SaleaeDump: _connection = Saleae def __init__(self, captures_folder): self._captures_folder = captures_folder def set_up_once(self): self._connection = Saleae() self._connection.set_capture_seconds(90) def set_up(self, **kwargs): self._connection.capture_start() sleep(0.5) def tear_down(self, test_id, **kwargs): sleep(1) self._connection.capture_stop() if not path.exists(self._captures_folder): os.makedirs(self._captures_folder) output_file = path.join(self._captures_folder, '%s.logicdata' % test_id) self._connection.save_to_file(output_file) def tear_down_once(self): pass
class SaleaeDump: _connection = Saleae def __init__(self, captures_folder): self._captures_folder = captures_folder def set_up_once(self): self._connection = Saleae() self._connection.set_capture_seconds(300) def set_up(self, **kwargs): self._connection.capture_start() sleep(0.5) def tear_down(self, test_id, **kwargs): sleep(1) self._connection.capture_stop() if not path.exists(self._captures_folder): os.makedirs(self._captures_folder) output_file = path.join(self._captures_folder, '%s.logicdata' % test_id) self._connection.save_to_file(output_file) def tear_down_once(self): pass
def set_up_once(self): self._connection = Saleae() self._connection.set_capture_seconds(300)
def save_data(log: Saleae) -> None: log.export_data2(WAVEFORM_FILE) sleep(3)
def configure_logic(log: Saleae) -> None: log.set_capture_seconds(1024) log.capture_start() sleep(5)
def connect_logic() -> Saleae: logic_ = Saleae(quiet=True) return logic_
def capture_self_report(digital_channels, analog_channels, trigger_channel, trigger_type, capture_time, tx_rate): if os.path.exists(filename): os.remove(filename) s = Saleae(host='localhost', port=10429) if s.is_logic_running(): try: s.close_all_tabs() except s.CommandNAKedError: print("Close tabs command failed") s.capture_stop() return False s.set_performance(PerformanceOption.Full) devs = s.get_connected_devices() if len(devs) >= 1: print("Found {} logic analyzers".format(len(devs))) if len(devs) > 1: # Select first device found, this could change in the future or may not be needed at all s.select_active_device(0) s.set_active_channels(digital_channels, analog_channels) reset_all_triggers(s, digital_channels) if trigger_channel > 0: s.set_trigger_one_channel(trigger_channel, trigger_type) # 1, Trigger.Negedge # s.set_num_samples(50000000) s.set_capture_seconds(capture_time) # 11 s.set_capture_pretrigger_buffer_size(10000) rates = s.get_all_sample_rates() # print("Rates: {}".format(rates)) for tup in rates: if tup[1] == tx_rate: s.set_sample_rate(tup) break s.capture_start() start = time.time() while True: time.sleep(.5) if s.is_processing_complete(): print("Processing complete") break if time.time() > start + 11: s.capture_stop() raise TimeoutError try: s.get_capture_range() except ValueError: pass except s.CommandNAKedError: return False time.sleep(.5) print("Exporting data to csv") s.export_data2(filename, analog_channels=analog_channels) while not s.is_processing_complete(): print("Waiting for export") time.sleep(5) if os.path.exists(filename): return True else: return False else: print("Failed to detect logic analyzer.") raise ConnectionError
def init_saleae(): sal = Saleae() analyzers = sal.get_analyzers() log.info(f"Saleae analyzers: {analyzers}") return sal
def set_up_once(self): self._connection = Saleae() self._connection.set_capture_seconds(90)