20 #include <serial/serial.h> 21 #include <std_msgs/Byte.h> 22 #include <std_msgs/UInt8.h> 23 #include <std_msgs/String.h> 24 #include <std_msgs/Empty.h> 33 int main (
int argc,
char** argv){
34 ros::init(argc, argv,
"serial_example_node");
42 ser.setPort(
"/dev/ttyUSB0");
43 ser.setBaudrate(115200);
44 serial::Timeout to = serial::Timeout::simpleTimeout(1000);
46 ser.setBytesize((serial::bytesize_t)8);
47 ser.setParity((serial::parity_t)0);
48 ser.setStopbits((serial::stopbits_t)1);
51 catch (serial::IOException& e)
70 std_msgs::String result;
72 result.data =
ser.read(
ser.available());
74 const char* read_data = result.data.c_str();
void write_callback(const std_msgs::String::ConstPtr &msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void publish(const boost::shared_ptr< M > &message) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_INFO_STREAM(args)
#define ROS_ERROR_STREAM(args)
ROSCPP_DECL void spinOnce()