]> pilppa.org Git - lib1wire.git/blobdiff - src_test/test_w1_datalog_write.cc
started adding support for reading average and sum data...
[lib1wire.git] / src_test / test_w1_datalog_write.cc
index 5b5e6eb8d80d2dbe135a52eadc11e4758a4c29d0..db0febca0cdaf3fa9da16df0971b98c10f11c75d 100644 (file)
@@ -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<W1Device *>::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;
 }