# Trigger capture from command line

**URL:** <https://discuss.saleae.com/t/trigger-capture-from-command-line/297>\
**Category:** Logic 1.x  (Legacy) Software\
**Created:** [February 7, 2020, 1:51am UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297 "2020-02-07T01:51:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkagerer](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@rkagerer](https://discuss.saleae.com/u/rkagerer)\
**Post date:** [February 7, 2020, 1:51am UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297/1 "2020-02-07T01:51:04Z")

</div>

![heading](https://canada1.discourse-cdn.com/flex030/uploads/saleae/original/1X/bec20e15518180f05b1c6742440fa77202bf4959.png)

## [SalaeStart-v1.1.zip](https://tinyurl.com/SalaeStart-v1-1)

### Syntax:

> **salaestart.exe** &nbsp;[**-port** _\<port\>_] &nbsp;[**-delay** _\<ms\>_]
> 
> _\<port\>_ &nbsp;Port number configured in the Salae software (omit for default)  
> _\<ms\>_ &nbsp;&nbsp;&nbsp;Number of milliseconds to wait before commencing the capture (omit for none)

### Examples:

> **salaestart.exe**  
> Immediately trigger a new capture in an existing Salae Logic window

> **salaestart.exe -delay 5000**  
> Trigger a new capture after five seconds

> **powershell Start-Process -FilePath “C:\Tools\salaestart.exe” -ArgumentList ‘-delay 5000’**  
> Trigger a new capture after five seconds, without blocking subsequent script commands or build steps (for IDE’s like Atmel Studio 7).

### Requirements:

The link above includes a single-file Windows binary and **full C# source code**. It would probably be straightforward to port this to Linux or other platforms. If you’re still on XP, you’ll need [Microsoft .NET Framework 4.5](https://www.microsoft.com/en-ca/download/details.aspx?id=30653).

### More Info:

I have an embedded programming workflow that automatically builds my firmware and uploads it to my microcontroller when I hit a button in the IDE. I got tired of manually hitting the Start button each time to take a new capture and see the latest results.

So I wrote this simple command-line program that invokes the [Salae Socket API C# Wrapper](https://github.com/saleae/SaleaeSocketApi) to trigger a new capture (more [API docs here](https://support.saleae.com/saleae-api-and-sdk/socket-api)). You need to open Salae Logic first and set up your capture, but after that the existing application instance and capture tab are reused.

Be sure to enable the scripting socket server in the Logic application (under Options | Preferences | Developer):

![pref](https://canada1.discourse-cdn.com/flex030/uploads/saleae/original/1X/63055a9f821b9456e24e63717c9329bebdb4cdeb.png)

### Alternative:

After writing this I found out Salae has a simple [Python script](https://github.com/saleae/python-saleae-cli) that does something similar. Apparently it can be used like this:

> **python saleae\_cli.py --capture-count 5 --capture-duration 0.1**

I kept this post up anyway, for other Windows luddites who don’t want to wade into Python.

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [February 8, 2020, 12:33am UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297/2 "2020-02-08T00:33:57Z")

</div>

This is awesome! I’m sure this will help out a lot of users. As discussed earlier over email, I’ve posted this under Third-Party Implementations below:  
[https://support.saleae.com/saleae-api-and-sdk/socket-api](https://support.saleae.com/saleae-api-and-sdk/socket-api)

Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![sudheer.gaddipati](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@sudheer.gaddipati](https://discuss.saleae.com/u/sudheer.gaddipati)\
**Post date:** [June 1, 2020, 12:28pm UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297/3 "2020-06-01T12:28:22Z")

</div>

Hi All,

How can we stop it automatically?

My requirement is something like as below,

Start Saleae  
Run some other Windows Executable  
Stop Saleae.

Regards,  
Sudheer

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [June 1, 2020, 8:31pm UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297/4 "2020-06-01T20:31:30Z")

</div>

This is possible with our [Saleae Socket API](https://support.saleae.com/saleae-api-and-sdk/socket-api) in Python.

The Python wrapper is [here](https://github.com/ppannuto/python-saleae).

Here’s the code for a very simplified automation script of what you need using the Python wrapper.

import saleae  
import time  
s = saleae.Saleae()  
s.set\_capture\_seconds(5)  
s.capture\_start()  
time.sleep(1)  
s.capture\_stop()

You could also use our ready made [Python script command line utility](https://github.com/saleae/python-saleae-cli) as well.

Is this the functionality you need?

---

<div class="post-metadata">

**Author:** ![rajiv.onkar](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rajiv.onkar](https://discuss.saleae.com/u/rajiv.onkar)\
**Post date:** [August 31, 2021, 8:30pm UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297/5 "2021-08-31T20:30:34Z")

</div>

Could you please add commands to:

- Save the raw capture (logic data file)
- Save the CSV file
- Exit/close the app

Thanks  
Rajiv

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [August 31, 2021, 10:50pm UTC](https://discuss.saleae.com/t/trigger-capture-from-command-line/297/6 "2021-08-31T22:50:20Z")

</div>

@rajiv.onkar Thanks for writing in! In case you are referring to our [Socket API Automation Utility](https://support.saleae.com/saleae-api-and-sdk/socket-api), you can refer to the commands below:

> - Save the raw capture (logic data file)

[save\_to\_file](https://github.com/saleae/SaleaeSocketApi/blob/master/Doc/Logic%20Socket%20API%20Users%20Guide.md#save-to-file)

> - Save the CSV file

[export\_data2](https://github.com/saleae/SaleaeSocketApi/blob/master/Doc/Logic%20Socket%20API%20Users%20Guide.md#export-data-2)

> - Exit/close the app

[exit](https://github.com/saleae/SaleaeSocketApi/blob/master/Doc/Logic%20Socket%20API%20Users%20Guide.md#exit)

Hope this helps!
