frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Error when creating and destroying device several times from the same process

Hi all,

We are working on a gstreamer pluging that supports inference with the NCS. We want to stop and destroy the device when the pipeline changes state to "Stoped", and create and open the device again when the state is set to "Playing". The problem is that these operations are called from the same process and the NCSDK C API has an unusual behavior with this case.

You can see what I'm talking about in the following example:

ncDeviceCreate(0, &device_handle);
for(i = 1; i < 16; i++) {
  ncDeviceOpen(device_handle);
  ncDeviceClose(device_handle);
  printf ("CHECKPOINT #%d: %s:%s:%d\n", i,  __FILE__, __FUNCTION__, __LINE__);
}

This code fails on the 16th call to ncDeviceOpen. I think this is caused because the "index" variable on the API increments with each call, and there is a limit set to 16 on xLink. If the API exposed some way to reset this index the code would not fail.

for(i = 1; i < 16; i++) {
  ncDeviceCreate(0, &device_handle);
  ncDeviceOpen(device_handle);
  ncDeviceClose(device_handle);
  ncDeviceDestroy (&device_handle);
  printf ("CHECKPOINT #%d: %s:%s:%d\n", i,  __FILE__, __FUNCTION__, __LINE__);
} 

This other code also fails, because it tries to open a new device on every iteration. What I really want is to open and close the same device over and over again. I can see that the C API has a function named resetAll that is called on the first ncDeviceCreate. If this function was exposed or there was a way to call ncDeviceCreate with reset, It would solve my problem.
Is there other way to solve this problem?
We are using NCSDK-2.05 with the NCS 1.

Thank you,
-Miguel.

Comments

Sign In or Register to comment.