labstreaminglayer / App-LabRecorder

An application for streaming one or more LSL streams to disk in XDF file format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running Lab Recorder CLI from an external process records duplicate streams.

Gnarlywhale opened this issue · comments

I encountered this issue when starting LabRecorderCLI from an external C# program that I'm working on (similar to @agricolab's project). I am able to start LabRecorderCLI with the file name and target streams as a separate process, but the resulting file contains multiple copies of the same stream.

To duplicate:

  • create a shortcut for LabRecorderCLI.exe

  • Right click the shortcut and select properties

  • Under the "Shortcut" tab, change the "Target" to include the arguments of multiple streams:
    "C:\Users\Deep Thought\source\repos\LabRemote\LabRemote\bin\Debug\LabRecorderCLI.exe" trialName.xdf 'name="Keyboard"' 'name="LabRemote"'
    image

  • Run the shortcut:
    image

Note that there appears to be 4 streams while there should only be 2.

Frustratingly, this error doesn't occur when starting the program directly from command line:
image

Any idea what's going on?

The only difference I could imagine is that the arguments are parsed differently depending on whether you're using powershell or launching from a shortcut.

A short-term solution is to create a shortcut to a powershell script. Can you verify that works?

I don't know how to debug this. I know how to put a break mark and debug the process when launched from within Visual Studio. I'm not good enough with Visual Studio to know how to get it to monitor for any process named LabRecorderCLI then attach its debugger as soon as it's found. If I knew how to do that, I would debug the arguments that get passed into the program when it's run from a shortcut or from a powershell prompt to see what's different.

You're intuition was correct and clued me in on a fix!

The key was noticing that running the shortcut launched Lab Recorder CLI using Command Prompt instead of Powershell (which is what I had used to build and test the initial call). It turns out C#'s Process.Start() method processes arguments the same as the Command Prompt, so I needed to change how I was launching Lab Recorder CLI:
startInfo.Arguments = "trial_1.xdf \"name=\"\"Keyboard\"\"\" \"name=\"\"LabRemote\"\"\" "

Thanks for the insight 👍