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; } if(argc < 2) usage(argv[0]); YModule *module = yFindModule(argv[1]); // use serial or logical name if (module->isOnline()) { if (argc >= 3) { string newname = argv[2]; if (!yCheckLogicalName(newname)) { cerr << "Invalid name (" << newname << ")" << endl; usage(argv[0]); } module->set_logicalName(newname); module->saveToFlash(); } cout << "Current name: " << module->get_logicalName() << endl; } else { cout << argv[1] << " not connected (check identification and USB cable)" << endl; } yFreeAPI(); 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; } if(argc < 2) usage(argv[0]); YModule *module = yFindModule(argv[1]); // use serial or logical name if (module->isOnline()) { if (argc > 2) { if (string(argv[2]) == "ON") module->set_beacon(Y_BEACON_ON); else module->set_beacon(Y_BEACON_OFF); } cout << "serial: " << module->get_serialNumber() << endl; cout << "logical name: " << module->get_logicalName() << endl; cout << "luminosity: " << module->get_luminosity() << endl; cout << "beacon: "; if (module->get_beacon()==Y_BEACON_ON) cout << "ON" << endl; else cout << "OFF" << endl; cout << "upTime: " << module->get_upTime()/1000 << " sec" << endl; cout << "USB current: " << module->get_usbCurrent() << " mA" << endl; cout << "Logs:"<< endl << module->get_lastLogs() << endl; } else { cout << argv[1] << " not connected (check identification and USB cable)" << endl; } return 0; }