Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check if the bladerf* dev is valid #918

Closed
t3hk4t opened this issue Apr 27, 2023 · 2 comments
Closed

How to check if the bladerf* dev is valid #918

t3hk4t opened this issue Apr 27, 2023 · 2 comments

Comments

@t3hk4t
Copy link

t3hk4t commented Apr 27, 2023

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?

@rghilduta
Copy link
Collaborator

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.

@t3hk4t
Copy link
Author

t3hk4t commented May 2, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants