BSEC library design seems to prohibit multiple instances within one process

hi folks,

I am not sure, if my approach is a good one, or if I simply do not fully understand how things work, yet. It would be great, if you could give me some hints to get it working πŸ™‚


In my use case I want to calculate the iAQ values of multiple BME680 sensors on a RaspberryPi or x86. The sensors are running on very low end Arduinos (328p) and send the raw data to the x86/RPi.

For this, I created an array of multiple BSEC objects, which I feed whenever new raw data arrive from the sensors:

My_BSEC bsec[2];      // Array of My_BSEC, a class wrapping and managing the bsec functions (e.g. bsec_set_configuration, bsec_update_subscription, bsec_sensor_control, bsec_do_steps, ...)

bsec[bsecId].calculateData(input);   // one sensor is fed with new data


With following input:

bsec[0].calculateData(F105C79AB0000014279641C1DE6847DB23704231A17048); // sensor one is fed with new data
bsec[1].calculateData(F105C79AB0000014279641C1DE6847DB23704231A17049); // sensor two is fed with slightly different data, but the same timestamp


... BSEC returns warning 4Β 

// from bsec_datatypes.h: BSEC_W_DOSTEPS_TSINTRADIFFOUTOFRANGE = 4, /*!< Duplicate timestamps passed to bsec_do_steps() */)

Β 

This indicates, that altough there are two separate instances of My_BSEC in my code, the same bsec data structures are used in the background/ external library. The BSEC library has only one context.

Am I mistaken or is this wanted or expected behaviour?
Some code is attached (sorry for using the Qt framwork, it is not really a minimal example)

Best Regards,

Martin

My_BSEC_Process_Minimal.zip
4.94KB
Best reply by mkaiser

hi,Β 

thank you both for your replies. I guess I will stick to the one process one sensor approach / workaround πŸ˜•

View original
3 replies
Resolved