Required due to api changes in libplp.
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
<name>lib1wire</name>
<comment></comment>
<projects>
+ <project>libplp</project>
</projects>
<buildSpec>
<buildCommand>
dirent *direntry_param) {
Device *ret_val;
DeviceConfig *config;
+ bool succ;
ret_val = NULL;
if (device_type_param.empty() == false) {
config = DeviceConfig::get_device_config(device_id_param);
if (config != NULL) {
// if not, create default device config
- device_type_param = config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
- if (device_type_param.empty() == true) {
+ succ = config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, device_type_param);
+ if (succ == false) {
device_type_param = ret_val->get_type();
- config->set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, device_type_param);
- config->set_config_value(DEVICE_CONFIG_VALUE_KEY__ID, ret_val->get_id());
+ config->set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, device_type_param, false);
+ config->set_config_value(DEVICE_CONFIG_VALUE_KEY__ID, ret_val->get_id(), true);
}
delete(config);
}
}
if (found == false) {
// reader device is not in the list of active devices. create and add it to list as in-active one...
- type = reader->get_device_type();
- if (type.empty() == false) {
+ found = reader->get_device_type(type);
+ if (found == true) {
device = create_device(type, id1);
if (device != NULL) {
ret_val.push_back(device);
if (name.empty() == true) {
cfg = DeviceConfig::get_device_config(id);
if (cfg != NULL) {
- name = cfg->get_config_value(DEVICE_CONFIG_VALUE_KEY__NAME);
+ cfg->get_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name);
delete(cfg);
}
}
name = name_param;
cfg = DeviceConfig::get_device_config(id);
if (cfg != NULL) {
- cfg->set_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name_param);
+ cfg->set_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name_param, true);
delete(cfg);
}
}
*/
}
else {
- log_error("Failed to convert temperature %s to celsius value", raw_value.c_str());
+ log_error("Failed to convert temperature %s to celcius value.", raw_value.c_str());
*err_flg = 1;
}
return dbl_val;
}
W1TemperatureSensor::~W1TemperatureSensor() {
- log_debug("W1TemperatureSensor destructor\n");
+ log_debug("destructor\n");
}
vector<double> *W1TemperatureSensor::get_raw_data() {
using namespace plp;
using namespace w1;
-bool try_parse_long(const char *str, long *result) {
- int new_result;
- char *endptr;
- bool ret_val;
-
- ret_val = false;
- errno = 0;
- new_result = strtol(str, &endptr, 10);
- if (errno != 0) {
- log_error("invalid input %s, could not convert to integer.\n", str);
- }
- else {
- if (endptr == str) {
- log_error("invalid input %s, could not convert to integer.\n", str);
- }
- else {
- *result = new_result;
- ret_val = true;
- }
- }
- return ret_val;
-}
-
int main(int argc, char** argv) {
string loc;
Data *fdata;
#include <plp/DeviceConfig.hh>
#include <plp/Device.hh>
+#include <plp/str_util.h>
+
#include "Factory.hh"
using namespace w1;
#define DEFAULT_READ_INTERVAL_SECONDS 600
#define DEFAULT_MAX_READ_COUNT -1
-bool try_parse_long(const char *str, long *result) {
- int new_result;
- char *endptr;
- bool ret_val;
-
- ret_val = false;
- errno = 0;
- new_result = strtol(str, &endptr, 10);
- if (errno != 0) {
- log_error("invalid input %s, could not convert to integer.\n", str);
- }
- else {
- if (endptr == str) {
- log_error("invalid input %s, could not convert to integer.\n", str);
- }
- else {
- *result = new_result;
- ret_val = true;
- }
- }
- return ret_val;
-}
-
int main(int argc, char** argv) {
int read_count_total;
long cnt_max_scans;
log_info("\tmax_read_count == -1: read devices until application is terminated\n\n");
}
if (argc > 2) {
- try_parse_long(argv[2], &read_interval_seconds);
+ parse_long(argv[2], &read_interval_seconds);
}
if (argc > 3) {
- try_parse_long(argv[3], &cnt_max_scans);
+ parse_long(argv[3], &cnt_max_scans);
}
log_info("searching 1-wire devices\n");
if (read_interval_seconds == DEFAULT_READ_INTERVAL_SECONDS) {