Items with no label
3338 Discussions

pipe.start(cfg) fails with rs2::wrong_api_call_sequence_error

vicky
Beginner
4,107 Views

Hello

 

When I start the pipe using start() without a configuration, everything works fine. But if I start the pipe with the following configuratopn, it fails

// Camera D415

// platform: linux on jetson

 

  rs2::config cfg;

  cfg.enable_stream(RS2_STREAM_INFRARED, 0);

  cfg.enable_stream(RS2_STREAM_INFRARED, 1);

  printf("starting pipe\n");

  pipe.start(cfg);

  printf("pipe started\n");

 

Output

starting pipe

terminate called after throwing an instance of 'rs2::wrong_api_call_sequence_error'

 what(): Device already streaming!

Aborted (core dumped)

 

I made sure no other program is using the camera

 

Any ideas what could be wrong ?

0 Kudos
1 Solution
MartyG
Honored Contributor III
3,795 Views

My understanding is that ​rs2::pipeline pipe and the pipe start instruction should always be declared after the cfg lines are completed, like in the example code quoted.

View solution in original post

0 Kudos
3 Replies
MartyG
Honored Contributor III
3,795 Views

Following through the sequence of your code and the debug statements that are printed, it looks as though the program is failing when the pipe.start(cfg) line is reached, meaning that it never reaches the debug print statement "pipe started".

 

In the SDK's example script in its API How To doc, there is an rs2::pipeline pipe; statement preceding the pipeline start instruction, which your script doesn't have.

 

rs2::config cfg;

cfg.enable_stream(RS2_STREAM_INFRARED, 0);

cfg.enable_stream(RS2_STREAM_INFRARED, 1);

rs2::pipeline pipe;

pipe.start(cfg);

0 Kudos
vicky
Beginner
3,795 Views

@MartyG The pipe was declared before the snippet. Otherwise the code wouldn't have compiled. I made a bare-bones version of the project and verified that the rs2::config is what is causing the exception. I have pasted below the test program in its entirely

 

#include <stdio.h>

#include <signal.h>

#include <unistd.h>

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API

 

bool signal_recieved = false;

 

void sig_handler(int signo)

{

    if( signo == SIGINT )

    {

        printf("received SIGINT\n");

        signal_recieved = true;

    }

}

 

int main( int argc, char** argv )

{

    if( signal(SIGINT, sig_handler) == SIG_ERR )

        printf("\ncan't catch SIGINT\n");

 

  rs2::pipeline pipe;

 

  // Start streaming with only right and left IR imagers

  rs2::config cfg;

  cfg.enable_stream(RS2_STREAM_INFRARED, 0);

  cfg.enable_stream(RS2_STREAM_INFRARED, 1);

 

  printf("starting pipe\n");

  pipe.start(cfg); // Doesn't work

// pipe.start(); // works

  printf("pipe started\n");

return 0;

}

 

0 Kudos
MartyG
Honored Contributor III
3,796 Views

My understanding is that ​rs2::pipeline pipe and the pipe start instruction should always be declared after the cfg lines are completed, like in the example code quoted.

0 Kudos
Reply