Error Compiling SerialTerminalPRO example

patrick-dojo

New member
Install the SerialTerminalPRO v1.1.1 library
Open the libraries 'calculator' example
Try to compile and you're presented with the following error.
Code:
In file included from /Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/examples/calculator/calculator.ino:1:0:
/Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/SerialTerminal.hpp: In static member function 'static maschinendeck::Pair<String, String> maschinendeck::SerialTerminal::ParseCommand(String)':
/Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/SerialTerminal.hpp:174:26: error: 'begin' was not declared in this scope
         for (auto& car : message) {
                          ^
/Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/SerialTerminal.hpp:174:26: note: suggested alternative:
In file included from /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/c++/5.4.1/utility:75:0,
                 from /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/wiring.h:89,
                 from /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/WProgram.h:45,
                 from /var/folders/0q/kx24shts5396rqt4r2rgpkfr0000gn/T/arduino_build_639362/pch/Arduino.h:6:
/Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/c++/5.4.1/initializer_list:89:5: note:   'std::begin'
     begin(initializer_list<_Tp> __ils) noexcept
     ^
In file included from /Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/examples/calculator/calculator.ino:1:0:
/Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/SerialTerminal.hpp:174:26: error: 'end' was not declared in this scope
         for (auto& car : message) {
                          ^
/Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1/SerialTerminal.hpp:174:26: note: suggested alternative:
In file included from /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/c++/5.4.1/utility:75:0,
                 from /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/wiring.h:89,
                 from /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/WProgram.h:45,
                 from /var/folders/0q/kx24shts5396rqt4r2rgpkfr0000gn/T/arduino_build_639362/pch/Arduino.h:6:
/Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/c++/5.4.1/initializer_list:99:5: note:   'std::end'
     end(initializer_list<_Tp> __ils) noexcept
     ^
Using library SerialTerminalPRO-1.1.1 at version 1.1.1 in folder: /Users/patricklittle/Documents/Arduino/libraries/SerialTerminalPRO-1.1.1 
Error compiling for board Teensy 3.6.

Source code of example, but the error is thrown by the library's .hpp file
HTML:
#include <SerialTerminal.hpp>

maschinendeck::SerialTerminal* term;

void addInt(String opts) {
  maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
  Serial.print(operands.first());
  Serial.print(" + ");
  Serial.print(operands.second());
  Serial.print(" = ");
  Serial.print(operands.first().toInt() + operands.second().toInt());
  Serial.print('\n');
}

void setup() {
  term = new maschinendeck::SerialTerminal(38400);
  term->add("add", &addInt, "adds to integers");
}

void loop() {
  term->loop();
}

I reported the bug to SerialTerminalPRO and he traced it down to the version of the Arduino.h file packaged with Teensyduino, claiming it's not up to date.
https://github.com/miko007/SerialTerminal/issues/3#issuecomment-902610304
 
His example
Code:
void setup() {
  String foo = "Hello";
  for (auto& car : foo) {
    Serial.print(car);  
  }
}

works, if you just add these lines to wstring.h
Code:
    // character acccess
    char charAt(unsigned int index) const;
    void setCharAt(unsigned int index, char c);
    char operator [] (unsigned int index) const;
    char& operator [] (unsigned int index);
    void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
    void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
        {getBytes((unsigned char *)buf, bufsize, index);}
    const char * c_str() const {
        if (!buffer) return &zerotermination; // https://forum.pjrc.com/threads/63842
        return buffer;
    }
    
[COLOR=#008000]    char* begin() { return buffer; }
    char* end() { return buffer + length(); }
    const char* begin() const { return c_str(); }
    const char* end() const { return c_str() + length(); }[/COLOR]
    
    // search
    int indexOf( char ch ) const;
 
It would help to remind Paul by posting in the 1.55beta thread( in :Announcements")

Thank you.
I guess we see a 1.55 beta2 soon.
 
Back
Top