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("scanning 1-wire devices\n");
72 log_info("data save dir: %s, scan interval: %ld, save interval: %ld\n", loc.c_str(), scan_interval, store_interval);
73 DeviceConfig::set_base_dir_name(loc);
74 device_list = Factory::get_device_list();
76 if (device_list.size() > 0) {
79 for(iter = device_list.begin(); iter != device_list.end(); iter++) {
80 device = (W1Device *)*iter;
83 if (round >= store_interval) {
88 if (round >= store_interval) {
94 log_debug("could not find 1-wire devices.\n");
96 while (device_list.empty() == false) {
97 device = device_list.back();
98 device_list.pop_back();