Problem with Serial library
Hi, I have a problem when i use serial.h library, this is my test code:
#include "ros/ros.h"
#include "serial/serial.h"
#include <string>
int main(int argc, char **argv)
{
ros::init(argc, argv, "Serial");
std::string port = "/dev/ttyUSB1";
unsigned long baud = 9600;
serial::Serial myserial(port, baud, serial::Timeout(250));
if(!myserial.isOpen())
myserial.open();
size_t size = 4;
std::string read;
while (ros::ok())
{
read = myserial.read(size);
for(int x=0; x<size; x++)
{
ROS_INFO("Valores leidos: %s ", read.c_str());
ROS_INFO(" ");
}
ROS_INFO("\n");
ros::spinOnce();
}
return 0;
};
and when i compile, this is the error:
CMakeFiles/Prueba_serial.dir/src/prueba_serial.cpp.o: In the function 'main':
prueba_serial.cpp:(.text.startup+0x145): reference toserial::Serial::Serial(std::__cxx11::basic_string<char, std::char_traits, std::allocator >const&, unsigned int, serial::Timeout, serial::bytesize_t, serial::parity_t, serial::stopbits_t,serial::flowcontrol_t)' sin definirprueba_serial.cpp:(.text.startup+0x155): reference to serial::Serial::isOpen() const' not define
prueba_serial.cpp:(.text.startup+0x1c1): reference toserial::Serial::read[abi:cxx11](unsigned long)'not defineprueba_serial.cpp:(.text.startup+0x606): reference to serial::Serial::~Serial()' not define
prueba_serial.cpp:(.text.startup+0x64c): reference toserial::Serial::open()' not defineprueba_serial.cpp:(.text.startup+0x660): reference to serial::Serial::~Serial()' not define
collect2: error: ld returned 1 exit status
thanks and sorry for my English
pd: sorry for the duplicate question.