Native: fail-safes for simulated node without config file (#3486)

* LinuxInput: only close if file descriptor is assigned

* Native: set some defaults if no configuration file found
pull/3488/head
GUVWAF 2024-03-24 19:42:32 +01:00 zatwierdzone przez GitHub
rodzic b960dc1b41
commit 77fb230baa
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -24,7 +24,8 @@ LinuxInput::LinuxInput(const char *name) : concurrency::OSThread(name)
void LinuxInput::deInit()
{
close(fd);
if (fd >= 0)
close(fd);
}
int32_t LinuxInput::runOnce()

Wyświetl plik

@ -38,7 +38,7 @@ class LinuxInput : public Observable<const InputEvent *>, public concurrency::OS
int queue_progress = 0;
struct epoll_event events[MAX_EVENTS];
int fd;
int fd = -1;
int ret;
uint8_t report[8];
int epollfd;

Wyświetl plik

@ -106,6 +106,8 @@ void portduinoSetup()
}
} else {
std::cout << "No 'config.yaml' found, running simulated." << std::endl;
settingsMap[maxnodes] = 200; // Default to 200 nodes
settingsMap[logoutputlevel] = level_debug; // Default to debug
// Set the random seed equal to TCPPort to have a different seed per instance
randomSeed(TCPPort);
return;