X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src_test%2Ftest_w1_datalog_write.cc;h=db0febca0cdaf3fa9da16df0971b98c10f11c75d;hb=c4b6d88d7ea02f5ae9b68a075944ff381a2f22c5;hp=5b5e6eb8d80d2dbe135a52eadc11e4758a4c29d0;hpb=034b14870060e6594bfb304502ca057a0771b585;p=lib1wire.git diff --git a/src_test/test_w1_datalog_write.cc b/src_test/test_w1_datalog_write.cc index 5b5e6eb..db0febc 100644 --- a/src_test/test_w1_datalog_write.cc +++ b/src_test/test_w1_datalog_write.cc @@ -50,11 +50,12 @@ int main(int argc, char** argv) { long store_interval; string location; bool err_flg; + W1Device *device; // default values than can be overwritten with parameters location = "/tmp/"; - scan_interval = 600; - store_interval = 6; + scan_interval = 2; //600; + store_interval = 2; if (argc > 1) { location = argv[1]; log_info("storage location: %s\n", location.c_str()); @@ -69,15 +70,17 @@ int main(int argc, char** argv) { try_parse_long(argv[3], &store_interval); } log_info("start scanning, data saved to location: %s, scan interval: %d, store interval: %d\n", location.c_str(), scan_interval, store_interval); - W1Store::set_location_base_dir(location.c_str()); + W1Store::set_store_base_dir(location.c_str()); scanner = new W1Scanner(); device_list = scanner->get_device_list(); round = 0; + int t = 0; if (device_list.size() > 0) { - while(1) { + while(t < 3) { + t++; round++; for(list::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) { - W1Device *device = (W1Device *)*list_iter; + device = (W1Device *)*list_iter; device->printout(); sleep(1); @@ -94,5 +97,12 @@ int main(int argc, char** argv) { else { log_debug("could not find 1-wire devices.\n"); } + while (device_list.empty() == false) { + device = device_list.back(); + device_list.pop_back(); + delete(device); + } + + delete(scanner); return 0; }