Advertisement
Guest User

Saleae Logic 2 Automation Multiple Files

a guest
Jul 24th, 2022
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. # Imports
  2. import os, glob
  3. from time import sleep
  4. from saleae import automation
  5.  
  6. # Config
  7. localCaptureDir = '/path/to/my/captures/'
  8. analyzer_config_template = {
  9.     'Bit Rate (Bits/s)': 9600,
  10.     'Bits per Frame': '8 Bits per Transfer (Standard)',
  11.     'Stop Bits': '1 Stop Bit (Standard)',
  12.     'Parity Bit': 'No Parity Bit (Standard)',
  13.     'Significant Bit': 'Least Significant Bit Sent First (Standard)',
  14.     'Signal inversion': 'Inverted',
  15.     'Mode': 'Normal'
  16. }
  17.  
  18. # Main program starts here
  19.  
  20. # Connect to the running Logic 2 application on port 10430
  21. manager = automation.Manager(port=10430)
  22.  
  23. for file in glob.glob(localCaptureDir + "*.sal"):
  24.     # Open capture file
  25.     capture = manager.load_capture(file)
  26.     capture.wait() # Not strictly required for opening a saved capture
  27.  
  28.     # Clear all analyzers
  29.     analyzers = []
  30.  
  31.     # Add analyzers
  32.     for channel in [0, 1, 2, 3]:
  33.         analyzer_config = analyzer_config_template
  34.         analyzer_config['Input Channel'] = channel
  35.         analyzers.append(
  36.             capture.add_analyzer(
  37.                 name = 'Async Serial',
  38.                 label = 'channel_' + str(channel) + '_serial',
  39.                 settings = analyzer_config
  40.             )
  41.         )
  42.     sleep(2) # Not strictly required
  43.  
  44.     # Export data
  45.     capture.export_data_table(
  46.         filepath = file + ".csv",
  47.         analyzers = analyzers,
  48.         radix = automation.RadixType.HEXADECIMAL
  49.     )
  50.  
  51.     # Close file
  52.     capture.close()
  53.  
  54. # Close the connection to the Logic 2 application
  55. manager.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement