RingBuffer | A simple ring buffer for ISR-task communication

 by   lamarrr C++ Version: Current License: No License

kandi X-RAY | RingBuffer Summary

kandi X-RAY | RingBuffer Summary

RingBuffer is a C++ library typically used in Internet of Things (IoT), Arduino applications. RingBuffer has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

A ring/cyclic buffer suitable for ISR-Task communication. A C++ 17, templated and stack allocated ring buffer for continuous i/o.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              RingBuffer has a low active ecosystem.
              It has 6 star(s) with 1 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              RingBuffer has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of RingBuffer is current.

            kandi-Quality Quality

              RingBuffer has no bugs reported.

            kandi-Security Security

              RingBuffer has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              RingBuffer does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              RingBuffer releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of RingBuffer
            Get all kandi verified functions for this library.

            RingBuffer Key Features

            No Key Features are available at this moment for RingBuffer.

            RingBuffer Examples and Code Snippets

            stream type:
            npmdot img1Lines of Code : 27dot img1no licencesLicense : No License
            copy iconCopy
            /* Create a ring buffer that stores the last 100 records. */
            var bunyan = require('bunyan');
            var ringbuffer = new bunyan.RingBuffer({ limit: 100 });
            var log = bunyan.createLogger({
                name: 'foo',
                streams: [
                    {
                        level: 'info',
              

            Community Discussions

            QUESTION

            Writing audio stream to circular buffer but Segmentation error reading value
            Asked 2021-Mar-07 at 17:09

            I very new concepts of audio processing and have a basic knowledge of C++, my end goal is to create a means to measure harmonic distortion on line-in audio; my thoughts are to write audio-in stream to a circular buffer, then read from the circular buffer to an FFT function; from the FFT data I can workout audio distortion.

            So far I'm using Portaudio to write streamed audio to the circular buffer from it's streaming input callback; I've created a Thread that checks if there's any data in the circular buffer, if there is data, read it into a temporary buffer. As a means of a simple test, I'm merely echo'ing the number of elements to read from the circular buffer, this works but after a second or so, produces an incorrect value for 'read elements available' (18446744073709542400) followed by a Segmentation error; sample output and my code below:

            ...

            ANSWER

            Answered 2021-Mar-07 at 17:09

            RingBuffer::readAvailable() is returning a small negative number as a size_t. Since size_t is an unsigned type and because you're using %lu in the printf, it's being displayed as though it's a huge unsigned long. (Somehow your output has extra digits.)

            It's possible RingBuffer has a bug. It seems to assume that that tail index will always be less then or equal to the head index. I'm not an expert in the memory ordering constraints used in lockless code, but it looks to me like it could be a synchronization problem with when it reads the head and tail to compute the amount available.

            Source https://stackoverflow.com/questions/66515015

            QUESTION

            AvSetMmThreadCharacteristicsW for UWP
            Asked 2021-Feb-19 at 14:31

            I'm working on a WASAPI UWP audio application with cpp/winrt which needs to take audio from an input and send it to an output after being processed.

            I want to set my audio thread characteristics with AvSetMmThreadCharacteristicsW(L"Pro Audio", &taskIndex), but I just noticed this function (and most of avrt.h) is limited to WINAPI_PARTITION_DESKTOP and WINAPI_PARTITION_GAMES.

            I think I need this because when my code is integrated into my UWP app, the audio input is full of discontinuity, and I have no issue in my test code which uses the avrt API.

            Is there another way to configure my thread for audio processing?

            Edit: here is my test program https://github.com/loics2/test-wasapi. The interesting part happens in the AudioStream class. I can't share my UWP app, but I can copy as is these classes into a Windows Runtime Component.

            Edit 2: here's the audio thread code :

            ...

            ANSWER

            Answered 2021-Feb-19 at 14:31

            @IInspectable was right, there's something wrong with my code : the audio processing is done by a library which then calls callbacks with some results.

            In my callback, I try to raise a winrt::event, but it sometimes takes more than 50ms. When it happens, it blocks the audio thread, and creates discontinuity...

            Source https://stackoverflow.com/questions/66211356

            QUESTION

            Where is the pointer pointing?
            Asked 2020-Dec-25 at 08:46

            This is the defination for my class.

            ...

            ANSWER

            Answered 2020-Dec-25 at 08:39

            rings.get():

            This is getting raw pointer from rings which gives you RingBuffer *

            rings_->ring1_.get():

            I suppose you mean rings->ring1_.get(), which first dereferences rings and then get raw pointer from member ring1_. It is the same with rings.get()->ring1_.get(). The final result is a RingBufferLock *

            Source https://stackoverflow.com/questions/65446498

            QUESTION

            Reconstruct USB CDC stream
            Asked 2020-Dec-07 at 20:36

            I have an USB CDC interface on a STM32 to which I send messages which can be longer than one single chunk of 64 bytes. This means I get multiple callbacks of CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) where I would have to copy the incoming data into another buffer (e.g. ringbuffer).

            My problem is, how do I know if data belongs to a new message or is a continuation of a previous (larger) one? What I can tell is that if less than 64 bytes arrived I can assume that the message is complete. But if exactly 64 bytes are in the buffer I'd technically have to wait if there are no more messages coming. And even then, how long do I have to wait to not mix them up with a new one?

            ...

            ANSWER

            Answered 2020-Dec-07 at 20:36

            USB CDC and all serial protocols derived from RS-232 implement stream-based communication, i.e. a potentially endless stream of bytes.

            They do not implement message-based communication. Therefore, they have no concept of messages, and no concept of message start and message end.

            The lower layers of USB are message based. So you might observe patterns that look like a message-based communication. You might also think that USB CDC is message based because the STM32cube framework exposes a USB API that will deliver more data whenever a low-level USB message has arrived.

            But this behavior can only be observed if small chunks of data are sent with pauses in-between and if the USB bus is mostly idle. It collapses if speed is increased or the USB bus becomes busier.

            Then your PC will start to merge chunks of data. This can be easily tested by sending 100 times 10 bytes as fast as possible. The first 10 bytes are likely sent in its own packet. But the remaining data will be merged and sent as packets of 64 bytes (except for the last few bytes).

            So if you want to have a message-oriented protocol on top of stream-oriented protocol, the two typical approaches are:

            • Use a delimiter between messages. As an example: If you have a human-readable text protocol, a linefeed is often used as the delimiter. Once you encounter a linefeed character, you know you have a complete message (i.e. line).

            • Use a length indicator at the end of the message. This is useful for binary protocols. The first two bytes could contain the message length in bytes, encoded as a 16-bit number. So will be obvious when the message is complete.

            Also note that a received packet can contain several message, or the end of a message and the start of the next message.

            Source https://stackoverflow.com/questions/65188361

            QUESTION

            How to access the value of a struct pointer from outsite of the allocatiing function?
            Asked 2020-Nov-08 at 09:50

            I use the file where I declare and init a struct

            ...

            ANSWER

            Answered 2020-Nov-08 at 09:50

            The function ringBufferInit does not make a sense. In the function testRingBufferPushPopSingle you already created an object of the type RingBuffer.

            Source https://stackoverflow.com/questions/64736091

            QUESTION

            Move Assignment of a Vector Element not working, Copy Assignment is called instead
            Asked 2020-Nov-02 at 07:34

            I have a class that is not default-constructable, copy-constructable or copy-assignable. It is move-constructable and move-assignable.

            ...

            ANSWER

            Answered 2020-Nov-02 at 07:34

            Your problem lies in the absence of a move assignment operator. Looking at your class, you have defaulted this operation.

            Unfortunately, = default means that you get the default behavior, not that this method is created. This is really confusing.

            To make this easier to spot I've recently enabled the following clang warning as error on the code base I'm working on: https://clang.llvm.org/docs/DiagnosticsReference.html#wdefaulted-function-deleted (Maybe GCC has something similar)

            Long story short, if you have a base class or member that doesn't allow this operation, your class can't default this.

            In this case, you have a reference as a member, as one can't reassign a reference, one can't provide the assignment operator.

            Possible workarounds are: store as a raw pointer, or store as std:: reference_wrapper.

            PS: please make your deleted methods public and use = delete, it will give much better error messages

            Source https://stackoverflow.com/questions/64640270

            QUESTION

            Create generic ArrayList with initialCapacity in generic class
            Asked 2020-Aug-20 at 16:19

            I'm createing a generic ring buffer and I would like to use array list as internal storage for data and I'd like to allocate array list with defined capacity.

            This is an example using Kotlin ArrayList:

            ...

            ANSWER

            Answered 2020-Aug-20 at 16:19

            It's possible to do it this way:

            Source https://stackoverflow.com/questions/63501214

            QUESTION

            Why can't I call my struct Semaphore methods?
            Asked 2020-Aug-18 at 10:30

            I am trying to input lowercase char and to add it to in.buffer, the other thread should read from in.buffer and make it lowercase and send to out.buffer, and the last one should read from out.buffer and print it.

            I am getting error: expected identifier before numeric constant Semaphore m_free(10); error: invalid use of member function ‘Semaphore RingBuffer::m_free(int)’

            Why is that?

            Thanks

            ...

            ANSWER

            Answered 2020-Aug-18 at 10:30

            You can't "call" anything inside a struct. A struct contains definitions of its members, not code.

            You can initialize a member in a constructor:

            Source https://stackoverflow.com/questions/63465877

            QUESTION

            Unable to animate THREE.js property using React Spring
            Asked 2020-Jul-15 at 19:34

            I would like to have React Spring animate a property of a material in Three.js.

            However, I'm getting an error when I try to do so:

            ...

            ANSWER

            Answered 2020-Jul-15 at 19:34

            args is for constructor arguments. if you change an arg, the object will re-instanciate, as in: is the same as new Foo(123). animating something that constructs 60fps is a no go, and it's also not possible with react-spring. in praxis you should find means to mutate things as fast as possible, if you can get away with it animate scale, or make a ring shader whose uniforms you animate.

            Source https://stackoverflow.com/questions/62881370

            QUESTION

            Why does VecDeque's tail member point to the first element and not the last element?
            Asked 2020-Jun-16 at 09:30

            The VecDeque declaration:

            ...

            ANSWER

            Answered 2020-Jun-16 at 09:30

            Spelunking a bit finally led me to the PR in which huonw has the exact same reaction you did:

            I find this mapping weird: it seems like tail should be head (as in, that element is the head of the ringbuf) and vice versa.

            What's the motivation for having them this way around?

            to which the PR author replies that it follows the linux kernel terminology. Which never explains why it's using the terms it does.

            The PR also specifically notes that

            lo, nelts [nb: the old names for these fields] are replaced by a more traditional head and tail

            So the answer seems to be "because it follows traditional nomenclature". Might be that one original paper used these terms and it stuck, or could be happenstance. The internets certainly don't seem interested in this question as while the terms show up aplenty explanations don't.

            The linux circular buffers document was only added in 2010 so it would be documenting the existing state of affairs, and struct circ_buf called it that when the Git repo was created back in 2005, so if you want more you'd have to dive into the historical archive and hope there are references there.

            Source https://stackoverflow.com/questions/62391711

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install RingBuffer

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/lamarrr/RingBuffer.git

          • CLI

            gh repo clone lamarrr/RingBuffer

          • sshUrl

            git@github.com:lamarrr/RingBuffer.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link