Skip to content

Logic for Accelerometer.py #8

@8ohamed

Description

@8ohamed

This is how I think we can implement the logic we discussed in Accelerometer.py
In the init() method:

We set the maximum size of the FIFO, which should be passed from driver.py.
By using deque(maxlen=fifo_size), we ensure that the oldest samples are deleted when the FIFO is full.
We use the concurrent package to set up a thread pool executor with two threads:
    The first thread runs the MQTT client.

In on_message():

We run the second thread, which executes process_and_store().

In process_and_store():

We extract the data and append it to the FIFO.

In read():

It takes the requested number of samples as input and checks if there is enough available data.
    If there is enough data, it returns the data as an ndarray with status 1.
    If there isn't enough data, it returns the available data with status 0.

Question:
@prasadtalasila
Should the size of sample requested from the read() also be initialized in driver.py or should it be passed as input for read()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions