• DepthAI
  • dai::DeviceBootloader::getAllAvailableDevices() not working in C++

I am having problems with dai::DeviceBootloader::getAllAvailableDevices() in C++. The returned vector of DeviceInfo objects seems to be corrupted. It also often comes back with no items or far too many (all with corrupted names).

When there are items, the first item returned gives me the IP address of the OAK PoE cam I have attached (I only have one). However getMxId() gives me the same thing not the expected MxId, so basically the same IP address. It should be a numerical Id number shouldn't it?

Thanks!

  • erik replied to this.

    Hello Malcs ,
    sorry about the delay. Could you provide some logs/screenshots of the far too many (corrupted names) objects returned?
    I believe OAK-POE appears twice as it's accessible by 2 IPs (static + dynamic). getMxId() doesn't yet return the MxID, but we are working to fix this.
    Thanks, Erik

    No problem Erik.

    So here's my code:

    If I uncomment the check on devs.size() then it never passes inside so the loop is not executed. Obviously this implies I'm getting an empty vector of dai::DeviceInfo.

    However, if I leave the line commented out and allow the loop to proceed, the first device name I get is the correct IP address for the camera. Furthermore, if I use the dai::DeviceInfo for this first entry I can connect to the camera successfully using dai::Device device(pipeline, info);.

    As you can see I keep looping until the device name is empty (just to see what I get) as the loop keeps going despite the fact that, from previous tests with the size check uncommented, I would expect the vector returned to have zero size.

    The subsequent device names vary but on the last try I got \x1 followed by \x17l@\x1 and then a zero length string. Sometimes I can keep going for longer. This may be because the loop should not be continuing past the first entry of course and it's just reading into other memory space. Hard to say. I just thought I'd mention it in case it gives a clue.

    But if the vector is empty then that loop should not execute so something looks to be corrupted somewhere as both the loop and the size check should be in agreement with each other.

    Hi again Erik. Bit of an update for you.

    I've been trying to work out what's going on here and I think I may have found the issue. I was looking at device.desc.name and noticed there were spurious looking characters from index 48 onwards.

    In XLinkPublicDefines.h there's this code:

    Now, XLINK_USE_MX_ID_NAME is not defined by default so XLINK_MAX_NAME_SIZE is set to 64. I have changed this so that XLINK_USE_MX_ID_NAME is defined and so XLINK_MAX_NAME_SIZE is set to 48 (because XLINK_MAX_MX_ID_SIZE is defined as 32).

    With this in place, when I call dai::DeviceBootloader::getAllAvailableDevices() I now get one item returned in the vector of dai::DeviceInfo. I wonder if the dll had XLINK_USE_MX_ID_NAME defined when it was built? I'm using the pre-built dlls not ones I've built myself (only because I struggled to build them without errors).

    Anyway, it's working now for me so all good 🙂