Error: 'SERIAL_RX_BUFFER_SIZE for each Sketch

Hello,
I would like to test something with the Simpit library. Unfortunately, not even the examples work. I always get the following error.

c:\arduino\libraries\KerbalSimpit\src\KerbalSimpit.cpp: In member function 'bool KerbalSimpit::init()':
c:\arduino\libraries\KerbalSimpit\src\KerbalSimpit.cpp:54:54: error: 'SERIAL_RX_BUFFER_SIZE' was not declared in this scope
printToKSP("Buffer receive size : " + String(SERIAL_RX_BUFFER_SIZE));
^

exit status 1

Compilation error: exit status 1

#include "KerbalSimpit.h"

// Declare a KerbalSimpit object that will
// communicate using the "Serial" device.
KerbalSimpit mySimpit(Serial);

// This boolean tracks the desired LED state.
bool state = false;

// A timestamp of the last time we sent an echo packet.
unsigned long lastSent = 0;
// How often to send echo packets (in ms)
unsigned int sendInterval = 1000;

void setup() {
  // Open the serial connection.
  Serial.begin(115200);

  // Set up the built in LED, and turn it on.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  // This loop continually attempts to handshake with the plugin.
  // It will keep retrying until it gets a successful handshake.
  while (!mySimpit.init()) {
    delay(100);
  }
  // Turn off the built-in LED to indicate handshaking is complete.
  digitalWrite(LED_BUILTIN, LOW);
  // Display a message in KSP to indicate handshaking is complete.
  mySimpit.printToKSP("Connected", PRINT_TO_SCREEN);
  // Sets our callback function. The KerbalSimpit library will
  // call this function every time a packet is received.
  mySimpit.inboundHandler(messageHandler);
}

void loop() {
  unsigned long now = millis();
  // If we've waited long enough since the last message, send a new one.
  if (now - lastSent >= sendInterval) {
    // If the last message was "high", send "low"
    // and vice-versa.
    if (state) {
      mySimpit.send(ECHO_REQ_MESSAGE, "low", 4);
    } else {
      mySimpit.send(ECHO_REQ_MESSAGE, "high", 5);
    }
    // Update when we last sent a message.
    lastSent = now;
    // Update the state variable to match the message we just sent.
    state = !state;
  }
  // Call the library update() function to check for new messages.
  mySimpit.update();
}

void messageHandler(byte messageType, byte msg[], byte msgSize) {
  // We are only interested in echo response packets.
  if (messageType == ECHO_RESP_MESSAGE) {
    // The message payload will be either "low" or "high".
    // We use the strcmp function to check what the string payload
    // is, and set the LED status accordingly.
    if (strcmp((char*) msg, "low")) {
      digitalWrite(LED_BUILTIN, LOW);
    } else {
      digitalWrite(LED_BUILTIN, HIGH);
    }
  }
}

I am using an Arduino Due

GitHub - PanGalacticTech/Kerbal_Controller: Firmware for Kerbal Space Program Controller, provides some useful info and you can also ask them why their stuff don't work with a DUE.

That's specific for the AVR boards. For the Due, it would be SERIAL_BUFFER_SIZE. There might be a lot more that will fail when compiling for the Due but you can use a conditional compilation; e.g. I'm compiling a program for both a Mega and a Due and use the below construction

#ifdef __SAM3X8E__
  Serial.print(SERIAL_BUFFER_SIZE);
#else
  Serial.print(SERIAL_RX_BUFFER_SIZE);
#endif

Please note that because this project is limited to Mega and Due (and I pretend to know what I'm doing :wink:) I can use this. If it ever has to move to another architecture (e.g. ESP), it might not work.

As said, you might have to make a lot more changes.

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