// シリアル通信を行う void writeBySerial(void) { // 1回目の通信なら初期設定 if(0 == config_counter){ port.set_option(serial_port_base::baud_rate(38400)); port.set_option(serial_port_base::character_size(8)); port.set_option(serial_port_base::flow_control(serial_port_base::flow_control::none)); port.set_option(serial_port_base::parity(serial_port_base::parity::none)); port.set_option(serial_port_base::stop_bits(serial_port_base::stop_bits::one)); config_counter++; } if(succeedS_R(port)){ printf("S_R Handshake successfully done\n"); if(sendImage(port)){ printf("data correctly written\n"); } } return; }
DriverComms(std::string port, int baudrate){ sp = new serial_port(io); //connect to port sp->open(port, ec); if(ec) { //Failure to connect ROS_ERROR_STREAM("Error connecting to expression board: " << ec.message()); sp->close(); delete sp; throw std::exception(); } //Set the baudrate sp->set_option(serial_port_base::baud_rate(baudrate)); }