Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] new isFifo() function #812

Closed
2bndy5 opened this issue Dec 2, 2021 · 5 comments · Fixed by #849
Closed

[Request] new isFifo() function #812

2bndy5 opened this issue Dec 2, 2021 · 5 comments · Fixed by #849
Assignees

Comments

@2bndy5
Copy link
Member

2bndy5 commented Dec 2, 2021

Currently, the library does not provide users with a way to examine the FIFO buffers statuses, with the exception of rxFifoFull(). In developing the CirPy lib, I have found the ability to examine the FIFO statuses extremely helpful when debugging a problem.

Proposal

Using 2 overloaded functions, we can expose info from the FIFO_STATUS register.

    /**
     * @param about_tx `true` focuses on the TX FIFO, `false` focuses on the RX FIFO
     * @return 
     * - `0` if the specified FIFO is neither full nor empty.
     * - `1` if the specified FIFO is empty.
     * - `2` if the specified FIFO is full.
     */ 
    uint8_t isFifo(const bool about_tx)
    {
        return static_cast<uint8_t>((read_register(FIFO_STATUS) >> (4 * about_tx)) & 3);
    }

    /** 
     * @param about_tx `true` focuses on the TX FIFO, `false` focuses on the RX FIFO
     * @param check_empty
     * - `true` checks if the specified FIFO is empty
     * - `false` checks is the specified FIFO is full.
     * @return A boolean answer to the question "is the [TX/RX] FIFO [empty/full]?"
     */
    bool isFifo(const bool about_tx, const bool check_empty)
    {
        return static_cast<bool>(is_fifo(about_tx) & _BV(!check_empty));
    }

Additional context

It is not my intention to make rxFifoFull() internally call isFifo(0, 0) as that would add to the code-size. Initially, I had planned to add these functions to the newer python wrapper in pyRF24, but I think it could be useful to those trying to debug the FIFO buffers' state in C++.

@2bndy5 2bndy5 self-assigned this Dec 2, 2021
@TMRh20
Copy link
Member

TMRh20 commented Dec 3, 2021 via email

@2bndy5
Copy link
Member Author

2bndy5 commented Dec 3, 2021

Yeah, I started organizing them by radio's feature in the CirPy lib's docs

@2bndy5
Copy link
Member Author

2bndy5 commented Dec 3, 2021

I could do some experimenting with the docs on my "improve-sphinx-docs" branch...

@TMRh20
Copy link
Member

TMRh20 commented Dec 3, 2021 via email

@2bndy5
Copy link
Member Author

2bndy5 commented Jul 9, 2022

I want to fit this in before the next release. I'll also be adding the model variant info to printPrettyDetails() (per aeb8b42#commitcomment-78046335 obervation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants