summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Device/Device.cpp18
-rw-r--r--src/MtsIoSysfs.cpp15
2 files changed, 21 insertions, 12 deletions
diff --git a/src/Device/Device.cpp b/src/Device/Device.cpp
index e7e295b..2b56895 100644
--- a/src/Device/Device.cpp
+++ b/src/Device/Device.cpp
@@ -489,6 +489,7 @@ void Device::printUsage(std::string program) {
printf(" : is an expected full path. i.e. /dev/spidevX.X\n");
printf(" -i, --input : input file for upgrade\n");
printf(" : files are stored in /usr/lib/mts-flash-binaries\n");
+ printf(" -u, --duration : optional field for <store> operation. it defines in milliseconds\n");
printf("Usage:\n");
printf(" Load : mts-io-sysfs -l -p <path> -i <file>\n");
printf(" Check : mts-io-sysfs -c -p <path>\n");
@@ -765,16 +766,12 @@ void Device::store(std::string name, std::string value) {
if (gr.request()) {
retval = gpiod_line_request_set_value(gr.request(),gr.offset(),lv);
- if(retval != -1) {
- storeOutputStateToNonvolatile(name, value);
- exitHandler(0);
- }
- else
+ if(retval == -1) {
simpleError("Could not set GPIO value",errno,111);
+ }
}
}
}
-
std::ofstream fileToWrite(SYSFS_PLATFORM + name);
if (fileToWrite.is_open()) {
fileToWrite << value;
@@ -783,13 +780,12 @@ void Device::store(std::string name, std::string value) {
name.c_str(),strerror(errno));
exitHandler(98);
}
- storeOutputStateToNonvolatile(name, value);
fileToWrite.close();
- exitHandler(0);
+ } else {
+ printError("Can't open %s%s: %s", SYSFS_PLATFORM,
+ name.c_str(),strerror(errno));
+ exitHandler(99);
}
- printError("Can't open %s%s: %s", SYSFS_PLATFORM,
- name.c_str(),strerror(errno));
- exitHandler(99);
}
void Device::storeTrigger(std::string name, std::string value) {
diff --git a/src/MtsIoSysfs.cpp b/src/MtsIoSysfs.cpp
index cea2537..ab68c8c 100644
--- a/src/MtsIoSysfs.cpp
+++ b/src/MtsIoSysfs.cpp
@@ -52,6 +52,7 @@ int main(int argc, char **argv) {
std::string forcedAP = "";
std::string name = "";
std::string data = "";
+ int duration = 0;
MTS::Logger::setPrintLevel(MTS::Logger::PrintLevel::INFO_LEVEL, true);
int c;
@@ -67,6 +68,7 @@ int main(int argc, char **argv) {
{"show", required_argument, nullptr, 's'},
{"show-trigger", required_argument, nullptr, 'S'},
{"store", required_argument, nullptr, 't'},
+ {"duration", required_argument, nullptr, 'u'},
{"store-trigger", required_argument, nullptr, 'T'},
{"version", no_argument, nullptr, 'v'},
{"verbose", no_argument, nullptr, 'V'},
@@ -75,7 +77,7 @@ int main(int argc, char **argv) {
for (;;) {
int option_index = 0;
- c = getopt_long(argc, argv, "cd:hi:Ijlp:s:St:T:vV", long_options,
+ c = getopt_long(argc, argv, "cd:hi:Ijlp:s:St:T:vVu:", long_options,
&option_index);
if (c == -1)
break;
@@ -132,6 +134,10 @@ int main(int argc, char **argv) {
name = optarg;
break;
}
+ case 'u': {
+ duration = atoi(optarg);
+ break;
+ }
case 'T': {
action = ACTION_STORE_TRIGGER;
name = optarg;
@@ -217,6 +223,13 @@ int main(int argc, char **argv) {
}
case ACTION_STORE: {
m.store(name, data);
+ if (duration) {
+ usleep(1000 * duration);
+ data = data == "0" ? "1" : "0";
+ m.store(name, data);
+ }
+ m.storeOutputStateToNonvolatile(name, data);
+ break;
}
case ACTION_STORE_TRIGGER: {
m.storeTrigger(name, data);