HubCtlManager.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 #include "dpyError.h"
6 
7 namespace dpyHubCtrl {
8 
10 enum portAction
11 {
12  POWER_KEEP = -1,
13  POWER_OFF = 0,
14  POWER_ON = 1,
15  POWER_CYCLE = 2
16 };
17 
19 enum portStatus
20 {
21  ERROR = -1,
22  OFF = 0,
23  POWER = 1,
24 };
25 
27 struct deviceInfo
28 {
29  std::string vendor;
30  std::string product;
31  std::string serial;
32  std::string description;
33 };
34 
37 {
38  portStatus status;
40 };
41 
43 struct hubInfo
44 {
45  int bcd_usb;
46  int nports;
47  int ppps;
48  int actionable;
49  std::string container_id;
50  std::string vendor;
51  std::string location;
52  int level;
54  std::vector<hubPortDeviceInfo> portsInfo;
55 };
56 
57 }
64 {
65 private:
66 
71 
72  int hub_count = 0;
73  int getPortStatus(struct hub_info * hub, int portmask, std::vector<dpyHubCtrl::hubPortDeviceInfo> & portsInfo);
74 
75 public:
79  virtual ~HubCtrlManager();
80 
81  HubCtrlManager(const HubCtrlManager&) = delete;
82  HubCtrlManager& operator=(const HubCtrlManager &) = delete;
83  HubCtrlManager(HubCtrlManager &&) = delete;
84  HubCtrlManager & operator=(HubCtrlManager &&) = delete;
85 
86  boost::system::error_code changePowerState(std::string hub, int port, dpyHubCtrl::portAction state);
87  int findHubs(std::vector<dpyHubCtrl::hubInfo> & hub_info);
88 
93  static auto& getInstance()
94  {
95  static HubCtrlManager instance;
96  return instance;
97  }
98 
99 };
deviceInfo device_info
HUB information.
Definition: HubCtlManager.h:53
Power On.
Definition: mcuApi.h:46
std::string container_id
container ID as hex string
Definition: HubCtlManager.h:49
USB port information.
Definition: HubCtlManager.h:36
USB device information.
Definition: HubCtlManager.h:27
portStatus status
USB status.
Definition: HubCtlManager.h:38
int ppps
Per Port Power Switching)
Definition: HubCtlManager.h:47
std::string vendor
USB port vendor id.
Definition: HubCtlManager.h:29
std::string vendor
Id vendor.
Definition: HubCtlManager.h:50
USB HUB information.
Definition: HubCtlManager.h:43
int bcd_usb
USB specification release number in binary-coded decimal. A value of 0x0200 indicates USB 2...
Definition: HubCtlManager.h:45
std::string serial
USB port serial number.
Definition: HubCtlManager.h:31
std::vector< hubPortDeviceInfo > portsInfo
Information about ports.
Definition: HubCtlManager.h:54
std::string location
Location in soc.
Definition: HubCtlManager.h:51
int level
Signal level.
Definition: HubCtlManager.h:52
int nports
Number of port in usb.
Definition: HubCtlManager.h:46
Definition: HubCtlManager.h:7
int actionable
true if this hub is subject to action
Definition: HubCtlManager.h:48
std::string description
USB port description.
Definition: HubCtlManager.h:32
Class to control USB Hubs.
Definition: HubCtlManager.h:63
deviceInfo device_info
USB information about connected device.
Definition: HubCtlManager.h:39
Shutdown.
Definition: scmTypes.h:26
static auto & getInstance()
Definition: HubCtlManager.h:93
ERROR.
Definition: mcuApi.h:87
std::string product
USB port product id.
Definition: HubCtlManager.h:30