PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
PlusSerialLine.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 
8 #ifndef _RAWSERIALLINE_H_
9 #define _RAWSERIALLINE_H_
10 
11 #ifdef _WIN32
12  #include <windows.h>
13 #else
14  #define INVALID_HANDLE_VALUE (-1)
15 #endif
16 
17 #include <string>
18 
30 {
31 public:
32  typedef unsigned long DWORD;
33  typedef unsigned int UINT;
34  typedef unsigned char BYTE;
35 
36 #ifdef _WIN32
37  // HANDLE is defined for Windows already
38 #else
39  typedef int HANDLE;
40 #endif
41 
42  SerialLine();
43  virtual ~SerialLine();
44 
46  bool Open();
47 
49  void Close();
50 
52  int Write(const BYTE* data, int numberOfBytesToWrite);
53 
55  bool Write(const BYTE data);
56 
58  int Read(BYTE* data, int maxNumberOfBytesToRead);
59 
61  bool Read(BYTE& data);
62 
64  SetStdStringMacro(PortName);
66  GetStdStringMacro(PortName);
67 
69  void SetSerialPortSpeed(DWORD speed);
70 
72  void SetMaxReplyTime(int maxreply);
73 
75  int GetMaxReplyTime() const;
76 
78  bool IsHandleAlive() const;
79 
81  unsigned int GetNumberOfBytesAvailableForReading() const;
82 
84  PlusStatus SetDTR(bool onOff);
85 
87  PlusStatus SetRTS(bool onOff);
88 
90  PlusStatus GetDSR(bool& onOff);
91 
93  PlusStatus GetCTS(bool& onOff);
94 
96  DWORD ClearError();
97 
98 private:
99  HANDLE CommHandle;
100  std::string PortName;
101  DWORD SerialPortSpeed;
102  int MaxReplyTime;
103 };
104 
105 #endif
const uint32_t * data
Definition: phidget22.h:3971
PlusStatus SetRTS(bool onOff)
unsigned int UINT
int Write(const BYTE *data, int numberOfBytesToWrite)
virtual ~SerialLine()
void SetMaxReplyTime(int maxreply)
SetStdStringMacro(PortName)
igsioStatus PlusStatus
Definition: PlusCommon.h:40
int Read(BYTE *data, int maxNumberOfBytesToRead)
DWORD ClearError()
Class for reading and writing data through the serial (RS-232) port.
PlusStatus SetDTR(bool onOff)
PlusStatus GetCTS(bool &onOff)
GetStdStringMacro(PortName)
unsigned int GetNumberOfBytesAvailableForReading() const
unsigned long DWORD
PlusStatus GetDSR(bool &onOff)
void SetSerialPortSpeed(DWORD speed)
bool IsHandleAlive() const
int GetMaxReplyTime() const
unsigned char BYTE