本文整理汇总了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;
}
示例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;
}
示例3: my_handler
void my_handler(int signal){
printf("Caught CTRL+C\n");
serialPort.disconnect();
exit(1);
}