Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code

Home Page:http://nuand.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to check if the bladerf* dev is valid

t3hk4t opened this issue · comments

Hello, i am trying to figure out how to validate whether the *dev pointer is valid. The struct is as follows:

struct bladerf {
    /* Handle lock - to ensure atomic access to control and configuration
     * operations */
    MUTEX lock;

    /* Identifying information */
    struct bladerf_devinfo ident;

    /* Backend-specific implementations */
    const struct backend_fns *backend;

    /* Backend's private data */
    void *backend_data;

    /* Board-specific implementations */
    const struct board_fns *board;

    /* Flash architecture */
    struct bladerf_flash_arch *flash_arch;

    /* Board's private data */
    void *board_data;

    /* XB attached */
    bladerf_xb xb;

    /* XB's private data */
    void *xb_data;
};

I do not see any file descriptor that could be monitored with ,for example, epoll. Also i do not seem to notice any backend_fns which could help me.

Is there any way i could do this?

The return value of bladerf_open() should be checked to ensure that the struct bladerf is valid. I would strongly advise against trying to parse memory of a potentially uninitialized pointer.

Thanks for the reply. What i meant is, I want to check for sudden disconnects asynchronously. That is, I want to monitor the state of the dev pointer after opening it.

For now, I think, the only way to do it is to occasionally ask for serial number or something like that to get the potential error return.
What i was asking is, i want to know if you have any inbuilt function to check if device has been disconnected and dev has to be re-opened. I do not seem to find anything like that