/* * test_w1.cc * * Created on: Oct 20, 2010 * Author: lamikr */ #include #include #include #include #include "W1Store.hh" #include "W1Scanner.hh" using namespace w1; using namespace std; int main(int argc, char** argv) { W1Scanner *scanner; list device_list; int round; int interval_seconds; int store_interval; string location; location = "/tmp/"; if (argc > 1) { location = argv[1]; log_info("storage location: %s\n", location.c_str()); } else { log_warning("storage location was not given as a parameter, using default location: %s\n", location.c_str()); } W1Store::set_location(location.c_str()); interval_seconds = 600; store_interval = 6; scanner = new W1Scanner(); device_list = scanner->get_device_list(); round = 0; if (device_list.size() > 0) { while(1) { round++; for(list::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) { W1Device *device = (W1Device *)*list_iter; device->printout(); sleep(1); if (round >= store_interval) { device->store(); } } sleep(interval_seconds); if (round >= store_interval) { round = 0; } } } else { log_debug("could not find 1-wire devices.\n"); } return 0; }