Compilation Error when moving from Pro Micro to Due

Hi all, This is my first post so please feel free to critique the formatting etc.

Background: I do a bit of sim racing and am building a button box where I want to use Sim Hub's base code for arduino and expand on it. Sim Hub only supports some of the arduinos but I would like to use Arduino Due as it has the most pins and also allows using Joystick library for native HID support as a game controller. However, Due is not an option in Sim Hub configurator. Sim Hub software has a GUI configurator which allows configuring various inputs and outputs of the arduino, which can then be directly uploaded to the arduino. You can also configure everything and open the sketch allowing you to modify the code and change the arduino target.

Setup: I have configured everything for Arduino Leonardo within the Sim Hub GUI and then opened up the code in the Arduino IDE to change the arduino from Leonardo to Due (since Due is not available within Sim Hub GUI). However,

Problem When I compile the code for Leonardo or Pro Micro, everything compiles fine. However, when I select Due, I get an error:

Simhub\Arduino\DisplayClientV2\RingBuffer.h:50:61: error: 'RingBuffer' is not a template type
 template <typename rg_element_t, uint8_t __maxSize__> class RingBuffer {
                                                             ^

This is the first error that comes up. There are more errors but they all relate to this first one (I believe). Happy to post them all if needed, just didn't want to clutter the post as it's long enough as it is.

The code to which this error is pointing:

#ifndef __RINGBUFFER_H__
#define __RINGBUFFER_H__

#include <Arduino.h>

template <typename rg_element_t, uint8_t __maxSize__>
class RingBuffer
{
private:
  rg_element_t mBuffer[__maxSize__];
  uint8_t mReadIndex;
  uint8_t mSize;

  uint8_t writeIndex();

public:
  /* Constructor. Init mReadIndex to 0 and mSize to 0 */
  RingBuffer();
  /* Push a data at the end of the buffer */
  bool push(const rg_element_t inElement) __attribute__ ((noinline));
  /* Push a data at the end of the buffer. Copy it from its pointer */
  bool push(const rg_element_t * const inElement) __attribute__ ((noinline));
  bool push(const rg_element_t* inElements, uint8_t length) __attribute__((noinline));
  /* Push a data at the end of the buffer with interrupts disabled */
  bool lockedPush(const rg_element_t inElement);
  /* Push a data at the end of the buffer with interrupts disabled. Copy it from its pointer */
  bool lockedPush(const rg_element_t * const inElement);
  /* Pop the data at the beginning of the buffer */
  bool pop(rg_element_t &outElement) __attribute__ ((noinline));
  /* Pop the data at the beginning of the buffer */
  bool pop() __attribute__((noinline));
  /* Pop the data at the beginning of the buffer with interrupt disabled */
  bool lockedPop(rg_element_t &outElement);
  /* Return true if the buffer is full */
  bool isFull()  { return mSize == __maxSize__; }
  /* Return true if the buffer is empty */
  bool isEmpty() { return mSize == 0; }
  /* Reset the buffer  to an empty state */
  void clear()   { mSize = 0; }
  /* return the size of the buffer */
  uint8_t size() { return mSize; }
  /* return the maximum size of the buffer */
  uint8_t maxSize() { return __maxSize__; }
  /* access the buffer using array syntax, not interrupt safe */
  rg_element_t &operator[](uint8_t inIndex);
};

Why does this not compile correctly for Due?

Any help is much appreciated.

Welcome to the forum

Please post your full sketch so that the problem can be seen in context

Thank you! The sketch comes with over 50 header files. How do I best post it so it can be seen in context?

I think it is a name clash, Due core defines a class RingBuffer as well : ArduinoCore-sam/cores/arduino/RingBuffer.h at master · arduino/ArduinoCore-sam · GitHub which is different to the SimHub one.

Thank you! I've reamed the header and all references to the GitHub RingBuffer to "RingBufferDue" and there are no more compilation errors referring to it.

However, I have another problem in this project related to GPIO. I will post another topic as it's not related and will add a link here once done.

Thanks again for your help!

If it does become necessary to post it then with that many files it is usually best to zip up the sketch folder and post that

better still, create a small sketch that illustrates the problem and post that

OK, Thank you for the tips. I will not post it here as this problem is resolved, but I might do that for the second issue I'm having.

Here is the second problem I'm having. Thanks again for your help with the first one!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.