dsi_serial_vcp.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #if !defined(DSI_SERIAL_VCP_HPP)
  9. #define DSI_SERIAL_VCP_HPP
  10. #if defined(DSI_TYPES_WINDOWS) // The VCP module is currently only supported on windows
  11. #include "types.h"
  12. #include "dsi_thread.h"
  13. #include "dsi_serial.hpp"
  14. #include "dsi_serial_callback.hpp"
  15. #include <windows.h>
  16. //////////////////////////////////////////////////////////////////////////////////
  17. // Public Class Prototypes
  18. //////////////////////////////////////////////////////////////////////////////////
  19. class DSISerialVCP : 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. volatile HANDLE hComm;
  27. DCB dcb;
  28. UCHAR ucDeviceNumber;
  29. ULONG ulBaud;
  30. // Private Member Functions
  31. void ReceiveThread();
  32. static DSI_THREAD_RETURN ProcessThread(void *pvParameter_);
  33. BOOL GetDeviceNumberByProductDescription(void* pvProductDescription_, USHORT usSize_, UCHAR& ucDeviceNumber_);
  34. public:
  35. DSISerialVCP();
  36. ~DSISerialVCP();
  37. // Methods inherited from the base class:
  38. BOOL AutoInit();
  39. ULONG GetDeviceSerialNumber();
  40. BOOL Init(ULONG ulBaud_, UCHAR ucDeviceNumber_);
  41. BOOL Open();
  42. void Close(BOOL bReset = FALSE);
  43. BOOL WriteBytes(void *pvData_, USHORT usSize_);
  44. UCHAR GetDeviceNumber();
  45. };
  46. #endif // defined(DSI_TYPES_WINDOWS)
  47. #endif // !defined(DSI_SERIAL_VCP_HPP)