Compare commits

..

2 Commits

Author SHA1 Message Date
Jorge Alejandro 318e527793
Merge 1d0cdb9f00 into b56fc99c2c 2023-09-17 18:13:55 -04:00
Jorge Alejandro 1d0cdb9f00 Add scan-interval-ms parameter
Allow user to specify the scan interval for searching for devices.
Scanning places every interface on the machine in promiscuous mode
and currently runs once a second.  This behaviour may have undesirable
side-effects and also pollutes the kernel log.

The new parameter --scan-interval-ms <interval> will allow the user
to specify the rate at which scanning occurs.  If equal to 0, then
only a single scan is performed.
2023-09-17 18:13:21 -04:00
1 changed files with 24 additions and 12 deletions

View File

@ -407,8 +407,20 @@ int main(int argc, char** argv) {
serialFilter = argv[++i];
transform(serialFilter.begin(), serialFilter.end(), serialFilter.begin(), ::toupper);
} else if(arg == "--scan-interval-ms" && i + 1 <= argc) {
scanIntervalMs = std::atoi(argv[i + 1]);
i++;
try {
scanIntervalMs = std::stoi(argv[++i]);
} catch (const std::invalid_argument& e) {
std::cerr << "Invalid input for scan-interval-ms\n";
return EX_USAGE;
} catch (const std::out_of_range& e) {
std::cerr << "Out of range input for scan-interval-ms\n";
return EX_USAGE;
}
if(scanIntervalMs < 0) {
std::cerr << "Invalid input for scan-interval-ms\n";
return EX_USAGE;
}
} else {
usage(argv[0]);
return EX_USAGE;