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;
|
SpecifiedDevice specified_device;
|
||||||
bool ok = specified_device.parse(devicefile);
|
bool ok = specified_device.parse(devicefile);
|
||||||
|
if (!ok && SpecifiedDevice::isLikelyDevice(devicefile))
|
||||||
|
{
|
||||||
|
error("Not a valid device \"%s\"\n", devicefile.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
// Number the devices
|
// 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,
|
// See if we had a specified device without a file,
|
||||||
// that matches this detected device.
|
// that matches this detected device.
|
||||||
find_specified_device_and_update_detected(config, &detected);
|
bool found = find_specified_device_and_update_detected(config, &detected);
|
||||||
open_wmbus_device_and_set_linkmodes(config, "auto", &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
|
else
|
||||||
{
|
{
|
||||||
|
@ -937,8 +941,12 @@ void perform_auto_scan_of_swradio_devices(Configuration *config)
|
||||||
{
|
{
|
||||||
// Use the serialnr as the id.
|
// Use the serialnr as the id.
|
||||||
detected.found_device_id = serialnr;
|
detected.found_device_id = serialnr;
|
||||||
find_specified_device_and_update_detected(config, &detected);
|
bool found = find_specified_device_and_update_detected(config, &detected);
|
||||||
open_wmbus_device_and_set_linkmodes(config, "auto", &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;
|
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)
|
bool SpecifiedDevice::parse(string &arg)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
|
@ -164,6 +164,7 @@ struct SpecifiedDevice
|
||||||
void clear();
|
void clear();
|
||||||
string str();
|
string str();
|
||||||
bool parse(string &s);
|
bool parse(string &s);
|
||||||
|
static bool isLikelyDevice(string &s);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Detected
|
struct Detected
|
||||||
|
|
Ładowanie…
Reference in New Issue