dsi_serial_si.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_SI_HPP)
  9. #define DSI_SERIAL_SI_HPP
  10. #include "types.h"
  11. #include "dsi_thread.h"
  12. #include "dsi_serial.hpp"
  13. #include "dsi_serial_callback.hpp"
  14. #include "usb_device_si.hpp"
  15. #include "usb_device_handle_si.hpp"
  16. #include <windows.h>
  17. //////////////////////////////////////////////////////////////////////////////////
  18. // Public Definitions
  19. //////////////////////////////////////////////////////////////////////////////////
  20. //////////////////////////////////////////////////////////////////////////////////
  21. // Public Class Prototypes
  22. //////////////////////////////////////////////////////////////////////////////////
  23. class DSISerialSI : public DSISerial
  24. {
  25. private:
  26. DSI_THREAD_ID hReceiveThread; // Handle for the receive thread.
  27. DSI_MUTEX stMutexCriticalSection; // Mutex used with the wait condition
  28. DSI_CONDITION_VAR stEventReceiveThreadExit; // Event to signal the receive thread has ended.
  29. BOOL bStopReceiveThread; // Flag to stop the receive thread.
  30. USBDeviceHandleSI* pclDeviceHandle; // Handle to the USB device.
  31. UCHAR ucDeviceNumber;
  32. ULONG ulBaud;
  33. // Private Member Functions
  34. void ReceiveThread();
  35. static DSI_THREAD_RETURN ProcessThread(void *pvParameter_);
  36. BOOL GetDeviceNumberByProductDescription(void* pvProductDescription_, USHORT usSize_, UCHAR& ucDeviceNumber_);
  37. public:
  38. DSISerialSI();
  39. ~DSISerialSI();
  40. BOOL Init(ULONG ulBaud_, UCHAR ucDeviceNumber_);
  41. BOOL Init(ULONG ulBaud_, void *pvProductDescription_, USHORT usSize_);
  42. BOOL Init(ULONG ulBaud_, const USBDeviceSI& clDevice_);
  43. void USBReset();
  44. UCHAR GetNumberOfDevices();
  45. // Methods inherited from the base class:
  46. BOOL AutoInit();
  47. ULONG GetDeviceSerialNumber();
  48. BOOL Open();
  49. void Close(BOOL bReset = FALSE);
  50. BOOL WriteBytes(void *pvData_, USHORT usSize_);
  51. UCHAR GetDeviceNumber();
  52. BOOL GetDeviceUSBInfo(UCHAR ucDevice_, UCHAR* pucProductString_, UCHAR* pucSerialString_, USHORT usBufferSize_);
  53. BOOL GetDevicePID(USHORT& usPID_);
  54. BOOL GetDeviceVID(USHORT& usVid_);
  55. };
  56. #endif // !defined(DSI_SERIAL_SI_HPP)