Skip to content

Fix ring buffer compilation error#994

Open
kchugalinskiy wants to merge 4 commits intonkolban:masterfrom
kchugalinskiy:master
Open

Fix ring buffer compilation error#994
kchugalinskiy wants to merge 4 commits intonkolban:masterfrom
kchugalinskiy:master

Conversation

@kchugalinskiy
Copy link
Copy Markdown

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

@chegewara
Copy link
Copy Markdown
Collaborator

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

@h2zero
Copy link
Copy Markdown
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