4 * Created on: Oct 20, 2010
16 #include "DeviceConfig.hh"
22 bool try_parse_long(const char *str, long *result) {
29 new_result = strtol(str, &endptr, 10);
31 log_error("invalid input %s, could not convert to integer.\n", str);
35 log_error("invalid input %s, could not convert to integer.\n", str);
45 int main(int argc, char** argv) {
46 list<W1Device *> device_list;
53 // default values than can be overwritten with parameters
55 scan_interval = 600; //600;
59 log_info("storage location: %s\n", loc.c_str());
62 log_warning("No storage location parameter given, using default location: %s\n", loc.c_str());
65 try_parse_long(argv[2], &scan_interval);
68 try_parse_long(argv[3], &store_interval);
70 log_info("start scanning, data saved to location: %s, scan interval: %ld, store interval: %ld\n", loc.c_str(), scan_interval, store_interval);
71 DeviceConfig::set_base_dir_name(loc);
72 device_list = Factory::get_device_list();
74 if (device_list.size() > 0) {
77 for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) {
78 device = (W1Device *)*list_iter;
81 if (round >= store_interval) {
86 if (round >= store_interval) {
92 log_debug("could not find 1-wire devices.\n");
94 while (device_list.empty() == false) {
95 device = device_list.back();
96 device_list.pop_back();