usb_device_libusb.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. #ifndef USB_DEVICE_LIBUSB_HPP
  9. #define USB_DEVICE_LIBUSB_HPP
  10. #include "types.h"
  11. #include "dsi_libusb_library.hpp"
  12. #include "usb_device.hpp"
  13. //////////////////////////////////////////////////////////////////////////////////
  14. // Public Definitions
  15. //////////////////////////////////////////////////////////////////////////////////
  16. //!!What happens if we release the list we got this device from?
  17. class USBDeviceLibusb : public USBDevice
  18. {
  19. public:
  20. USBDeviceLibusb(struct usb_device& stDevice_);
  21. USBDeviceLibusb(const USBDeviceLibusb& clDevice_);
  22. USBDeviceLibusb& operator=(const USBDeviceLibusb& clDevice_);
  23. struct usb_device& GetRawDevice() const { return *pstDevice; }
  24. //USBDevice Base//
  25. BOOL USBReset() const;
  26. USHORT GetVid() const { return usVid; }
  27. USHORT GetPid() const { return usPid; }
  28. ULONG GetSerialNumber() const { return ulSerialNumber; }
  29. BOOL GetProductDescription(UCHAR* pucProductDescription_, USHORT usBufferSize_) const; //guaranteed to be null-terminated
  30. BOOL GetSerialString(UCHAR* pucSerialString_, USHORT usBufferSize_) const;
  31. DeviceType::Enum GetDeviceType() const { return DeviceType::LIBUSB; }
  32. //std::auto_ptr<USBDevice> MakeCopy() const { return auto_ptr<USBDevice>(new USBDeviceSI(*this)); }
  33. ////
  34. private:
  35. BOOL GetDeviceSerialNumber(ULONG& ulSerialNumber_);
  36. struct usb_device* pstDevice; //should we copy instead?
  37. USHORT usVid;
  38. USHORT usPid;
  39. ULONG ulSerialNumber;
  40. UCHAR szProductDescription[USB_MAX_STRLEN];
  41. UCHAR szSerialString[USB_MAX_STRLEN];
  42. };
  43. #endif // !defined(USB_DEVICE_LIBUSB_HPP)