4 * Created on: Oct 20, 2010
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;
55 // default values than can be overwritten with parameters
57 scan_interval = 2; //600;
61 log_info("storage location: %s\n", location.c_str());
64 log_warning("No storage location parameter given, using default location: %s\n", location.c_str());
67 try_parse_long(argv[2], &scan_interval);
70 try_parse_long(argv[3], &store_interval);
72 log_info("start scanning, data saved to location: %s, scan interval: %d, store interval: %d\n", location.c_str(), scan_interval, store_interval);
73 W1Store::set_base_dir_name(location);
74 scanner = new W1Scanner();
75 device_list = scanner->get_device_list();
78 if (device_list.size() > 0) {
82 for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) {
83 device = (W1Device *)*list_iter;
87 if (round >= store_interval) {
92 if (round >= store_interval) {
98 log_debug("could not find 1-wire devices.\n");
100 while (device_list.empty() == false) {
101 device = device_list.back();
102 device_list.pop_back();