RingBuffer Component with Put/Get/Clear Events

8 Oct
Sometimes I have a good idea how to extend one of my Processor Expert components with an extra feature, but then I step back because why implementing more than I need at the moment? Until another user of the component simply asks for the same thing, and here we go: if one or more can take advantage of a feature, that’s definitely a strong argument to add it🙂. This happened with the RingBuffer Processor Expert component I’m using in many projects. And a reader of this blog asked to add some extra event methods: when an item is added or removed to the buffer.
RingBuffer used in USB Component with Extra EventsRingBuffer used in USB Component with Extra Events

Beside of the OnItemPut() and OnItemGet() events, I added an extra OnClear() event which gets called when the ring buffer Clear() method gets called. The events are disabled  by default not to add any overhead, and they can be enabled individually.

Using the CDE (Component Development Environment) of Processor Expert makes it very easy to such additional events: define the interface for the event, and then add the event code to the driver. Below shows it for the Put() method:

To check the details of the change, see the commit on GitHub.

So with using the new RingBuffer events in my USB stack, I can get application notifications for every byte received or sent, which is very useful.

The updated component will be available with the next *.PEupd release.

The IoT Zone is presented by WSO2. Download A Reference Architecture for the Internet of Things to learn more about the server-side and cloud architecture required to intereact with and manage IoT devices.

 

Published at DZone with permission of Erich Styger, author and DZone MVB. (source)

Source: http://architects.dzone.com/articles/ringbuffer-component

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: