WPOCT Software Developer's Kit (SDK)
SDK For using Wasatch Photonics OCT Spectrometers
Serial.h
Go to the documentation of this file.
1 #pragma once
2 
8 #include <windows.h>
9 #include <string>
10 
11 #define FC_DTRDSR 0x01
12 #define FC_RTSCTS 0x02
13 #define FC_XONXOFF 0x04
14 #define ASCII_BEL 0x07
15 #define ASCII_BS 0x08
16 #define ASCII_LF 0x0A
17 #define ASCII_CR 0x0D
18 #define ASCII_XON 0x11
19 #define ASCII_XOFF 0x13
20 
21 class CSerial
22 {
23 public:
24  CSerial();
25  ~CSerial();
26 
27  // Add/modify the calls to make them uniform with TimeoutSerial
28  bool Open (const std::string& comName, int nBaud = 9600, int stopBits = 1,
29  int timeout = 1000);
30 
31  bool Close (void);
32 
33  int Read (void *, int);
34  std::string ReadStringUntil (std::string delim);
35  std::string ReadExisting ();
36 
37  int Write (const char *, int);
38  int WriteString (const std::string& s);
39 
40  int ReadDataWaiting (void);
41 
42  bool IsOpen (void);
43 
44  void SetReadDelay (int ms);
45 
46 protected:
47  HANDLE _hIDComDev;
48  OVERLAPPED _overlappedRead, _overlappedWrite;
49 
50  bool _opened;
51  char* _buff;
52  int _maxBuf;
53  int _readDelay;
54 
55  BOOL WriteCommByte (unsigned char);
56 
57 };
Definition: Serial.h:22