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

    Thank you for your honest feedback!

    As you may tell by now, gas sensing is more complex than it seems and requires expensive characterization and algorithm development to abstract raw sensor value into a useful metric (such as IAQ).

    If you have the time, I would be very interested in getting your feedback on the following points:

    How difficult was it and how long did it take to ...
    1) ...find the BSEC download page and integration guide within?
    2) ...understand the 2 software layers: open-source API and closed-source binary?
    3) ...integrate the BSEC sample code into your system? (please specify platform here)

    And finally: Which key information was missing to make the evaluation/integration faster in your design ?

    o_o

    kevyk
    Established Member

    I met some of the engineers at CES and explained how this should be done. They were more managers than engineers but said someone would eventually get back to me. We'll see...

    Basically it has to be simple to implment for the developer, right? That way the uptake and onboarding will be simple and fast and and developers can stay focused on their project instead of trying to implement the sensor. I had to incorporate 12 files and fix a few bugs and tweak a little Bosch code to finally get the BSEC to work properly. And even then, it's (assumed) PID loop is integrating too slowly for my use case so ultimately I probably won't be able to use it. 

    From Bosch's end, to keep it simple for us developers, Bosch should provide a single file or two that contains all the code necessary to get the BSEC running. Just off the top of my head: that file should have just a single entry point to initialize everything (including telling the BSEC who the data consumer is), another single entry point to set settings like sample rate, voltage, etc., a single entry point to get a current sample (as an override), a single entry point to start or pause the system which will utilize best practices for energy management, and a single entry point to stop and release all resources.

    This way, all the developer has to do is implement a few calls into their application to utilize the BSEC and they are good to go. This needs to be all well documented with plenty of examples to show how to properly utilize the BSEC, how to integrate the binary, some common pitfalls like memory issues, etc.

    That's how I would implement this.

    That all said, in an ideal scenario: everything the BSEC does should really be contained onboard the BME680 iself. It should not require a developer to implement libraries and such. There should just be I2C data transfers to get and set everythning needed by the BSEC. Right? That way NONE of the above has to be implemented by a developer and, again, they can just stay focused on their project.

    Hope that helps. Contact me offline (my info was input into the iPad at the CES show) if you'ld like more input...

    Take care, Kevin.

    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