mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
refactor: change portname parameter to const char* in startCommunication and improve USB device check logic
This commit is contained in:
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
long loop(void *user_data, TKobukiData &Kobuki_data);
|
||||
|
||||
void startCommunication(char *portname,bool CommandsEnabled,void *userDataL);
|
||||
void startCommunication(const char *portname,bool CommandsEnabled,void *userDataL);
|
||||
int measure(); //thread function, contains an infinite loop and reads data
|
||||
void setLed(int led1 = 0, int led2 = 0); //led1 green/red 2/1, //led2 green/red 2/1
|
||||
void setTranslationSpeed(int mmpersec);
|
||||
|
@@ -77,10 +77,9 @@ void checkKobukiConnection()
|
||||
std::lock_guard<std::mutex> lock(connectionMutex);
|
||||
std::string port = findKobukiPort();
|
||||
|
||||
// Controleer of het apparaat beschikbaar is
|
||||
if (!std::ifstream("/dev/ttyUSB0")){
|
||||
if (kobuki_connected){
|
||||
cout << "Kobuki disconnected: USB device not found." << endl;
|
||||
if (port.empty()) {
|
||||
if (kobuki_connected) {
|
||||
cout << "Kobuki disconnected: No USB device found." << endl;
|
||||
kobuki_connected = false;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
@@ -95,7 +94,7 @@ void checkKobukiConnection()
|
||||
}
|
||||
|
||||
cout << "Attempting to reconnect Kobuki..." << endl;
|
||||
robot.startCommunication(const_cast<char*>(port.c_str()), true, nullptr);
|
||||
robot.startCommunication((port.c_str()), true, nullptr);
|
||||
|
||||
if (robot.isConnected()){
|
||||
cout << "Kobuki reconnected successfully!" << endl;
|
||||
|
Reference in New Issue
Block a user