ykush.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*******************************************************************************
  2. Copyright 2017 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. #ifndef _YKUSH_H_
  14. #define _YKUSH_H_
  15. #include <yk_usb_device.h>
  16. #include <command_parser.h>
  17. /**
  18. * \defgroup ykush YKUSH boards
  19. */
  20. /**
  21. * \ingroup ykush
  22. * \brief Available options for YKUSH boards.
  23. */
  24. enum ykushAction {
  25. YKUSH_PORT_UP,
  26. YKUSH_PORT_DOWN,
  27. YKUSH_PORT_STATUS,
  28. YKUSH_LIST_BOARDS,
  29. YKUSH_GET_STATUS,
  30. YKUSH_HELP
  31. };
  32. /**
  33. * \ingroup ykush
  34. * \brief Handles the YKUSH device.
  35. */
  36. class Ykush : public UsbDevice
  37. {
  38. public:
  39. Ykush(unsigned int pid)
  40. : UsbDevice(0x04D8, pid)
  41. {
  42. if( pid == 0x0042 ) {
  43. is_legacy = true;
  44. } else {
  45. is_legacy = false;
  46. }
  47. non_blocking_usb_comm = false;
  48. }
  49. int get_port_status(char *serial, char port); //get downstream port status
  50. /**
  51. * \brief Switch ON YKUSH downstream(s).
  52. *
  53. */
  54. int port_up(char *serial, char port);
  55. int port_down(char *serial, char port);
  56. void print_help(char *exec_name);
  57. private:
  58. bool is_legacy;
  59. bool non_blocking_usb_comm;
  60. };
  61. //---------------------------------
  62. //FUNCTIONS
  63. //---------------------------------
  64. int ykush_cmd_parser(int argc, char** argv);
  65. void ykush_help(char * execName);
  66. void ykush_up(char * iserial);
  67. void ykush_down(char * iserial);
  68. int ykush_list_attached(void);
  69. #endif