summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Malinowski <a.malinowsk2@partner.samsung.com>2016-01-18 09:28:21 +0100
committerAdam Malinowski <a.malinowsk2@partner.samsung.com>2016-04-26 17:43:05 +0200
commitdf520279a14bc3800a9b9dca6d52023aad62dcc7 (patch)
treee63af22f4f2053177151adc5158fa22a86cdca5a
parent8f58d62dc43807f755b3730a786a8c1340ef1d73 (diff)
downloadsd-mux-df520279a14bc3800a9b9dca6d52023aad62dcc7.tar.gz
sd-mux-df520279a14bc3800a9b9dca6d52023aad62dcc7.tar.bz2
sd-mux-df520279a14bc3800a9b9dca6d52023aad62dcc7.zip
Add command for getting current state of device
Change-Id: I2c67d15c76e59fd4762f79bbdd059c30e5d467ef
-rw-r--r--src/main.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 390e603..bc92f6e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,6 +47,7 @@ enum CCCommand {
CCC_ShowSerial,
CCC_SetSerial,
CCC_Init,
+ CCC_Status,
CCC_None
};
@@ -393,6 +394,26 @@ int setPins(unsigned char pins, CCOptionValue options[]) {
return ret;
}
+int showStatus(CCOptionValue options[]) {
+ unsigned char pins;
+ struct ftdi_context *ftdi = prepareDevice(options, &pins);
+ if (ftdi == NULL)
+ return EXIT_FAILURE;
+
+ ftdi_usb_close(ftdi);
+ ftdi_free(ftdi);
+
+ if (!(pins & POWER_SW_ON && pins & POWER_SW_OFF)) {
+ fprintf(stdout, "Device not initialized!\n");
+ return 0;
+ }
+
+ fprintf(stdout, "USB connected to: %s\n", pins & USB_SEL ? "TS" : "DUT");
+ fprintf(stdout, "SD connected to: %s\n", pins & SOCKET_SEL ? "TS" : "DUT");
+
+ return 0;
+}
+
int parseArguments(int argc, const char **argv, CCCommand *cmd, int *arg, char *args, size_t argsLen,
CCOptionValue options[]) {
char c;
@@ -410,6 +431,7 @@ int parseArguments(int argc, const char **argv, CCCommand *cmd, int *arg, char *
{ "ts", 's', POPT_ARG_NONE, NULL, 's', "connects SD card and USB to the test server", NULL },
{ "pins", 'p', POPT_ARG_INT, arg, 'p', "write pin state in bitbang mode", NULL },
{ "tick", 'c', POPT_ARG_NONE, NULL, 'c', "turn off and on power supply of DUT", NULL },
+ { "status", 'u', POPT_ARG_NONE, NULL, 'u', "show current status: DUT or TS or NOINIT", NULL },
// Options
{ "tick-time", 'm', POPT_ARG_INT, &options[CCO_TickTime].argn, 'm', "set time delay for 'tick' command",
NULL },
@@ -458,6 +480,9 @@ int parseArguments(int argc, const char **argv, CCCommand *cmd, int *arg, char *
case 'c':
*cmd = CCC_Tick;
break;
+ case 'u':
+ *cmd = CCC_Status;
+ break;
case 'n':
options[CCO_BitsInvert].argn = 1;
break;
@@ -513,6 +538,8 @@ int main(int argc, const char **argv) {
return doPower(true, true, options);
case CCC_Pins:
return setPins((unsigned char)arg, options);
+ case CCC_Status:
+ return showStatus(options);
}
return 0;