Created
February 28, 2023 11:17
-
-
Save Matjaz-B/362f8158c802725df9ed67079223f323 to your computer and use it in GitHub Desktop.
Using saleae API capture and store logic data indefinitly every x seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from saleae import automation | |
from datetime import datetime | |
import os | |
import os.path | |
manager = automation.Manager.connect(port=10430) | |
while(True): | |
# record 0-6 channels | |
# 5 msps | |
# 1.2 voltage | |
device_configuration = automation.LogicDeviceConfiguration( | |
enabled_digital_channels=[0, 1, 2, 3, 4, 5, 6], | |
digital_sample_rate=5_000_000, | |
digital_threshold_volts=1.2, | |
) | |
# Record XX seconds of data before stopping the capture | |
capture_configuration = automation.CaptureConfiguration( | |
capture_mode=automation.TimedCaptureMode(duration_seconds=(1*60)) # EDIT! | |
) | |
print(f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} Starting capture ....') | |
capture = manager.start_capture( | |
device_id='F4241', # EDIT | |
device_configuration=device_configuration, | |
capture_configuration=capture_configuration) | |
capture.wait() | |
print(f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} Done. Storing....') | |
# Store output in a timestamped directory | |
capture_filepath = os.path.join(os.getcwd(), f'output-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.sal') | |
capture.save_capture(filepath=capture_filepath) | |
capture.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment