dsi_serial_generic.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2014
  6. All rights reserved.
  7. */
  8. #if !defined(DSI_SERIAL_GENERIC_HPP)
  9. #define DSI_SERIAL_GENERIC_HPP
  10. #include "types.h"
  11. #include "dsi_thread.h"
  12. #include "dsi_serial.hpp"
  13. #include "usb_device.hpp"
  14. #include "usb_device_handle.hpp"
  15. #include "usb_device_list.hpp"
  16. //////////////////////////////////////////////////////////////////////////////////
  17. // Public Class Prototypes
  18. //////////////////////////////////////////////////////////////////////////////////
  19. class DSISerialGeneric : public DSISerial
  20. {
  21. private:
  22. DSI_THREAD_ID hReceiveThread; // Handle for the receive thread.
  23. DSI_MUTEX stMutexCriticalSection; // Mutex used with the wait condition
  24. DSI_CONDITION_VAR stEventReceiveThreadExit; // Event to signal the receive thread has ended.
  25. BOOL bStopReceiveThread; // Flag to stop the receive thread.
  26. USBDeviceHandle* pclDeviceHandle; // Handle to the USB device.
  27. const USBDevice* pclDevice;
  28. UCHAR ucDeviceNumber;
  29. ULONG ulBaud;
  30. static time_t lastUsbResetTime;
  31. // Private Member Functions
  32. void ReceiveThread();
  33. static DSI_THREAD_RETURN ProcessThread(void *pvParameter_);
  34. public:
  35. DSISerialGeneric();
  36. ~DSISerialGeneric();
  37. BOOL Init(ULONG ulBaud_, UCHAR ucDeviceNumber_);
  38. BOOL Init(ULONG ulBaud_, const USBDevice& clDevice_, UCHAR ucDeviceNumber_);
  39. void USBReset();
  40. UCHAR GetNumberOfDevices();
  41. // Methods inherited from the base class:
  42. BOOL AutoInit();
  43. ULONG GetDeviceSerialNumber();
  44. BOOL Open();
  45. void Close(BOOL bReset = FALSE);
  46. BOOL WriteBytes(void *pvData_, USHORT usSize_);
  47. UCHAR GetDeviceNumber();
  48. BOOL GetDeviceUSBInfo(UCHAR ucDevice_, UCHAR* pucProductString_, UCHAR* pucSerialString_, USHORT usBufferSize_);
  49. BOOL GetDevicePID(USHORT& usPid_);
  50. BOOL GetDeviceVID(USHORT& usVid_);
  51. BOOL GetDeviceSerialString(UCHAR* pucSerialString_, USHORT usBufferSize_);
  52. };
  53. #endif // !defined(DSI_SERIAL_GENERIC_HPP)