Add a command to list detectable devices on the command line.

This commit is contained in:
David Given
2024-01-30 21:44:11 +01:00
parent 83d907bf71
commit fd4ddc56f2
4 changed files with 48 additions and 1 deletions

View File

@@ -58,7 +58,14 @@ If _more_ than one device is plugged in, you need to specify which one to use
with the `--usb.serial` parameter, which takes the device serial number as a
parameter. You can find out the serial numbers by running the command without
the `--usb.serial` parameter, and if more than one device is attached they will
be listed. The serial number is also shown whenever a connection is made.
be listed. The serial number is also shown whenever a connection is made. You
can list all the detectable devices with:
```
$ fluxengine test devices
```
This will show you their serial numbers.
You _can_ work with more than one FluxEngine at the same time, using different
invocations of the client; but be careful of USB bandwidth. If the devices are

View File

@@ -23,6 +23,7 @@ cxxprogram(
"./fe-rpm.cc",
"./fe-seek.cc",
"./fe-testbandwidth.cc",
"./fe-testdevices.cc",
"./fe-testvoltages.cc",
"./fe-write.cc",
"./fileutils.cc",

37
src/fe-testdevices.cc Normal file
View File

@@ -0,0 +1,37 @@
#include "lib/globals.h"
#include "lib/flags.h"
#include "lib/usb/usbfinder.h"
#include <fmt/format.h>
static FlagGroup flags;
int mainTestDevices(int argc, const char* argv[])
{
flags.parseFlagsWithConfigFiles(argc, argv, {});
auto candidates = findUsbDevices();
switch (candidates.size())
{
case 0:
fmt::print("Detected no devices.\n");
break;
case 1:
fmt::print("Detected one device:\n");
break;
default:
fmt::print("Detected {} devices:\n", candidates.size());
}
fmt::print("{:15} {:30} {}\n", "Type", "Serial number", "Port (if any)");
for (auto& candidate : candidates)
{
fmt::print("{:15} {:30} {}\n",
getDeviceName(candidate->type),
candidate->serial,
candidate->serialPort);
}
return 0;
}

View File

@@ -23,6 +23,7 @@ extern command_cb mainRm;
extern command_cb mainRpm;
extern command_cb mainSeek;
extern command_cb mainTestBandwidth;
extern command_cb mainTestDevices;
extern command_cb mainTestVoltages;
extern command_cb mainWrite;
@@ -69,6 +70,7 @@ static std::vector<Command> analysables =
static std::vector<Command> testables =
{
{ "bandwidth", mainTestBandwidth, "Measures your USB bandwidth.", },
{ "devices", mainTestDevices, "Displays all detected devices.", },
{ "voltages", mainTestVoltages, "Measures the FDD bus voltages.", },
};
// clang-format on