当前位置: 首页>>代码示例>>C++>>正文


C++ Serial::isOpen方法代码示例

本文整理汇总了C++中serial::Serial::isOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ Serial::isOpen方法的具体用法?C++ Serial::isOpen怎么用?C++ Serial::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在serial::Serial的用法示例。


在下文中一共展示了Serial::isOpen方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: open

        bool open() {

				bool device_opened = false;

				if (is_open()) {
					if (debug)
						std::cout << "serial already opened" << std::endl;
					
				} else {
				
					m_serial.setPort(m_device_port);
					m_serial.setBaudrate(115200);
					//serial::Timeout t(1000, 1000);
					m_serial.setTimeout(serial::Timeout::simpleTimeout(2000));
					m_serial.open();

					// Open port
					if (m_serial.isOpen()) {
						m_serial.flush();
						// Check if the device is well a Wattsup
						if (identify()) {
							m_serial.flush();
							device_opened = true;
						} else {
							m_serial.close();
						}
					}
				}

				return device_opened;
        }
开发者ID:hanappe,项目名称:low-energy-boinc,代码行数:31,代码来源:Wattsup.cpp

示例2: checkConnection

bool checkConnection(){
	if(!port.isOpen() && !port.getPort().empty()){
		try{
			port.open();
			ROS_WARN_THROTTLE(5, "Serial port was closed, reopened.");
		} catch (const serial::IOException& ex){
			ROS_ERROR_THROTTLE(10, "Serial port is closed, reopening failed: %s", ex.what());
		}
	}
}
开发者ID:exuvo,项目名称:kbot,代码行数:10,代码来源:serial.cpp

示例3: configure_com_port

// Opens and configures the com-port
void configure_com_port(void)
{
  if (my_serial.isOpen())
  {
    cout << "Port is open " << endl;
  }
  else
  {
     cout << "Unable to open com-port " << endl;
  }
}
开发者ID:Trechi,项目名称:Merging,代码行数:12,代码来源:controller_server.cpp

示例4: main

int main(int argc, char **argv){

	ros::init(argc, argv, "nayan_ros");

	ros::NodeHandle n;



	imu_pub = n.advertise<nayan_msgs::nayan_imu>("nayan_ros/imu", 1000);

	debug_var_pub = n.advertise<nayan_msgs::nayan_dbg>("nayan_ros/debug_var", 1000);

	gps_pose_vel_pub = n.advertise<nayan_msgs::nayan_gps_pose_vel>("nayan_ros/gps_pose_vel", 1000);

	attitude_pub = n.advertise<nayan_msgs::nayan_attitude>("nayan_ros/attitude", 1000);

	rc_in_pub = n.advertise<nayan_msgs::nayan_rc_in>("nayan_ros/rc_in", 1000);


	vision_est_sub = n.subscribe("nayan_ros/vision_estimate", 1000, update_vision_estimate);

	pose_vel_setpt_sub = n.subscribe("nayan_ros/setpoint_pose_vel", 1000, update_setpoint_pose_vel);


	param_srv = n.advertiseService("param_set", update_param);


	ros::Duration(2).sleep();

	if (ser.isOpen()){
		ROS_INFO("Serial Port Opened!");
	}else{
		ROS_ERROR("Serial Port Cannot be Opened!");
	}

	ros::Rate loop_rate(100);

	while(ros::ok()){

		update_mavlink();

		ros::spinOnce();

		loop_rate.sleep();
	}


	return 0;
}
开发者ID:nikhil9,项目名称:nayan_ros,代码行数:49,代码来源:nayan_ros_node.cpp

示例5: open

bool open(string portname, int baudrate){
  port.setPort(portname);
  port.setBaudrate(baudrate);
  serial::Timeout t = serial::Timeout::simpleTimeout(1000);
  port.setTimeout(t);
	try{
		port.open();
	} catch (const serial::IOException& ex){
		ROS_ERROR_THROTTLE(10, "IOException while attempting to open serial port '%s': %s", portname.c_str(), ex.what());
	}

  if(port.isOpen()){
		port.setPort("kbot_bridge");
    return true;
  }

  return false;
}
开发者ID:exuvo,项目名称:kbot,代码行数:18,代码来源:serial.cpp

示例6: is_open

        bool is_open() {
				return m_serial.isOpen();
        }
开发者ID:hanappe,项目名称:low-energy-boinc,代码行数:3,代码来源:Wattsup.cpp

示例7: main

int main(int argc, char** argv)
{
    ros::init(argc, argv, "IMU_Node2");
    ros::NodeHandle n;


     imu_pub = n.advertise<sensor_msgs::Imu>("/imu/data",100);


    // Change the next line according to your port name and baud rate
    try
    {

        if(device.isOpen())
           {
               ROS_INFO("Port is opened");
          }
    }
    catch(serial::SerialException& e)
    {
        ROS_FATAL("Failed to open the serial port!!!");
        ROS_BREAK();
    }

       ros::Rate r(50);
          while(ros::ok())
          {


       // Get the reply, the last value is the timeout in ms
       try{
     std::string reply;

        // ros::Duration(0.005).sleep();

           device.readline(reply);
           Roll = strtod(reply.c_str(),&pRoll)/2;
           Pitch = strtod(pRoll,&pRoll)/2;
           Yaw  = strtod(pRoll,&pRoll)/2;
           GyroX = strtod(pRoll,&pRoll);
           GyroY = strtod(pRoll,&pRoll);
           GyroZ = strtod(pRoll,&pRoll);
           AccX = strtod(pRoll,&pRoll);
           AccY = strtod(pRoll,&pRoll);
           AccZ = strtod(pRoll,&pRoll);
           Mx = strtod(pRoll,&pRoll);
           My = strtod(pRoll,&pRoll);
           Mz = strtod(pRoll,NULL);

           ROS_INFO("Euler %.2f %.2f %.2f",Roll,Pitch,Yaw);

	   sensor_msgs::Imu imu;

           geometry_msgs::Quaternion Q;
           Q = tf::createQuaternionMsgFromRollPitchYaw(Roll*-1,Pitch*-1,Yaw*-1);

           imu.orientation.x = 0;
           imu.orientation.y = 0;
           imu.orientation.z = 0;
           imu.orientation.w = 1;


           LinearX =  (AccX/256)*9.806;
           LinearY = (AccY/256)*9.806;
           LinearZ = (AccZ/256)*9.806;

           imu.angular_velocity.x = GyroX*-1*0.07*0.01745329252;;
           imu.angular_velocity.y = GyroY*0.07*0.01745329252;;
           imu.angular_velocity.z = GyroZ*-1*0.07*0.01745329252;;

           imu.linear_acceleration.x =  LinearX*-1;
           imu.linear_acceleration.y =  LinearY;
           imu.linear_acceleration.z =  LinearZ*-1;
           imu.header.stamp = ros::Time::now();
           imu.header.frame_id = "imu";
           imu_pub.publish(imu);


       }
       catch(serial::SerialException& e)
       {
           ROS_INFO("Error %s",e.what());
       }

              r.sleep();
    }

}
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:88,代码来源:imu_serial2.cpp


注:本文中的serial::Serial::isOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。