mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 12:24:57 +00:00
made thread to wait 1 sec before reconnect
This commit is contained in:
@@ -68,7 +68,8 @@ int CKobuki::connect(char *comportT) {
|
|||||||
HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||||
|
|
||||||
if (HCom == -1) {
|
if (HCom == -1) {
|
||||||
printf("unable to connect\n");
|
std::cerr <<"unable to connect. retry in 1 second" << std::endl;
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
return HCom;
|
return HCom;
|
||||||
} else {
|
} else {
|
||||||
set_interface_attribs2(HCom, B115200,0); // set speed to 115,200 bps, 8n1 (no parity)
|
set_interface_attribs2(HCom, B115200,0); // set speed to 115,200 bps, 8n1 (no parity)
|
||||||
|
@@ -327,6 +327,7 @@ void sendKobukiData(TKobukiData &data) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if(!robot.isConnected()){
|
if(!robot.isConnected()){
|
||||||
std::cout << "Kobuki is not connected anymore" << std::endl;
|
std::cout << "Kobuki is not connected anymore" << std::endl;
|
||||||
|
robot.connect("/dev/ttyUSB0");
|
||||||
while(!robot.isConnected()){
|
while(!robot.isConnected()){
|
||||||
robot.startCommunication("/dev/ttyUSB0", true, nullptr);
|
robot.startCommunication("/dev/ttyUSB0", true, nullptr);
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
Reference in New Issue
Block a user