4 * Created on: Oct 20, 2010
16 #include "DeviceConfig.hh"
17 #include "W1Scanner.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) {
47 list<W1Device *> device_list;
54 // default values than can be overwritten with parameters
56 scan_interval = 2; //600;
60 log_info("storage location: %s\n", location.c_str());
63 log_warning("No storage location parameter given, using default location: %s\n", location.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", location.c_str(), scan_interval, store_interval);
72 DeviceConfig::set_base_dir_name(location);
73 scanner = new W1Scanner();
74 device_list = scanner->get_device_list();
77 if (device_list.size() > 0) {
81 for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) {
82 device = (W1Device *)*list_iter;
85 if (round >= store_interval) {
90 if (round >= store_interval) {
96 log_debug("could not find 1-wire devices.\n");
98 while (device_list.empty() == false) {
99 device = device_list.back();
100 device_list.pop_back();