kopia lustrzana https://github.com/weetmuts/wmbusmeters
Fix bug that caused auto even though only a single device expected, like: rtlwmbus[1234]
rodzic
0320070c41
commit
85786cbe8c
|
@ -224,6 +224,11 @@ bool handleDevice(Configuration *c, string devicefile)
|
|||
{
|
||||
SpecifiedDevice specified_device;
|
||||
bool ok = specified_device.parse(devicefile);
|
||||
if (!ok && SpecifiedDevice::isLikelyDevice(devicefile))
|
||||
{
|
||||
error("Not a valid device \"%s\"\n", devicefile.c_str());
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
// Number the devices
|
||||
|
|
16
src/main.cc
16
src/main.cc
|
@ -889,8 +889,12 @@ void perform_auto_scan_of_serial_devices(Configuration *config)
|
|||
{
|
||||
// See if we had a specified device without a file,
|
||||
// that matches this detected device.
|
||||
find_specified_device_and_update_detected(config, &detected);
|
||||
open_wmbus_device_and_set_linkmodes(config, "auto", &detected);
|
||||
bool found = find_specified_device_and_update_detected(config, &detected);
|
||||
if (config->use_auto_device_detect || found)
|
||||
{
|
||||
// Open the device, only if auto is enabled, or if the device was specified.
|
||||
open_wmbus_device_and_set_linkmodes(config, found?"config":"auto", &detected);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -937,8 +941,12 @@ void perform_auto_scan_of_swradio_devices(Configuration *config)
|
|||
{
|
||||
// Use the serialnr as the id.
|
||||
detected.found_device_id = serialnr;
|
||||
find_specified_device_and_update_detected(config, &detected);
|
||||
open_wmbus_device_and_set_linkmodes(config, "auto", &detected);
|
||||
bool found = find_specified_device_and_update_detected(config, &detected);
|
||||
if (config->use_auto_device_detect || found)
|
||||
{
|
||||
// Open the device, only if auto is enabled, or if the device was specified.
|
||||
open_wmbus_device_and_set_linkmodes(config, found?"config":"auto", &detected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4105,6 +4105,14 @@ string SpecifiedDevice::str()
|
|||
return r;
|
||||
}
|
||||
|
||||
bool SpecifiedDevice::isLikelyDevice(string &arg)
|
||||
{
|
||||
// Only devices are allowed to contain colons.
|
||||
// Devices usually contain a colon!
|
||||
if (arg.find(":") != string::npos) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpecifiedDevice::parse(string &arg)
|
||||
{
|
||||
clear();
|
||||
|
|
|
@ -164,6 +164,7 @@ struct SpecifiedDevice
|
|||
void clear();
|
||||
string str();
|
||||
bool parse(string &s);
|
||||
static bool isLikelyDevice(string &s);
|
||||
};
|
||||
|
||||
struct Detected
|
||||
|
|
Ładowanie…
Reference in New Issue