ykushcmd-reference-ykush3.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <h1>YKUSH3 Board Commands</h1>
  2. <div class="reference_page_toc">
  3. <ul>
  4. <li><a href="#command_overview">Command overview</a></li>
  5. <li><a href="#list_attached_example">List attached boards</a></li>
  6. <li><a href="#switch_command_example">Downstream port On/Off switching</a></li>
  7. <li><a href="#switch_state_command_example">Port switching state</a></li>
  8. <li><a href="#gpio_read_write_command_example">GPIO read/write</a></li>
  9. <li><a href="#reset_command_example">Reset/reboot board</a></li>
  10. </ul>
  11. </div>
  12. <h2 id="command_overview">Command overview</h2>
  13. <p>YKUSH3 board commands have the following structure.</p>
  14. <p class="command_line">ykushcmd ykush3 [-s serial_number] [OPTION]</p>
  15. <p>Where:</p>
  16. <table cellpadding="10">
  17. <tr>
  18. <td width="30%" valign="top">-s serial_number</td>
  19. <td>
  20. Board serial number to which the command is addressed.
  21. When multiple YKUSH boards are connected to a host, this option should be used
  22. to specify the board. If more than one board is connected and this option is not
  23. provided the command will be sent to the first board in the USB enumeration list.
  24. </td>
  25. </tr>
  26. <tr>
  27. <td valign="top">-l</td>
  28. <td>
  29. List attached YKUSH3 boards.
  30. The serial number of each board attached to the host will be displayed.
  31. </td>
  32. </tr>
  33. <tr>
  34. <td valign="top">-d 1|2|3|a</td>
  35. <td>
  36. Power Down/Off downstream port with the number provided.
  37. If <i>a</i> is provided as the port number then all ports will be switched.
  38. </td>
  39. </tr>
  40. <tr>
  41. <td valign="top">-u 1|2|3|a</td>
  42. <td>
  43. Power Up/On downstream port with the number provided.
  44. If <i>a</i> is provided as the port number then all ports will be switched.
  45. </td>
  46. </tr>
  47. <tr>
  48. <td>-g 1|2|3</td>
  49. <td>
  50. Get port state.
  51. </td>
  52. </tr>
  53. <tr>
  54. <td valign="top">-on</td>
  55. <td>
  56. Switch On the 5V output power port.
  57. </td>
  58. </tr>
  59. <tr>
  60. <td valign="top">-off</td>
  61. <td>
  62. Switch Off the 5V output power port.
  63. </td>
  64. </tr>
  65. <tr>
  66. <td valign="top">-r 1|2|3</td>
  67. <td>
  68. Read GPIO with the number provided (1, 2 or 3).
  69. </td>
  70. </tr>
  71. <tr>
  72. <td valign="top">-w 1|2|3 0|1</td>
  73. <td>
  74. Write to the GPIO with the number provided (1, 2 or 3).
  75. Writing a value of <b>1</b> or <b>0</b> will drive the GPIO to logical <b>high</b> or <b>low</b>, respectively.
  76. </td>
  77. </tr>
  78. <tr>
  79. <td valign="top">--reset</td>
  80. <td>
  81. Resets (reboot) the YKUSH3 board.
  82. </td>
  83. </tr>
  84. </table>
  85. <h2 id="list_attached_example">List attached boards</h2>
  86. <p>
  87. The <b>[-l]</b> option is used to list all attached YKUSH3 boards.
  88. All YKUSH board have unique serial numbers which are displayed when this option is used.
  89. </p>
  90. <pre>
  91. <code class="language-bash">
  92. #list the serial number for each of the attached YKUSH3 boards
  93. $ ykushcmd ykush3 -l
  94. Attached YKUSH3 Boards:
  95. 1. Board found with serial number: YK17125
  96. 2. Board found with serial number: YK21493
  97. </code>
  98. </pre>
  99. <h2 id="switch_command_example">Downstream port On/Off switching</h2>
  100. <p>
  101. When only one YKUSH3 board is attached to the host the <b>[-s serial_number]</b> option is not required.
  102. Bellow are some examples.
  103. </p>
  104. <pre>
  105. <code class="language-bash">
  106. #power-down downstream port 1
  107. $ ykushcmd ykush3 -d 1
  108. #power-down downstream port 2
  109. $ ykushcmd ykush3 -d 2
  110. #power down downstream port 3
  111. $ ykushcmd ykush3 -d 3
  112. #power-down all three downstream ports
  113. $ ykushcmd ykush3 -d a
  114. #power-up downstream port 1
  115. $ ykushcmd ykush3 -u 1
  116. #power-up downstream port 2
  117. $ ykushcmd ykush3 -u 2
  118. #power-up downstream port 3
  119. $ ykushcmd ykush3 -u 3
  120. #power-up all three downstream ports
  121. $ ykushcmd ykush3 -u a
  122. </code>
  123. </pre>
  124. <p>
  125. If more than one YKUSH3 board is attached to the host the <b>[-s serial_number]</b> option should be used.
  126. Bellow are some examples.
  127. </p>
  128. <pre>
  129. <code class="language-bash">
  130. #list the serial number for each of the attached YKUSH3 boards
  131. $ ykushcmd ykush3 -l
  132. Attached YKUSH3 Boards:
  133. 1. Board found with serial number: YK17125
  134. 2. Board found with serial number: YK21493
  135. #power-down downstream port 1 of the board with serial number YK17125
  136. $ ykushcmd ykush3 -s YK17125 -d 1
  137. #power-down downstream port 1 of the board with serial number YK21493
  138. $ ykushcmd ykush3 -s YK21493 -d 1
  139. #power-down downstream port 3
  140. $ ykushcmd ykush3 -d 3
  141. #power-down all three downstream ports of the board with serial number YK21493
  142. $ ykushcmd ykush3 -s YK21493 -d a
  143. </code>
  144. </pre>
  145. <h2 id="switch_state_command_example">Port switching state</h2>
  146. <p>
  147. The current switching state of each downstream port can be fetched from the YKUSH3 board using the <b>[-g 1|2|3]</b> option.
  148. </p>
  149. <pre>
  150. <code class="language-bash">
  151. #State of downstream port 1
  152. $ ykushcmd ykush3 -g 1
  153. Downstream port 1 is ON
  154. #power-down downstream port 1
  155. $ ykushcmd ykush3 -d 1
  156. #State of downstream port 1
  157. $ ykushcmd ykush3 -g 1
  158. Downstream port 1 is OFF
  159. #list the serial number for each of the attached YKUSH boards
  160. $ ykushcmd ykush3 -l
  161. Attached YKUSH Boards:
  162. 1. Board found with serial number: YK17125
  163. 2. Board found with serial number: YK21493
  164. #State of downstream port 1 of the board with serial number YK17125
  165. $ ykushcmd ykush3 -s YK17125 -g 1
  166. Downstream port 1 is OFF
  167. #power-up downstream port 1 of the board with serial number YK17125
  168. $ ykushcmd ykush3 -s YK17125 -u 1
  169. </code>
  170. </pre>
  171. <h2 id="gpio_read_write_command_example">GPIO read/write</h2>
  172. <p>
  173. The <b>[-r|-w]</b> option is used to read from or write to a GPIO.
  174. </p>
  175. <pre>
  176. <code class="language-bash">
  177. #Writing a 0 to a GPIO will drive it to logical low (0V).
  178. #Example of writing value 0 to GPIO 1
  179. $ ykushcmd ykush3 -w 1 0
  180. #Writing a 1 to a GPIO will drive it to logical high (3.3V).
  181. #Example of writing value 1 to GPIO 1
  182. $ ykushcmd ykush3 -w 1 1
  183. #Example of writing value 1 to GPIO 2
  184. $ ykushcmd ykush3 -w 2 1
  185. #Reading from a GPIO will get the digital value of that pin,
  186. #0 if Low and 1 if High.
  187. #Example of reading from GPIO 3
  188. $ ykushcmd ykush3 -r 3
  189. </code>
  190. </pre>
  191. <h2 id="reset_command_example">Reset/reboot board</h2>
  192. <p>
  193. The <b>[--reset]</b> option is used to reset (reboot) the board.
  194. </p>
  195. <pre>
  196. <code class="language-bash">
  197. #Example of resetting YKUSH3
  198. $ ykushcmd ykush3 --reset
  199. </code>
  200. </pre>