PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
List of all members | Public Types | Public Member Functions
SerialLine Class Reference

Class for reading and writing data through the serial (RS-232) port. More...

#include <src/PlusDataCollection/PlusSerialLine.h>

Public Types

typedef unsigned char BYTE
 
typedef unsigned long DWORD
 
typedef int HANDLE
 
typedef unsigned int UINT
 

Public Member Functions

DWORD ClearError ()
 
void Close ()
 
PlusStatus GetCTS (bool &onOff)
 
PlusStatus GetDSR (bool &onOff)
 
int GetMaxReplyTime () const
 
unsigned int GetNumberOfBytesAvailableForReading () const
 
 GetStdStringMacro (PortName)
 
bool IsHandleAlive () const
 
bool Open ()
 
int Read (BYTE *data, int maxNumberOfBytesToRead)
 
bool Read (BYTE &data)
 
 SerialLine ()
 
PlusStatus SetDTR (bool onOff)
 
void SetMaxReplyTime (int maxreply)
 
PlusStatus SetRTS (bool onOff)
 
void SetSerialPortSpeed (DWORD speed)
 
 SetStdStringMacro (PortName)
 
int Write (const BYTE *data, int numberOfBytesToWrite)
 
bool Write (const BYTE data)
 
virtual ~SerialLine ()
 

Detailed Description

Class for reading and writing data through the serial (RS-232) port.

The class currently only works on Windows. If serial communication is needed on other platforms then sample code can be found in src\Utilities\ndicapi\ndicapi_serial.* or at https://github.com/wjwwood/serial.

Definition at line 29 of file PlusSerialLine.h.

Member Typedef Documentation

◆ BYTE

typedef unsigned char SerialLine::BYTE

Definition at line 34 of file PlusSerialLine.h.

◆ DWORD

typedef unsigned long SerialLine::DWORD

Definition at line 32 of file PlusSerialLine.h.

◆ HANDLE

Definition at line 39 of file PlusSerialLine.h.

◆ UINT

typedef unsigned int SerialLine::UINT

Definition at line 33 of file PlusSerialLine.h.

Constructor & Destructor Documentation

◆ SerialLine()

SerialLine::SerialLine ( )

Definition at line 11 of file PlusSerialLine.cxx.

◆ ~SerialLine()

SerialLine::~SerialLine ( )
virtual

Definition at line 20 of file PlusSerialLine.cxx.

Member Function Documentation

◆ ClearError()

SerialLine::DWORD SerialLine::ClearError ( )

Clears the device's error flag to enable additional input and output (I/O) operations

Definition at line 188 of file PlusSerialLine.cxx.

◆ Close()

void SerialLine::Close ( )

Close serial port

Definition at line 29 of file PlusSerialLine.cxx.

◆ GetCTS()

PlusStatus SerialLine::GetCTS ( bool &  onOff)

Gets status of CTS (clear-to-send) line.

Definition at line 303 of file PlusSerialLine.cxx.

◆ GetDSR()

PlusStatus SerialLine::GetDSR ( bool &  onOff)

Gets status of DTR (data-set-ready) line.

Definition at line 286 of file PlusSerialLine.cxx.

◆ GetMaxReplyTime()

int SerialLine::GetMaxReplyTime ( ) const

Get the serial port max reply time

Definition at line 214 of file PlusSerialLine.cxx.

◆ GetNumberOfBytesAvailableForReading()

unsigned int SerialLine::GetNumberOfBytesAvailableForReading ( ) const

Check the handle alive status

Definition at line 226 of file PlusSerialLine.cxx.

◆ GetStdStringMacro()

SerialLine::GetStdStringMacro ( PortName  )

Get the serial port name

◆ IsHandleAlive()

bool SerialLine::IsHandleAlive ( ) const

Check the handle alive status

Definition at line 220 of file PlusSerialLine.cxx.

◆ Open()

bool SerialLine::Open ( )

Open serial port

Definition at line 41 of file PlusSerialLine.cxx.

◆ Read() [1/2]

int SerialLine::Read ( BYTE data,
int  maxNumberOfBytesToRead 
)

Read data from the serial port. Returns the number of writes actually read.

Definition at line 144 of file PlusSerialLine.cxx.

◆ Read() [2/2]

bool SerialLine::Read ( BYTE data)

Read a single byte from the serial port. Returns true if successful.

Definition at line 182 of file PlusSerialLine.cxx.

◆ SetDTR()

PlusStatus SerialLine::SetDTR ( bool  onOff)

Sends the DTR (data-terminal-ready) signal.

Definition at line 240 of file PlusSerialLine.cxx.

◆ SetMaxReplyTime()

void SerialLine::SetMaxReplyTime ( int  maxreply)

Set the serial port max reply time

Definition at line 208 of file PlusSerialLine.cxx.

◆ SetRTS()

PlusStatus SerialLine::SetRTS ( bool  onOff)

Sends the RTS (request-to-send) signal.

Definition at line 263 of file PlusSerialLine.cxx.

◆ SetSerialPortSpeed()

void SerialLine::SetSerialPortSpeed ( DWORD  speed)

Set the serial port speed

Definition at line 202 of file PlusSerialLine.cxx.

◆ SetStdStringMacro()

SerialLine::SetStdStringMacro ( PortName  )

Set the serial port name e.g. COM1

◆ Write() [1/2]

int SerialLine::Write ( const BYTE data,
int  numberOfBytesToWrite 
)

Write data to the serial port. Returns the number of writes actually written.

Definition at line 100 of file PlusSerialLine.cxx.

◆ Write() [2/2]

bool SerialLine::Write ( const BYTE  data)

Write a single byte to the serial port. Returns true if successful.

Definition at line 138 of file PlusSerialLine.cxx.


The documentation for this class was generated from the following files: