ykush_help.cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*******************************************************************************
  2. Copyright 2019 Yepkit Lda (www.yepkit.com)
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. *******************************************************************************/
  13. #include "ykush_help.h"
  14. #include <iostream>
  15. #include <stdio.h>
  16. Help::Help(char *exec_name)
  17. {
  18. app_name = exec_name;
  19. }
  20. void Help::print_version(void)
  21. {
  22. std::cout << "YKUSHCMD Version 1.2.5\n";
  23. }
  24. void Help::print_usage(void)
  25. {
  26. std::cout << "Usage:\t" << app_name << " [board_name] [-s serial_number] [OPTION]...\n";
  27. std::cout << "Control Yepkit YKUSH family boards.\n";
  28. }
  29. void Help::print_board_names(void)
  30. {
  31. std::cout << "\nThe board_name specifies the board model being addressed.";
  32. std::cout << "If no board_name is provided the board is assumed to be a YKUSH board (board_name = ykush).\n";
  33. std::cout << "Board names:\n";
  34. std::cout << " ykush\t\tYKUSH board.\n";
  35. std::cout << " ykush3\t\tYKUSH3 board.\n";
  36. std::cout << " ykushxs\tYKUSHXS board.\n";
  37. std::cout << "The [board_name] must be provided for commands addressed for a specific board.\n";
  38. std::cout << "For general or common commands, applicable to all board models, the [board_name] is to ommited from the command.\n";
  39. }
  40. void Help::print_common_options(void)
  41. {
  42. }
  43. void Help::print_ykush(void)
  44. {
  45. std::cout << "\nYKUSH board options:\n";
  46. std::cout << "-d 1|2|3|a Power Down/Off downstream port with the number privided.\n";
  47. std::cout << " If [a] is provided as the port number then all ports will be switched.\n";
  48. std::cout << "-u 1|2|3|a Power Up/On downstream port number downstream_number\n";
  49. std::cout << "-s serial_number Board serial number to wich the command is addressed.\n";
  50. std::cout << " When multiple YKUSH boards are connected to a host, this option should be used\n";
  51. std::cout << " to specify the board. If more than one board is connected and this option is not\n";
  52. std::cout << " provided the command will be sent to the first board in the USB enumeration list.\n";
  53. std::cout << "-l Lists the serial numbers of the YKUSH boards attached to the host.\n";
  54. std::cout << "-g 1|2|3 Switching state of a downstream port.\n";
  55. std::cout << "-h Display help for YKUSH board specific commands.\n";
  56. }
  57. void Help::print_ykush2(void)
  58. {
  59. }
  60. void Help::print_ykush3(void)
  61. {
  62. std::cout << "\nYKUSH3 board options:\n";
  63. std::cout << "-d 1|2|3|a Power Down/Off downstream port with the number privided.\n";
  64. std::cout << " If [a] is provided as the port number then all ports will be switched.\n";
  65. std::cout << "-u 1|2|3|a Power Up/On downstream port number downstream_number\n";
  66. std::cout << "-s serial_number Board serial number to wich the command is addressed.\n";
  67. std::cout << " When multiple YKUSH boards are connected to a host, this option should be used\n";
  68. std::cout << " to specify the board. If more than one board is connected and this option is not\n";
  69. std::cout << " provided the command will be sent to the first board in the USB enumeration list.\n";
  70. std::cout << "-l Lists the serial numbers of the YKUSH boards attached to the host.\n";
  71. std::cout << "-g 1|2|3 Switching state of a downstream port.\n";
  72. std::cout << "-c <port-number> <config-value> Configure the default state of a downstream port\n";
  73. std::cout << " (port-number=1|2|3|e) at power-on. The port number <e> refers to exteranl 5V port.\n";
  74. std::cout << " The default states are off (config-value=0), on (config-value=1)\n";
  75. std::cout << " and persistent (config-value=2).\n";
  76. std::cout << "-on Switch On the 5V output power port.\n";
  77. std::cout << "-off Switch Off the 5V output power port.\n";
  78. std::cout << "-r 1|2|3 Read GPIO with the number provided (1, 2 or 3).\n";
  79. std::cout << "-w 1|2|3 0|1 Write to the GPIO with the number provided (1, 2 or 3).\n";
  80. std::cout << " Writing a value of 1 or 0 will drive the GPIO to logical high or low, respectively.\n";
  81. std::cout << "--gpio enable|disable Enable / Disable GPIO control interface. Will become active on next reset/power-on.\n\n";
  82. std::cout << "--reset Resets (reboot) the YKUSH3 board.\n";
  83. std::cout << "-h Display help for YKUSH board specific commands.\n";
  84. std::cout << "--bootloader-version Board bootloader version.\n";
  85. std::cout << "--firmware-version Board firmware version.\n";
  86. std::cout << "--boot Enter bootloader mode for firmware update.\n";
  87. }
  88. void Help::print_ykushxs(void)
  89. {
  90. std::cout << "\nYKUSHXS board options:\n";
  91. std::cout << "-d Power Down/Off the downstream port.\n";
  92. std::cout << "-u Power Up/On the downstream port\n";
  93. std::cout << "-s serial_number Board serial number to wich the command is addressed.\n";
  94. std::cout << " When multiple YKUSHXS boards are connected to a host, this option should be used\n";
  95. std::cout << " to specify the board. If more than one board is connected and this option is not\n";
  96. std::cout << " provided the command will be sent to the first board in the USB enumeration list.\n";
  97. std::cout << "-l Lists the serial numbers of the YKUSHXS boards attached to the host.\n";
  98. std::cout << "-g Switching state of a downstream port.\n";
  99. std::cout << "-h Display help for YKUSHXS board specific commands.\n";
  100. }
  101. void Help::print_all(void)
  102. {
  103. print_version();
  104. print_usage();
  105. print_board_names();
  106. print_ykush();
  107. print_ykush2();
  108. print_ykush3();
  109. print_ykushxs();
  110. }