Helper to debug xiaomi motorized camera

This commit is contained in:
Pierre-Hugues Husson 2019-06-03 10:08:36 +02:00
parent 7052b96cea
commit 819cbe360d
2 changed files with 50 additions and 0 deletions

View File

@ -99,3 +99,15 @@ cc_binary {
"libhidlbase", "libhidlbase",
], ],
} }
cc_binary {
name: "xiaomi-motor",
srcs: [
"xiaomi-motor.cpp",
],
shared_libs: [
"vendor.xiaomi.hardware.motor@1.0",
"libutils",
"libhidlbase",
],
}

38
cmds/xiaomi-motor.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <iostream>
#include <unistd.h>
#include <vendor/xiaomi/hardware/motor/1.0/IMotor.h>
using ::vendor::xiaomi::hardware::motor::V1_0::IMotor;
using ::android::sp;
int main(int argc, char **argv) {
auto svc = IMotor::getService();
if(svc == nullptr) {
std::cerr << "Failed getting IMotor" << std::endl;
return -1;
}
if(argc<2) {
std::cerr << "Usage: " << argv[0] << " <init|release|popup|takeback|takebackShortly>" << std::endl;
return -1;
}
std::string cmd(argv[1]);
if(cmd == "init") {
svc->init();
} else if(cmd == "release") {
svc->release();
} else if(cmd == "popup") {
if(argc!=3) {
std::cerr << "Usage: " << argv[0] << " " << argv[1] << " <cookie>" << std::endl;
return -1;
}
svc->popupMotor(atoi(argv[2]));
} else if(cmd == "takeback") {
if(argc!=3) {
std::cerr << "Usage: " << argv[0] << " " << argv[1] << " <cookie>" << std::endl;
return -1;
}
svc->takebackMotor(atoi(argv[2]));
} else if(cmd == "takebackShortly") {
svc->takebackMotorShortly();
}
}