ei_run_impulse_check_canceled()

EI_IMPULSE_ERROR ei_run_impulse_check_canceled();

Brief: Check if the sampler thread was canceled, use this in conjunction with the same signaling mechanism as ei_sleep

Location: edge-impulse-sdk/porting/ei_classifier_porting.h

Blocking: Depends on user implementation

Description:
ei_run_impulse_check_canceled() is declared internally in the Edge Impulse SDK library, and the function must be defined by the user.

If you are using a multi-threaded approach to sample while running inference, you will need to implement this function to check if the sampling thread is still running. See this guide to learn more about using a separate thread for sampling data.

If you are not using separate threads for sampling and inference, then this function should simply return EI_IMPULSE_OK. For example:

__attribute__((weak)) EI_IMPULSE_ERROR ei_run_impulse_check_canceled() {
    return EI_IMPULSE_OK;
}

Returns:
Error code as defined by EI_IMPULSE_ERROR enum. Will be EI_IMPULSE_OK if the function completed successfully.

Example:
The following examples demonstrate possible implementations of this function for various platforms. Note the __attribute__((weak)) in most of the definitions, which means that a user could override the implementation elsewhere in the program: