]> pilppa.org Git - lib1wire.git/blobdiff - src_test/test_w1.cc
storage data cleanup. allow specifying storage dir location
[lib1wire.git] / src_test / test_w1.cc
index 3a07a0a37ab780f8322b69cc26312edabe639738..e0ceb1d4c4f4eec634d07798d87480c7d8d36f1f 100644 (file)
 
 #include <plp/log.h>
 
+#include "W1Store.hh"
 #include "W1Scanner.hh"
 
 using namespace w1;
 using namespace std;
 
-int main(int argc, char** argv)
-{
+int main(int argc, char** argv) {
        W1Scanner               *scanner;
        list<W1Device *>        device_list;
        int                     round;
        int                     interval_seconds;
        int                     store_interval;
+       string                  location;
 
-       interval_seconds        = 60;
-       store_interval          = 10;
+       location                = "/tmp/";
+       if (argc > 1) {
+               location        = argv[1];
+               log_info("storage location: %s\n", location.c_str());
+       }
+       W1Store::set_location(location.c_str());
+       interval_seconds        = 3;
+       store_interval          = 3;
        scanner                 = new W1Scanner();
        device_list             = scanner->get_device_list();
        round                   = 0;
@@ -34,12 +41,7 @@ int main(int argc, char** argv)
                        for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++)
                        {
                                W1Device *device = (W1Device *)*list_iter;
-/*
-                       string name     = device->get_name();
-                       string value    = device->get_value();
-                       string unit             = device->get_unit();
-                       cout << name << ": " << value << " " << unit << endl;
-*/
+
                                device->printout();
                                sleep(1);
                                if (round >= store_interval) {