aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Campbell <leecam@google.com>2016-03-03 12:17:23 -0800
committerLee Campbell <leecam@google.com>2016-03-03 20:57:04 +0000
commit52373993181972ec6629d0c4e39ef86d448799d5 (patch)
treea5012d7c269e9ea1b5664d534be43a8eef94460a
parent6196081a689aa9f4457458848c90d2d5362e0ddc (diff)
downloadperipheralmanager-52373993181972ec6629d0c4e39ef86d448799d5.tar.gz
Add --pin arg to example
Now example can be ran as follows: peripheralmanager_example --pin=IO18 This allows for easier testing of GPIO pins BUG: 26778811 Change-Id: I713630ad14fd575bd28d880c94cb1a8ea5152361 TEST: All the gpio pins on edison work.
-rw-r--r--example/peripheralmanager_example.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/example/peripheralmanager_example.cc b/example/peripheralmanager_example.cc
index 4348baf..136e0b9 100644
--- a/example/peripheralmanager_example.cc
+++ b/example/peripheralmanager_example.cc
@@ -29,10 +29,17 @@
#include <peripheralmanager/peripheral_manager_client.h>
int main(int argc, char* argv[]) {
+ DEFINE_string(pin, "", "Pin to toggle");
brillo::FlagHelper::Init(argc, argv, "Example PeripheralManager client.");
logging::InitLogging(logging::LoggingSettings());
android::BinderWrapper::Create();
+ std::string pin_name = "IO13";
+ if (!FLAGS_pin.empty())
+ pin_name = FLAGS_pin;
+
+ LOG(INFO) << "Toggling Pin " << pin_name;
+
// Get a client to the PeripheralManager.
BPeripheralManagerClient* client = BPeripheralManagerClient_new();
@@ -41,9 +48,9 @@ int main(int argc, char* argv[]) {
return 1;
}
- // Open GPIO pin IO13.
+ // Open GPIO pin.
BGpio* my_gpio;
- if (BPeripheralManagerClient_openGpio(client, "IO13", &my_gpio) !=
+ if (BPeripheralManagerClient_openGpio(client, pin_name.c_str(), &my_gpio) !=
PERIPHERAL_IO_OK) {
LOG(ERROR) << "Failed to open Gpio";
return 1;