Device *device;
string id;
int err_flg;
+ Data *data;
+ dev_lst = NULL;
controller = new DeviceManagerController();
if (controller != NULL) {
dev_lst = controller->get_device_list(&err_flg);
- if (err_flg == PLP_OK) {
- if (dev_lst != NULL) {
- for (dev_iter = ((list<Device *> *)dev_lst)->begin(); dev_iter != ((list<Device *> *)dev_lst)->end(); dev_iter++) {
- device = (Device *)*dev_iter;
- id = device->get_id();
- device->printout();
- log_info("id: %s\n", id.c_str());
- controller->get_latest_data(id, &err_flg);
- if (err_flg == PLP_OK) {
- log_info("latest data:\n");
- }
- else {
- log_error("Could not get latest data for device id: %s\n", id.c_str());
- }
+ if ((err_flg == PLP_OK) &&
+ (dev_lst != NULL)) {
+ for (dev_iter = ((list<Device *> *)dev_lst)->begin(); dev_iter != ((list<Device *> *)dev_lst)->end(); dev_iter++) {
+ device = (Device *)*dev_iter;
+ id = device->get_id();
+ device->printout();
+ log_info("id: %s\n", id.c_str());
+ data = controller->get_latest_data(id, &err_flg);
+ if ((data != NULL) &&
+ (err_flg == PLP_OK)) {
+ log_info("latest data:\n");
+ data->printout();
+ delete(data);
+ }
+ else {
+ log_error("Could not get latest data for device id: %s\n", id.c_str());
}
- }
- else {
- log_error("Could not get device list, device list NULL");
}
}
else {
- log_error("Could not get device list, error code: %d", err_flg);
+ log_error("Could not get device list, device list NULL or error code returned.\n");
}
+ //if (dev_lst != NULL)
+ // delete(dev_lst);
delete(controller);
sleep(3);
}
succ = parse_long(argv[2], &interval_sec);
if (succ == false) {
interval_sec = DEFAULT_READ_INTERVAL_SEC;
- log_error("failed to parse read interval parameter, using default value: %ld", interval_sec);
+ log_error("failed to parse read interval parameter, using default value: %ld\n", interval_sec);
printout_usage();
}
}