int main(int argc, const char * argv[]) { int i; string errmsg; vector<string> hubs; vector<string> shield; vector<string> devices; // Setup the API to use local USB devices if(YAPI::RegisterHub("usb", errmsg) != YAPI_SUCCESS) { cerr << "RegisterHub error: " << errmsg << endl; return 1; } for (i = 1; i < argc; i++) { string hub_url = string(argv[i]); cout << "Update module connected to hub " << hub_url << endl; if(YAPI::RegisterHub(hub_url, errmsg) != YAPI_SUCCESS) { cerr << "RegisterHub error: " << errmsg << endl; return 1; } } //first step construct the list of all hub /shield and devices connected YModule *module = YModule::FirstModule(); while (module){ string product = module->get_productName(); string serial = module->get_serialNumber(); if (product == "YoctoHub-Shield") { shield.push_back(serial); } else if (product.substr(0,9) == "YoctoHub-") { hubs.push_back(serial); } else if (product != "VirtualHub"){ devices.push_back(serial); } module = module->nextModule(); } // first upgrades all Hubs... upgradeSerialList(hubs); // ... then all shield.. upgradeSerialList(shield); // ... and finaly all devices upgradeSerialList(devices); cout << "All devices are now up to date" << endl; YAPI::FreeAPI(); return 0; }
int main(int argc, const char * argv[]) { string errmsg; // Setup the API to use local USB devices if(yRegisterHub("usb", errmsg) != YAPI_SUCCESS) { cerr << "RegisterHub error: " << errmsg << endl; return 1; } cout << "Device list: " << endl; YModule *module = yFirstModule(); while (module != NULL) { cout << module->get_serialNumber() << " "; cout << module->get_productName() << endl; module = module->nextModule(); } return 0; }