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


C++ SerialPort::connect方法代码示例

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


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

示例1: main

int main()
{
	VideoCapture webcam(3);
	Mat frame;

	webcam.set(CV_CAP_PROP_FRAME_WIDTH, height);
	webcam.set(CV_CAP_PROP_FRAME_HEIGHT, width);

	if (serialPort.connect("//dev//ttymxc3")==0) {
		cout << "Can't open serial port" << endl;
		return -1;
	}
	while(true)
	{
		timer.reset();
		webcam.read(frame);
		cv::blur( frame, frame, Size(4,4) );
		imshow("Blured",frame);

		Mat frame_can = Mat::zeros( frame.size(), CV_8UC3 );
		cv::Canny( frame, frame_can, 50, 200, 3 );
		detect_lines(frame_can, frame, "Canny");

		waitKey(5);

		cout << "Timer: "  << timer.elapsed() << endl;

	}
	return 0;
}
开发者ID:ct7ahx,项目名称:CA,代码行数:30,代码来源:main.cpp

示例2: wWinMain

/// <summary>
/// Entry point for the application
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="hPrevInstance">always 0</param>
/// <param name="lpCmdLine">command line arguments</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
/// <returns>status</returns>
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
	port1.connect(L"\\\\.\\COM17");
	port2.connect2(L"\\\\.\\COM21"); //neu

	CSkeletonBasics application;
    application.Run(hInstance, nCmdShow);
}
开发者ID:SiHaas,项目名称:Robomove-Robotersteuerung,代码行数:16,代码来源:SkeletonBasics+-+COM+Verbindung+zu+2+Robotern.cpp

示例3: main

int main()
{
	Dualshock3 joystick;
	joystick.connect();
	
	int err=serialPort.connect("//dev//ttyACM0");
	
	send_command('n', 0);

	while( 1 ) 	/* infinite loop */
	{

		joystick.getData();
		
		if (joystick.button[16]){
			serialPort.disconnect();
			close( joy_fd );
			system("sixad --stop &");
			exit(0);
		}
		
		joystick.getData();
		
		// Detect conflits and process input
		if (joystick.axis[12] != 0 && joystick.axis[13] != 0){
			// Rumbleeeeeee
			send_command('n', 0);
		}else if (joystick.axis[12] == 0 && joystick.axis[13] != 0){
			//input_processing(FWD, joystick.axis[13]);
			cout << "frente" << endl;
			send_command('f', joystick.axis[12]/547);
		}else if(joystick.axis[12] != 0 && joystick.axis[13] == 0){
			//input_processing(BCK, joystick.axis[12]);
			send_command('b', joystick.axis[13]/547);
		}else{
			send_command('n', 0);
		}
		
		joystick.getData();
		
		if (joystick.axis[0] > 0){
			send_command('r', joystick.axis[0]);
		}else if(joystick.axis[0] < 0){
			send_command('l', abs(joystick.axis[0]));
		}else{
			send_command('l', 0);
		}
	}

	serialPort.disconnect();
	close( joy_fd );	/* too bad we never get here */
	return 0;
}
开发者ID:n3erobotics,项目名称:SUBAO_dualshock3,代码行数:53,代码来源:joystick.cpp

示例4: main

int main() {
	cout << "AX Control starts" << endl; // prints AX Control 
	int error=0; 
	int idAX12=0; 
	SerialPort serialPort; 
	if (serialPort.connect("/dev/ttyUSB0")!=0) {
		printf ("Serial port opened\n");
		// Sync Write: 0xFF 0xFF 0xFE(broadcast) [(L+1) * N + 4] 0x83(instruction)  0x20(location) 0x02(lenght of the data) 0x01(id1) lowvel1 hivel1 0x02(id2) lowvel2 hivel2 chk
		// This one sends vels to both motors with orientation
		sendVels(1,512,1, 2,512,0, &serialPort);
		serialPort.disconnect();
	} else {
		printf ("nCan't open serial port");
		error=-1;
	}
	 
	cout << endl << "AX Control ends" << endl; // prints AX Control
	return error;
}
开发者ID:mllofriu,项目名称:romina2,代码行数:19,代码来源:moveax.c

示例5: main

int main() {
  Gamepad gpad(0);
  SerialPort serial;
  Sleep(1000);
  serial.connect("\\\\.\\COM11");

  while (true) {
    gpad.update();
    float lx = scaleInput(gpad.getStickLeftX());
    float ly = scaleInput(gpad.getStickLeftY());
    float rx = scaleInput(gpad.getStickRightX());
    float ry = scaleInput(gpad.getStickRightY());
    printf("lx = %f ly =%f rx = %f ry = %f\n", lx, ly, rx, ry);
    int16_t v[2];
    v[0] = ly * 255;
    v[1] = ry * 255;
    int ret = serial.WriteData((char*)v, 4);
    Sleep(20);
  }

}
开发者ID:guadabernal,项目名称:MazeRobot,代码行数:21,代码来源:main.cpp


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