mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +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);
|
||||
|
||||
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;
|
||||
} else {
|
||||
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) {
|
||||
if(!robot.isConnected()){
|
||||
std::cout << "Kobuki is not connected anymore" << std::endl;
|
||||
robot.connect("/dev/ttyUSB0");
|
||||
while(!robot.isConnected()){
|
||||
robot.startCommunication("/dev/ttyUSB0", true, nullptr);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
Reference in New Issue
Block a user