LibreSolar / bms-firmware

Firmware for LibreSolar BMS boards based on bq769x0, bq769x2 or ISL94202
https://libre.solar/bms-firmware/
Apache License 2.0
146 stars 67 forks source link

Thingset Synchronization with bq76952 Initialization #63

Open Ananyaaynana opened 5 months ago

Ananyaaynana commented 5 months ago

Description:

Feasibility of using semaphores to synchronize the execution of the Thingset with the initialization of the bq76952. Currently, when the live publication is enabled thingset executes before bq76952 is initialized. This leads to the publication of incorrect values.

Current Approach:

A few changes made by us to the code currently employ semaphores to ensure data consistency between the PC-provided current, voltage, and temperature inputs, and the SOC (State of Charge) output received from the board. This approach guarantees that the Thingset operates with synchronized data sets.

Proposed Synchronization with bq76952:

Would a semaphore-based synchronization method ensure the Thingset only starts execution after the bq76952 has finished initializing be feasible? This would prevent the Thingset from using potentially invalid or incomplete data during its initial execution phase.

Can semaphores be effectively utilized to achieve synchronization between the Thingset and bq76952 initialization? Are there any potential drawbacks or limitations to this approach?

martinjaeger commented 5 months ago

That's a very good point.

I don't think we need semaphores for that, but we could integrate something like a trigger into the ThingSet Zephyr SDK that inhibits publication of messages before valid data was read.

Will mark this as an enhancement.