areaDetector  3-5-0
EPICS areaDetector framework
Public Member Functions | Protected Attributes | List of all members
sw_com_port Class Reference

Class for general serial port. More...

#include <sw_com_port.h>

Inheritance diagram for sw_com_port:
comportInterface

Public Member Functions

 sw_com_port (char *name, log_file *lf_)
 Class for general serial port. More...
 
 ~sw_com_port ()
 Destructior. More...
 
virtual void open (void)
 OPen com port with default settings. More...
 
virtual void open (int baud, int parity, int nbits, int nstop)
 Open comport with baud as int, parity (1,0), nbits 7,8, nstop, 0,1. More...
 
virtual void open (int baud, int parity, int nbits, int nstop, int rdtimeout)
 Open com port with standard specs and add read time out in ms. More...
 
virtual void write (unsigned char *buffer, int length)
 Write mem buffer of byes, num bytes to ser port, flush. More...
 
virtual void read (unsigned char *buffer, int length)
 read length bytes into bufferfrom ser port. More...
 
virtual void write (unsigned char c)
 Write byte to serial port, flush. More...
 
virtual unsigned char read (void)
 read 1 byte from ser port. More...
 
virtual void close (void)
 close ser port. More...
 
virtual void flush (void)
 
virtual void clearPipe ()
 read ser port until no data left. More...
 
virtual void setPortName (char *n)
 Set port name like COM1 or etc. More...
 
virtual void wait (int us)
 Waait in a for loop. More...
 
virtual void tic ()
 Start a stop watch. More...
 
virtual double toc ()
 read stop watch in sec. More...
 

Protected Attributes

bool is_open
 
double currenttime
 
double elapsedtime
 
char INBUFFER [500]
 
char OUTBUFFER [20]
 
int bytes_read
 
int bytes_written
 
int bStatus
 
char port_name [64]
 
log_filelf
 
std::queue< unsigned char > * myqueue
 

Detailed Description

Class for general serial port.

Can be overridden. Used for camera link serial port.

Author
Timothy Madden
Date
2003

Constructor & Destructor Documentation

◆ sw_com_port()

sw_com_port::sw_com_port ( char *  name,
log_file lf_ 
)

Class for general serial port.

Can be overridden. Used for camera link serial port.

Author
Timothy Madden
Date
2003construct with name like "COM1"
Parameters
nameC string like "COM2"

◆ ~sw_com_port()

sw_com_port::~sw_com_port ( )

Destructior.

Member Function Documentation

◆ clearPipe()

void sw_com_port::clearPipe ( void  )
virtual

read ser port until no data left.

clears out garbage that may be in serial port.

Implements comportInterface.

◆ close()

void sw_com_port::close ( void  )
virtual

close ser port.

Implements comportInterface.

◆ flush()

void sw_com_port::flush ( void  )
virtual

Implements comportInterface.

◆ open() [1/3]

void sw_com_port::open ( void  )
virtual

OPen com port with default settings.

115200 baud, 1stop, no parituy, 8 bit data.

Implements comportInterface.

◆ open() [2/3]

void sw_com_port::open ( int  baud,
int  parity,
int  nbits,
int  nstop 
)
virtual

Open comport with baud as int, parity (1,0), nbits 7,8, nstop, 0,1.

Parameters
baudbaud rate like 9600 or 115200
parity1 or 0
nbits7 or 8
nstop1 or 0

Implements comportInterface.

◆ open() [3/3]

void sw_com_port::open ( int  baud,
int  parity,
int  nbits,
int  nstop,
int  rdtimeout 
)
virtual

Open com port with standard specs and add read time out in ms.

Parameters
baudBaud rate
parity1 or 0
nbits7 or 8 bits
nstop0 opr 1 stop bits
rdtimeoutint millisec for timeout.

Implements comportInterface.

◆ read() [1/2]

void sw_com_port::read ( unsigned char *  buffer,
int  length 
)
virtual

read length bytes into bufferfrom ser port.

Parameters
bufferRead ser port into this memory.
lengthmax len of data to read from ser port.

Implements comportInterface.

◆ read() [2/2]

unsigned char sw_com_port::read ( void  )
virtual

read 1 byte from ser port.

Implements comportInterface.

◆ setPortName()

void sw_com_port::setPortName ( char *  n)
virtual

Set port name like COM1 or etc.

Parameters
nC string like "COM2"

Implements comportInterface.

◆ tic()

void sw_com_port::tic ( )
virtual

Start a stop watch.

like tic in matlab.

Implements comportInterface.

◆ toc()

double sw_com_port::toc ( )
virtual

read stop watch in sec.

return double seconds since tic. let stop watch keep going. likc toc in matlab.

Implements comportInterface.

◆ wait()

void sw_com_port::wait ( int  us)
virtual

Waait in a for loop.

Not a sleep. give micro sec.

Parameters
nummicrosec to loop. or wait.

Implements comportInterface.

◆ write() [1/2]

void sw_com_port::write ( unsigned char *  buffer,
int  length 
)
virtual

Write mem buffer of byes, num bytes to ser port, flush.

Parameters
buffermem w/ message or data to send to ser port./
lengthlengt of message to send in bytes

Implements comportInterface.

◆ write() [2/2]

void sw_com_port::write ( unsigned char  c)
virtual

Write byte to serial port, flush.

Parameters
cchar to write to ser port.

Implements comportInterface.

Member Data Documentation

◆ bStatus

int sw_com_port::bStatus
protected

◆ bytes_read

int sw_com_port::bytes_read
protected

◆ bytes_written

int sw_com_port::bytes_written
protected

◆ currenttime

double sw_com_port::currenttime
protected

◆ elapsedtime

double sw_com_port::elapsedtime
protected

◆ INBUFFER

char sw_com_port::INBUFFER[500]
protected

◆ is_open

bool sw_com_port::is_open
protected

◆ lf

log_file* sw_com_port::lf
protected

◆ myqueue

std::queue<unsigned char>* sw_com_port::myqueue
protected

◆ OUTBUFFER

char sw_com_port::OUTBUFFER[20]
protected

◆ port_name

char sw_com_port::port_name[64]
protected

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