Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    Bug in BSEC BSEC_integration.c

    Bug in BSEC BSEC_integration.c

    kevyk
    Established Member

    Hi,

    I'd like confirmation of a probable bug in the BSEC_integration.c file, in the bsec_iot_init function. It reads:

    return_values_init bsec_iot_init(uint8_t deviceAddr, float sample_rate, float temperature_offset, bme680_com_fptr_t bus_write, bme680_com_fptr_t bus_read, sleep_fct sleep, state_load_fct state_load, config_load_fct config_load)
    {
        return_values_init ret = {BME680_OK, BSEC_OK};
        bsec_library_return_t bsec_status = BSEC_OK;
        
        uint8_t bsec_state[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};    // <--- BUG
        uint8_t bsec_config[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
        uint8_t work_buffer[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};   // <--- BUG
        int bsec_state_len, bsec_config_len;

    and I'm pretty sure it should read:

    return_values_init bsec_iot_init(uint8_t deviceAddr, float sample_rate, float temperature_offset, bme680_com_fptr_t bus_write, bme680_com_fptr_t bus_read, sleep_fct sleep, state_load_fct state_load, config_load_fct config_load)
    {
        return_values_init ret = {BME680_OK, BSEC_OK};
        bsec_library_return_t bsec_status = BSEC_OK;
        
        uint8_t bsec_state[BSEC_MAX_STATE_BLOB_SIZE] = {0};     // <--- BUG fixed
        uint8_t bsec_config[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
        uint8_t work_buffer[BSEC_MAX_WORKBUFFER_SIZE] = {0};    // <--- BUG fixed
        int bsec_state_len, bsec_config_len;

    Please let me know if this is indeed a bug. My app was crashing before the bug fix and is working now after the above fix.

    It was crashing because bsec_iot_init was calling state_load with the wrong buffer size and the subsequent call to bsec_set_state was failing.

    If this is confirmed to be a bug, how is it possible that no one else has discovered and reported this problem in the past two years?

    Thank you,

    Kevin

    6 REPLIES 6

    shellywang
    Occasional Contributor

    Hi Kevin,

    Thank you very much for feedback this informtion to us.It is already sent back to the internal team for analysis.

    kevyk
    Established Member

    Thanks Shelly. Could you let me know if the software engineers confirm this is infact a bug? I'm pretty sure it is. Thank you!

    handytech
    Community Moderator
    Community Moderator

    You are correct, work buffer arrays should be of size BSEC_MAX_WORKBUFFER_SIZE, and state arrays (respectively config arrays) should be of size BSEC_MAX_STATE_BLOB_SIZE (respectively BSEC_MAX_PROPERTY_BLOB_SIZE).

    kevyk
    Established Member

    OK. Thanks. I'm a little puzzled why Bosch has made it such a challenge to integrate this sensor into a design. As it stands now, I've had to "plug in" 12 Bosch sensor C files into my application just to read the IAQ. I would think it should be way easier to implement this part: One or two files with just a few entry points to call into the functions, or better yet just read the IAQ right off the sensor itself after it calculates the value... I have things working finally but it has taken way more time than I think it should have. Just a friendly note from out here in the field...

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist