0

I'm writing the header file for a class that communicates with an Arduino, and I keep getting the above error message. I looked at other similar questions, and a reoccuring problem is that the data type in question is not well-defined. Is there any reason why std::string isn't defined, or is there another issue? Thanks in advance!

Edit: The following code is for the Linux Machine I'm using to communicate with the Arduino, and therefore isn't the Arduino code. Also the full error message is: error: expected ‘)’ before ‘name’ ArduinoCom(std::string name, speed_t baud);

#ifndef ArduinoCom
#define ArduinoCom

#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <iostream>
#include <fstream>
#include <string>
#include <termios.h>
#include "SerialCom.h"

class ArduinoCom {
    public:
        ArduinoCom(std::string name, speed_t baud);
        ~ArduinoCom();
        std::string get_value(std::string value_type); 
        double get_double_value(std::string value_type);
    private:
        SerialCom *ard_serial;
};
#endif

And the corresponding .cpp file:

#include "ArduinoCom.h"
#include "SerialCom.h"

using namespace std;

ArduinoCom::ArduinoCom(std::string name, speed_t baud){
    ard_serial = new SerialCom(name, baud);
}

ArduinoCom::~ArduinoCom(){
    delete ard_serial;
}

std::string ArduinoCom::get_value(std::string value_type){
    ard_serial->write(value_type);
    std::string buf;
    ard_serial->read(buf);
    return buf;
}

double ArduinoCom::get_double_value(std::string value_type){
    std::value_str = ArduinoCom::get_value(value_type);
    return stod(value_str);
}
Phantom101
  • 101
  • 3

1 Answers1

0

Arduino IDE does not come with the C++ STL by default, instead Arduino has its own set of libraries. For Arduino development you would use the provided String object instead of std::string.

Also, you should check out

Tzalumen
  • 652
  • 3
  • 16
  • I'll edit the above question, but the above code is for the Linux machine communicating with the Arduino, and isn't for the Arduino itself. Thank you for responding though – Phantom101 Apr 08 '19 at 23:09