Initial commit
[remote/remote-mci.git] / diku_mch / Configuration.cc
blob6d9680d80c3a3da0719fbc7250be070978d35563
1 #include "Configuration.h"
3 namespace remote { namespace diku_mch {
5 void Configuration::read( int ac, char** av )
9 // command line options
10 po::options_description cmdline_options("commandlineoptions");
11 cmdline_options.add_options()
12 ("config-file",
13 po::value<std::string>()->default_value("/etc/diku_mch.cfg"),
14 "Path to the configuration file.")
15 ("daemonize",
16 po::value<int>()->default_value(false),
17 "Run as a daemon.");
19 // declare all configuration groups
20 po::options_description config("Configuration");
22 config.add_options()
23 ("usbserialPath",
24 po::value<std::string>()->default_value("/proc/tty/driver/usbserial"),
25 "Path to the usbserial device file.")
26 ("usbdevicePath",
27 po::value<std::string>()->default_value("/proc/bus/usb/devices"),
28 "Path to the usb system device file.")
29 ("usbPlugEventPipe",
30 po::value<std::string>()->default_value("/var/run/motehost.events"),
31 "Path to the fifo notifying the motehost of mote hotplug events.")
32 ("macPrefix",
33 po::value<uint64_t>()->default_value(0x0050C237),
34 "The initial part of MAC adresses for DIG528-2 boards.")
35 ("vendorId",
36 po::value<std::string>()->default_value("0050"),
37 "USB Vendor ID for the DIG528-2 boards.")
38 ("productId",
39 po::value<std::string>()->default_value("c237"),
40 "USB Product ID for the DIG528-2 boards.")
41 ("usbSerialDevicePath",
42 po::value<std::string>()->default_value("/dev/ttyUSB%u"),
43 "Path pattern of usb devices.")
44 ("maxDeviceFileSize",
45 po::value<uint16_t>()->default_value(10000),
46 "Maximum size in bytes of the device info files.")
47 ("serverAddress",
48 po::value<std::string>(),
49 "DNS or IP address of the mote server.")
50 ("serverPort",
51 po::value<uint16_t>()->default_value(10001),
52 "Port number to use for connecting to the mote server.")
53 ("serverConnectionRetryInterval",
54 po::value<uint64_t>()->default_value(30),
55 "Number of seconds to wait between server connection retries.")
56 ("moteProgrammerPath",
57 po::value<std::string>()->default_value("/usr/bin/hc08sprg"),
58 "Path to the DIG528-2 flash programmer.")
59 ("flashImagePath",
60 po::value<std::string>()->default_value("/var/run/motehost_flash%u.s19"),
61 "Temporary naming of flash image files.")
64 store(po::parse_command_line(ac, av, cmdline_options), vm);
65 notify(vm);
67 // get the configuration settings from a file
68 std::ifstream ifs(Configuration::vm["config-file"].as<std::string>().c_str());
69 store(parse_config_file(ifs, config), vm);
70 notify(vm);
73 po::variables_map Configuration::vm;