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

Fix ring buffer compilation error #994

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kchugalinskiy
Copy link

Current version of idf provides alternative naming for ring buffer type. see this for details

@chegewara
Copy link
Collaborator

This cant be merged since it will brake v3.3 compatibility. Maybe to different branch, not master.

@h2zero
Copy link
Contributor

h2zero commented Aug 3, 2020

I've seen this come up a lot, I thought I'd share the fix I used in NimBLE library.

FreeRTOS.h

class Ringbuffer {
public:
#ifdef ESP_IDF_VERSION //Quick hack to detect if using IDF version that replaced ringbuf_type_t
    Ringbuffer(size_t length, RingbufferType_t type = RINGBUF_TYPE_NOSPLIT);
#else
    Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
#endif
    ~Ringbuffer();

    void*    receive(size_t* size, TickType_t wait = portMAX_DELAY);
    void     returnItem(void* item);
    bool     send(void* data, size_t length, TickType_t wait = portMAX_DELAY);
private:
    RingbufHandle_t m_handle;
};

FreeRTOS.cpp

/**
 * @brief Create a ring buffer.
 * @param [in] length The amount of storage to allocate for the ring buffer.
 * @param [in] type The type of buffer.  One of RINGBUF_TYPE_NOSPLIT, RINGBUF_TYPE_ALLOWSPLIT, RINGBUF_TYPE_BYTEBUF.
 */
#ifdef ESP_IDF_VERSION //Quick hack to detect if using IDF version that replaced ringbuf_type_t
Ringbuffer::Ringbuffer(size_t length, RingbufferType_t type) {
#else
Ringbuffer::Ringbuffer(size_t length, ringbuf_type_t type) {
#endif
    m_handle = ::xRingbufferCreate(length, type);
} // Ringbuffer


Ringbuffer::~Ringbuffer() {
    ::vRingbufferDelete(m_handle);
} // ~Ringbuffer

COM8 added a commit to COM8/esp32-snippets that referenced this pull request Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants