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


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

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


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

示例1: 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

示例2: 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

示例3: my_handler

void my_handler(int signal){
           printf("Caught CTRL+C\n");
           serialPort.disconnect();
           exit(1);
}
开发者ID:n3erobotics,项目名称:SUBAO_dualshock3,代码行数:5,代码来源:joystick.cpp


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