Port Class Reference

Port is a thing the multimeter is connected to, that can be opened, closed and one can read and write. More...

#include <port.h>

Inheritance diagram for Port:

SerialPort List of all members.

Public Types

enum  Error {
  Ok = 0, SyntaxError, PermissionDenied, NoSuchPort,
  ConfigError, OpenError, WriteError, ReadError,
  UnknownBaudRate, UnknownNumberOfBits, UnknownParity, UnknownStopBits,
  NoData, BadFileDescriptor, BadAddress, Interrupted,
  Invalid, IOError, IsDirectory, UnknownError
}

Public Member Functions

 Port ()
 ctor
virtual ~Port ()
 dtor
virtual Error open (const std::string &config)=0
virtual Error close ()=0
virtual Error writeByte (int byte) const
virtual Error readByte (int *byte) const
virtual Error writeString (const char *string, ssize_t len) const
virtual Error readString (char *string, ssize_t len) const

Static Public Member Functions

static const char * errorString (Error err)

Protected Member Functions

Error errnoValue () const

Protected Attributes

int m_handle

Detailed Description

Port is a thing the multimeter is connected to, that can be opened, closed and one can read and write.

Port is the base class for a multimeter port (which in most of the cases would be a SerialPort). UNIX error values are translated to typesafe internal values which also can be translated into plain english strings.

Definition at line 34 of file port.h.


Member Enumeration Documentation

enum Port::Error
 

Enumerator:
Ok 
SyntaxError 
PermissionDenied 
NoSuchPort 
ConfigError 
OpenError 
WriteError 
ReadError 
UnknownBaudRate 
UnknownNumberOfBits 
UnknownParity 
UnknownStopBits 
NoData 
BadFileDescriptor 
BadAddress 
Interrupted 
Invalid 
IOError 
IsDirectory 
UnknownError 

Definition at line 37 of file port.h.


Constructor & Destructor Documentation

Port::Port  ) 
 

ctor

Definition at line 23 of file port.cpp.

Port::~Port  )  [virtual]
 

dtor

Definition at line 28 of file port.cpp.


Member Function Documentation

virtual Error Port::close  )  [pure virtual]
 

close the previously opened port

Implemented in SerialPort.

Port::Error Port::errnoValue  )  const [protected]
 

Translate errno into internal value

Returns:
Error code corresponding to the current value of errno

Definition at line 122 of file port.cpp.

References BadAddress, BadFileDescriptor, Interrupted, Invalid, IOError, IsDirectory, NoData, and UnknownError.

Referenced by readByte(), readString(), writeByte(), and writeString().

const char * Port::errorString Error  err  )  [static]
 

Translate Error code into a human readable string.

Parameters:
err Error code (as returned by the read/write/open/close) members of this class
Returns:
Pointer to human readable string

Definition at line 145 of file port.cpp.

References BadAddress, BadFileDescriptor, ConfigError, Interrupted, Invalid, IOError, IsDirectory, NoData, NoSuchPort, Ok, OpenError, PermissionDenied, ReadError, SyntaxError, UnknownBaudRate, UnknownError, UnknownNumberOfBits, UnknownParity, UnknownStopBits, and WriteError.

virtual Error Port::open const std::string &  config  )  [pure virtual]
 

Open the port given a general purpose configuration string containing the description of the port.

Parameters:
config The description of the port containing whatever is needed for the specific port implementation. Could be for example /dev/ttyS0:600:8:N:1 or localhost:1234

Implemented in SerialPort.

Port::Error Port::readByte int *  byte  )  const [virtual]
 

Read a byte from the port.

Parameters:
byte Value to be read. Is invalid if an error occured.
Returns:
Error code

Definition at line 51 of file port.cpp.

References errnoValue(), m_handle, and Ok.

Referenced by VC820::readData(), PeakTech10Ascii::readData(), and DMMClass::readData().

Port::Error Port::readString char *  string,
ssize_t  len
const [virtual]
 

Read a string from the port.

Parameters:
string String to be read.
len Number of bytes to be read
Returns:
Error code

Definition at line 97 of file port.cpp.

References errnoValue(), m_handle, and Ok.

Port::Error Port::writeByte int  byte  )  const [virtual]
 

Write a byte to the port.

Parameters:
byte Value to be written
Returns:
Error code

Definition at line 32 of file port.cpp.

References errnoValue(), m_handle, and Ok.

Port::Error Port::writeString const char *  string,
ssize_t  len
const [virtual]
 

Write a string to the port.

Parameters:
string String to be written
len Number of bytes to be written
Returns:
Error code

Definition at line 72 of file port.cpp.

References errnoValue(), m_handle, and Ok.

Referenced by MetexAscii::run().


Member Data Documentation

int Port::m_handle [protected]
 

Definition at line 108 of file port.h.

Referenced by SerialPort::close(), readByte(), readString(), writeByte(), and writeString().


The documentation for this class was generated from the following files:
Generated on Mon Jan 22 23:24:19 2007 for cdmm by  doxygen 1.4.6