Skip to content

Commit

Permalink
Native: fail-safes for simulated node without config file (#3486)
Browse files Browse the repository at this point in the history
* LinuxInput: only close if file descriptor is assigned

* Native: set some defaults if no configuration file found
  • Loading branch information
GUVWAF authored Mar 24, 2024
1 parent b960dc1 commit 77fb230
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/input/LinuxInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/input/LinuxInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 77fb230

Please sign in to comment.