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;
52 list<W1Device *>::iterator iter;
54 // default values than can be overwritten with parameters
56 scan_interval = 600; //600;
60 log_info("storage location: %s\n", loc.c_str());
63 log_warning("No storage location parameter given, using default location: %s\n", loc.c_str());
66 try_parse_long(argv[2], &scan_interval);
69 try_parse_long(argv[3], &store_interval);
71 log_info("start scanning, data saved to location: %s, scan interval: %ld, store interval: %ld\n", loc.c_str(), scan_interval, store_interval);
72 DeviceConfig::set_base_dir_name(loc);
73 device_list = Factory::get_device_list();
75 if (device_list.size() > 0) {
78 for(iter = device_list.begin(); iter != device_list.end(); iter++) {
79 device = (W1Device *)*iter;
82 if (round >= store_interval) {
87 if (round >= store_interval) {
93 log_debug("could not find 1-wire devices.\n");
95 while (device_list.empty() == false) {
96 device = device_list.back();
97 device_list.pop_back();