]> pilppa.org Git - lib1wire.git/blobdiff - src_test/test_w1_datalog_write.cc
Support for querying the list devices having data stored.
[lib1wire.git] / src_test / test_w1_datalog_write.cc
index f5a86d8820c69f41cb13648606c93383bbd8f1b3..d0cd8e9943b1fd62c709c9cde8e5175ba547a288 100644 (file)
@@ -14,7 +14,7 @@
 #include <plp/log.h>
 
 #include "DeviceConfig.hh"
-#include "W1Scanner.hh"
+#include "Factory.hh"
 
 using namespace w1;
 using namespace std;
@@ -43,24 +43,23 @@ bool try_parse_long(const char *str, long *result) {
 }
 
 int main(int argc, char** argv) {
-       W1Scanner               *scanner;
        list<W1Device *>        device_list;
        int                     round;
        long                    scan_interval;
        long                    store_interval;
-       string                  location;
+       string                  loc;
        W1Device                *device;
 
        // default values than can be overwritten with parameters
-       location        = "/tmp/";
-       scan_interval   = 2; //600;
+       loc     = "/tmp/w1data";
+       scan_interval   = 600; //600;
        store_interval  = 2;
        if (argc > 1) {
-               location        = argv[1];
-               log_info("storage location: %s\n", location.c_str());
+               loc     = argv[1];
+               log_info("storage location: %s\n", loc.c_str());
        }
        else {
-               log_warning("No storage location parameter given, using default location: %s\n", location.c_str());
+               log_warning("No storage location parameter given, using default location: %s\n", loc.c_str());
        }
        if (argc > 2) {
                try_parse_long(argv[2], &scan_interval);
@@ -68,15 +67,12 @@ int main(int argc, char** argv) {
        if (argc > 3) {
                try_parse_long(argv[3], &store_interval);
        }
-       log_info("start scanning, data saved to location: %s, scan interval: %ld, store interval: %ld\n", location.c_str(), scan_interval, store_interval);
-       DeviceConfig::set_base_dir_name(location);
-       scanner         = new W1Scanner();
-       device_list     = scanner->get_device_list();
+       log_info("start scanning, data saved to location: %s, scan interval: %ld, store interval: %ld\n", loc.c_str(), scan_interval, store_interval);
+       DeviceConfig::set_base_dir_name(loc);
+       device_list     = Factory::get_device_list();
        round           = 0;
-       int     t = 0;
        if (device_list.size() > 0) {
-               while(t < 3) {
-                       t++;
+               while(1) {
                        round++;
                        for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) {
                                device = (W1Device *)*list_iter;
@@ -100,6 +96,5 @@ int main(int argc, char** argv) {
                device_list.pop_back();
                delete(device);
        }
-       delete(scanner);
        return 0;
 }