Make Send Command feature more flexible
The sendOemCommand command, used to send NCSI_CMD_SEND_CMD payloads,
is hardcoded to only send one command.
Update the sendOemCommand function to allow the sub-operation to be
passed as a command line argument. This is done by prepending the
sub-operation byte to the front of the Send Cmd payload.
Doing this allows sub-operations without any payload bytes to be
called. For example "-o 0a", where the sub-operation for Send Cmd is
the 0x0a value.
Tested:
Sent 'ncsi-netlink -x 3 -p 0 -c 0 -o 50000001572100' and confirmed
the 0x50 byte worked the same way as the original hard-coded value.
Sent 'ncsi-netlink -x 3 -p 0 -c 0 -o 0a' and confirmed the 0x0a
sub-operation functioned on the submitters SUT.
Change-Id: I20f093fd8296f549fce03dc5729b8e5fedcab313
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/src/argument.cpp b/src/argument.cpp
index 0c49b11..6bc40bc 100644
--- a/src/argument.cpp
+++ b/src/argument.cpp
@@ -66,18 +66,29 @@
void ArgumentParser::usage(char** argv)
{
std::cerr << "Usage: " << argv[0] << " [options]\n";
- std::cerr << "Options:\n";
- std::cerr << " --help Print this menu.\n";
- std::cerr << " --info=<info> Retrieve info about NCSI topology.\n";
- std::cerr << " --set=<set> Set a specific package/channel.\n";
std::cerr
- << " --clear=<clear> Clear all the settings on the interface.\n";
- std::cerr
- << " --oem-payload=<hex data> Send an OEM command with payload.\n";
- std::cerr << " --package=<package> Specify a package.\n";
- std::cerr << " --channel=<channel> Specify a channel.\n";
- std::cerr << " --index=<device index> Specify device ifindex.\n";
- std::cerr << std::flush;
+ << "Options:\n"
+ " --help | -h Print this menu.\n"
+ " --index=<device index> | -x <device index> Specify device ifindex.\n"
+ " --package=<package> | -p <package> Specify a package.\n"
+ " --channel=<channel> | -c <channel> Specify a channel.\n"
+ " --info | -i Retrieve info about NCSI topology.\n"
+ " --set | -s Set a specific package/channel.\n"
+ " --clear | -r Clear all the settings on the interface.\n"
+ " --oem-payload=<hex data...> | -o <hex data...> Send an OEM command with payload.\n"
+ "\n"
+ "Example commands:\n"
+ " 1) Retrieve topology information:\n"
+ " ncsi-netlink -x 3 -p 0 -i\n"
+ " 2) Set preferred package\n"
+ " ncsi-netlink -x 3 -p 0 -s\n"
+ " 3) Set preferred channel\n"
+ " ncsi-netlink -x 3 -p 0 -c 1 -s\n"
+ " 4) Clear preferred channel\n"
+ " ncsi-netlink -x 3 -p 0 -r\n"
+ " 5) Send NCSI Command\n"
+ " ncsi-netlink -x 3 -p 0 -c 0 -o 50000001572100\n"
+ "\n";
}
const option ArgumentParser::options[] = {
@@ -92,7 +103,7 @@
{0, 0, 0, 0},
};
-const char* ArgumentParser::optionStr = "i:s:r:o:p:c:x:h?";
+const char* ArgumentParser::optionStr = "irsx:o:p:c:h?";
const std::string ArgumentParser::trueString = "true";
const std::string ArgumentParser::emptyString = "";