mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add a command to list detectable devices on the command line.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
37
src/fe-testdevices.cc
Normal 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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user