Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::SerialCommunication Class Reference

serial communication interface More...

#include <mitkSerialCommunication.h>

List of all members.

Public Types

enum  PortNumber {
  COM1 = 1, COM2 = 2, COM3 = 3, COM4 = 4,
  COM5 = 5, COM6 = 6, COM7 = 7, COM8 = 8,
  COM9 = 9
}
enum  BaudRate {
  BaudRate9600 = 9600, BaudRate14400 = 14400, BaudRate19200 = 19200, BaudRate38400 = 38400,
  BaudRate57600 = 57600, BaudRate115200 = 115200
}
enum  DataBits { DataBits8 = 8, DataBits7 = 7 }
enum  Parity { None = 'N', Odd = 'O', Even = 'E' }
enum  StopBits { StopBits1 = 1, StopBits2 = 2 }
enum  HardwareHandshake { HardwareHandshakeOn = 1, HardwareHandshakeOff = 0 }
typedef SerialCommunication Self
typedef itk::Object Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
int OpenConnection ()
 Opens connection to the COM port with port number m_PortNumber or the device name m_DeviceName and all port settings.
void CloseConnection ()
 Closes the connection.
int Receive (std::string &answer, unsigned int numberOfBytes)
 Read numberOfBytes characters from the serial interface.
int Send (const std::string &input)
 Send the string input.
void SendBreak (unsigned int ms=400)
 Send the break signal for ms milliseconds.
void ClearReceiveBuffer ()
 erase the receive buffer of the serial interface
void ClearSendBuffer ()
 erase the send buffer of the serial interface
virtual PortNumber GetPortNumber () const
 Get the port number of the serial interface.
virtual void SetPortNumber (PortNumber _arg)
 Set the port number of the serial interface.
virtual const char * GetDeviceName () const
 Get the device name.
virtual void SetDeviceName (const char *_arg)
 Set the device name.
virtual BaudRate GetBaudRate () const
 Get the baud rate of the serial interface.
virtual void SetBaudRate (BaudRate _arg)
 Set the baud rate of the serial interface.
virtual DataBits GetDataBits () const
 Get the number of data bits of the serial interface.
virtual void SetDataBits (DataBits _arg)
 Set the number of data bits of the serial interface.
virtual Parity GetParity () const
 Get the parity mode of the serial interface.
virtual void SetParity (Parity _arg)
 Set the parity mode of the serial interface.
virtual StopBits GetStopBits () const
 Get number of stop bits of the serial interface.
virtual void SetStopBits (StopBits _arg)
 Set number of stop bits of the serial interface.
virtual HardwareHandshake GetHardwareHandshake () const
 returns true if hardware handshake should is used
virtual void SetHardwareHandshake (HardwareHandshake _arg)
 Set if hardware handshake should be used.
virtual unsigned int GetSendTimeout () const
 returns the send timeout in milliseconds
virtual void SetSendTimeout (unsigned int _arg)
 set the send timeout in milliseconds
virtual unsigned int GetReceiveTimeout () const
 returns the receive timeout in milliseconds
virtual void SetReceiveTimeout (unsigned int _arg)
 set the send timeout in milliseconds

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 SerialCommunication ()
virtual ~SerialCommunication ()
int ApplyConfiguration ()
 configures the serial interface with all parameters

Protected Attributes

std::string m_DeviceName
 device name that is used to connect to the serial interface (will be used if != "")
PortNumber m_PortNumber
 port number of the device
BaudRate m_BaudRate
 baud rate of the serial interface connection
DataBits m_DataBits
 number of data bits per symbol
Parity m_Parity
 parity mode
StopBits m_StopBits
 number of stop bits per symbol
HardwareHandshake m_HardwareHandshake
 whether to use hardware handshake for the connection
unsigned int m_ReceiveTimeout
 timeout for receiving data from the serial interface in milliseconds
unsigned int m_SendTimeout
 timeout for sending data to the serial interface in milliseconds
bool m_Connected
 is set to true if a connection currently established
int m_FileDescriptor

Detailed Description

serial communication interface

Documentation This class allows to send and receive data over a serial communication interface (COM Port). Define the serial interface that should be used either with SetPortNumber() or SetDeviceName() Next, define communication parameters: baud rate, number of data bits, number of stop bits, parity mode, usage of hardware handshake and timeout values (in ms). Use OpenConnection() to establish a connection on the serial interface with the selected parameters. While the connection is established, changes to the parameters will not take effect. You have to close the connection using CloseConnection() and then reopen it with the new parameters with OpenConnection().

Definition at line 50 of file mitkSerialCommunication.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::SerialCommunication::ConstPointer

Definition at line 53 of file mitkSerialCommunication.h.

typedef itk::SmartPointer<Self> mitk::SerialCommunication::Pointer

Definition at line 53 of file mitkSerialCommunication.h.

Definition at line 53 of file mitkSerialCommunication.h.

Definition at line 53 of file mitkSerialCommunication.h.


Member Enumeration Documentation

Enumerator:
BaudRate9600 
BaudRate14400 
BaudRate19200 
BaudRate38400 
BaudRate57600 
BaudRate115200 

Definition at line 69 of file mitkSerialCommunication.h.

    {
      BaudRate9600   = 9600,
      BaudRate14400  = 14400,
      BaudRate19200  = 19200,
      BaudRate38400  = 38400,
      BaudRate57600  = 57600,
      BaudRate115200 = 115200
    };
Enumerator:
DataBits8 
DataBits7 

Definition at line 79 of file mitkSerialCommunication.h.

    {
      DataBits8 = 8,
      DataBits7 = 7
    };
Enumerator:
HardwareHandshakeOn 
HardwareHandshakeOff 

Definition at line 98 of file mitkSerialCommunication.h.

Enumerator:
None 
Odd 
Even 

Definition at line 85 of file mitkSerialCommunication.h.

    {
      None = 'N',
      Odd  = 'O',
      Even = 'E'
    };
Enumerator:
COM1 
COM2 
COM3 
COM4 
COM5 
COM6 
COM7 
COM8 
COM9 

Definition at line 56 of file mitkSerialCommunication.h.

    {
      COM1 = 1,
      COM2 = 2,
      COM3 = 3,
      COM4 = 4,
      COM5 = 5,
      COM6 = 6,
      COM7 = 7,
      COM8 = 8,
      COM9 = 9
    };
Enumerator:
StopBits1 
StopBits2 

Definition at line 92 of file mitkSerialCommunication.h.

    {
      StopBits1 = 1,
      StopBits2 = 2
    };

Constructor & Destructor Documentation

mitk::SerialCommunication::SerialCommunication (  ) [protected]
mitk::SerialCommunication::~SerialCommunication (  ) [protected, virtual]

Definition at line 55 of file mitkSerialCommunication.cpp.


Member Function Documentation

int mitk::SerialCommunication::ApplyConfiguration (  ) [protected]

configures the serial interface with all parameters

Definition at line 255 of file mitkSerialCommunication.cpp.

References ERROR_VALUE, FALSE, INVALID_HANDLE_VALUE, OK, and TRUE.

{
#ifdef WIN32 // Windows implementation
  if (m_ComPortHandle == INVALID_HANDLE_VALUE)
    return ERROR_VALUE;

  DCB controlSettings;
  if (GetCommState(m_ComPortHandle, &controlSettings) == 0)
  {
    return ERROR_VALUE;
  }

  std::ostringstream o;
  o << "baud=" << m_BaudRate << " parity=" << static_cast<char>(m_Parity) << " data=" << m_DataBits << " stop=" << m_StopBits;  
  if (BuildCommDCBA(o.str().c_str(), &controlSettings)  == 0) // Build device-control block
    return ERROR_VALUE;

  if (m_HardwareHandshake == HardwareHandshakeOn) // Modify hardware handshake values
  {
    controlSettings.fDtrControl = DTR_CONTROL_ENABLE;
    controlSettings.fRtsControl = RTS_CONTROL_ENABLE;
    controlSettings.fOutxCtsFlow = TRUE;
    controlSettings.fRtsControl = RTS_CONTROL_HANDSHAKE;
  }
  else
  {
    controlSettings.fDtrControl = DTR_CONTROL_DISABLE;
    controlSettings.fRtsControl = RTS_CONTROL_DISABLE;
    controlSettings.fOutxCtsFlow = FALSE;
    controlSettings.fRtsControl = RTS_CONTROL_DISABLE;
  }
  if (SetCommState(m_ComPortHandle, &controlSettings) == FALSE)    // Configure com port
    return GetLastError();

  COMMTIMEOUTS timeouts;


  timeouts.ReadIntervalTimeout = m_ReceiveTimeout;
  timeouts.ReadTotalTimeoutMultiplier = 0;
  timeouts.ReadTotalTimeoutConstant = m_ReceiveTimeout;
  timeouts.WriteTotalTimeoutMultiplier = 0;
  timeouts.WriteTotalTimeoutConstant = m_SendTimeout;
  if (SetCommTimeouts(m_ComPortHandle, &timeouts) == FALSE)  // set timeout values
    return GetLastError();

  PurgeComm(m_ComPortHandle, PURGE_TXCLEAR | PURGE_RXCLEAR);  // clear read and write buffers
  return OK;

#else // Posix

  if ( m_FileDescriptor == INVALID_HANDLE_VALUE )
    return ERROR_VALUE;

  struct termios termIOStructure;
  if ( tcgetattr(m_FileDescriptor, &termIOStructure) != 0 ) // retrieve parameters from com port
    return ERROR_VALUE;

  cfmakeraw(&termIOStructure);        // set flags to raw mode
  termIOStructure.c_cflag |= CLOCAL;
  if (m_HardwareHandshake == HardwareHandshakeOn)
  { // enable
    termIOStructure.c_cflag |= CRTSCTS;
    termIOStructure.c_iflag &= ~(IXON|IXOFF);
  }
  else
  { // disable
    termIOStructure.c_cflag &= ~CRTSCTS;
    termIOStructure.c_iflag &= ~(IXON|IXOFF);
  }
  termIOStructure.c_cflag &= ~CSIZE;  // set number of data bits
  switch (m_DataBits)
  {
  case DataBits7:
    termIOStructure.c_cflag |= CS7;
    break;
  case DataBits8:
  default:
    termIOStructure.c_cflag |= CS8;
  }
  switch (m_StopBits)  // set number of stop bits
  {
  case StopBits2:
    termIOStructure.c_cflag |= CSTOPB;
    break;
  case StopBits1:
  default:
    termIOStructure.c_cflag &= ~CSTOPB;
  }
  switch (m_Parity)  // set parity
  {
  case Odd:
    termIOStructure.c_cflag |= (PARENB|PARODD);
    break;
  case Even:
    termIOStructure.c_cflag |= PARENB;
    termIOStructure.c_cflag &= ~PARODD;
  case None:
  default:
    termIOStructure.c_cflag &= ~PARENB;
    break;
  }
  speed_t baudrate; // set baudrate
  switch (m_BaudRate)
  {
  case BaudRate9600:
    baudrate = B9600;
    break;
  case BaudRate14400:
    baudrate = B9600;  //14400 is not defined for posix, use 9600 instead
    break;
  case BaudRate19200:
    baudrate = B19200;
    break;
  case BaudRate38400:
    baudrate = B38400;
    break;
  case BaudRate57600:
    baudrate = B57600;
    break;
  case BaudRate115200:
    baudrate = B115200;
    break;
  default:
    baudrate = B9600;
    break;
  }
  cfsetispeed(&termIOStructure, baudrate);
  cfsetospeed(&termIOStructure, baudrate);

  termIOStructure.c_cc[VMIN] = 0;
  termIOStructure.c_cc[VTIME] = m_ReceiveTimeout / 100; // timeout in 1/10 sec, not in ms. Rounded down.

  if (tcsetattr(m_FileDescriptor, TCSANOW, &termIOStructure) == 0)
    return OK;
  else
    return ERROR_VALUE;
#endif
}
void mitk::SerialCommunication::ClearReceiveBuffer (  )

erase the receive buffer of the serial interface

Definition at line 415 of file mitkSerialCommunication.cpp.

References INVALID_HANDLE_VALUE.

{
#ifdef WIN32
  if (m_ComPortHandle != INVALID_HANDLE_VALUE)
    PurgeComm(m_ComPortHandle, PURGE_RXCLEAR);
#else // Posix
  if (m_FileDescriptor != INVALID_HANDLE_VALUE)
    tcflush(m_FileDescriptor, TCIFLUSH);
#endif
}
void mitk::SerialCommunication::ClearSendBuffer (  )

erase the send buffer of the serial interface

Definition at line 427 of file mitkSerialCommunication.cpp.

References INVALID_HANDLE_VALUE.

{
#ifdef WIN32
  if ( m_ComPortHandle != INVALID_HANDLE_VALUE )
    PurgeComm(m_ComPortHandle, PURGE_TXCLEAR);
#else // Posix
  if ( m_FileDescriptor != INVALID_HANDLE_VALUE )
    tcflush(m_FileDescriptor, TCOFLUSH);
#endif
}
void mitk::SerialCommunication::CloseConnection (  )

Closes the connection.

Definition at line 121 of file mitkSerialCommunication.cpp.

References INVALID_HANDLE_VALUE.

{
#ifdef WIN32
  if (m_ComPortHandle == INVALID_HANDLE_VALUE)
    return;
  ClearReceiveBuffer();
  ClearSendBuffer();
  SetCommState(m_ComPortHandle, &m_PreviousDeviceControlBlock); // restore previous settings
  SetCommTimeouts(m_ComPortHandle, &m_PreviousTimeout);         // restore previous timeout values
  SetCommMask(m_ComPortHandle, m_PreviousMask);                 // restore previous mask value
  PurgeComm(m_ComPortHandle, PURGE_TXCLEAR | PURGE_RXCLEAR);    // empty buffers
  CloseHandle(m_ComPortHandle);                                 // close handle
  m_ComPortHandle = INVALID_HANDLE_VALUE;
  m_Connected = false;
  return;

#else // Posix
  if (m_FileDescriptor == INVALID_HANDLE_VALUE)
    return;
  ClearReceiveBuffer();
  ClearSendBuffer();
  close(m_FileDescriptor);
  m_FileDescriptor = INVALID_HANDLE_VALUE;
  m_Connected = false;
  return;
#endif
}
virtual BaudRate mitk::SerialCommunication::GetBaudRate (  ) const [virtual]

Get the baud rate of the serial interface.

virtual const char* mitk::SerialCommunication::GetClassName (  ) const [virtual]
virtual DataBits mitk::SerialCommunication::GetDataBits (  ) const [virtual]

Get the number of data bits of the serial interface.

virtual const char* mitk::SerialCommunication::GetDeviceName (  ) const [virtual]

Get the device name.

SerialCommunication can either use m_PortNumber to create serial interface device names or use m_DeviceName directly. This method allows to set an arbitrary device name that will be used to connect to the device. Common names are COM1, CNCA0, CNCB9 on windows and /dev/ttyS0 or /dev/ttyUSB0 on linux.

virtual HardwareHandshake mitk::SerialCommunication::GetHardwareHandshake (  ) const [virtual]

returns true if hardware handshake should is used

virtual Parity mitk::SerialCommunication::GetParity (  ) const [virtual]

Get the parity mode of the serial interface.

virtual PortNumber mitk::SerialCommunication::GetPortNumber (  ) const [virtual]

Get the port number of the serial interface.

Returns the port number that will be used in the connection. The port number is only used if the m_DeviceName is empty ("").

virtual unsigned int mitk::SerialCommunication::GetReceiveTimeout (  ) const [virtual]

returns the receive timeout in milliseconds

virtual unsigned int mitk::SerialCommunication::GetSendTimeout (  ) const [virtual]

returns the send timeout in milliseconds

virtual StopBits mitk::SerialCommunication::GetStopBits (  ) const [virtual]

Get number of stop bits of the serial interface.

static Pointer mitk::SerialCommunication::New (  ) [static]
int mitk::SerialCommunication::OpenConnection (  )

Opens connection to the COM port with port number m_PortNumber or the device name m_DeviceName and all port settings.

Definition at line 61 of file mitkSerialCommunication.cpp.

References ERROR_VALUE, INVALID_HANDLE_VALUE, and OK.

{
  if (m_Connected)
    return ERROR_VALUE;

#ifdef WIN32
  std::stringstream ss;
  if (m_DeviceName.empty())
    ss << "COM" << static_cast<unsigned int>(m_PortNumber); // use m_PortNumber
  else
    ss << m_DeviceName; // use m_DeviceName

  m_ComPortHandle = CreateFile(ss.str().c_str(), GENERIC_READ | GENERIC_WRITE,
    NULL,    /* no sharing */
    NULL, /* no security flags */
    OPEN_EXISTING, /* open com port, don't create it */
    NULL, /* no flags */
    NULL); /* no template */
  if (m_ComPortHandle == INVALID_HANDLE_VALUE)
    return ERROR_VALUE;

  GetCommState(m_ComPortHandle, &m_PreviousDeviceControlBlock);
  GetCommTimeouts(m_ComPortHandle, &m_PreviousTimeout);
  GetCommMask(m_ComPortHandle, &m_PreviousMask);

  if (this->ApplyConfiguration() != OK)    // set interface parameters
  {
    CloseHandle(m_ComPortHandle);
    m_ComPortHandle = INVALID_HANDLE_VALUE;
    return ERROR_VALUE;
  }
  m_Connected = true;
  return OK;

#else // Posix
  std::stringstream ss;
  if (m_DeviceName.empty())
    ss << "/dev/ttyS" << static_cast<unsigned int>(m_PortNumber) - 1; // use m_PortNumber, COM1 = ttyS0
  else
    ss << m_DeviceName; // use m_DeviceName

  //m_FileDescriptor = open(ss.str().c_str(), O_RDWR | O_NONBLOCK | O_NDELAY | O_NOCTTY | O_EXCL); // open device file
  m_FileDescriptor = open(ss.str().c_str(), O_RDWR|O_NONBLOCK|O_EXCL); // open device file
  if (m_FileDescriptor < 0)
    return ERROR_VALUE;

  fcntl(m_FileDescriptor, F_SETFL, 0);    // change to blocking mode
  tcflush(m_FileDescriptor, TCIOFLUSH);   // flush buffers
  if (this->ApplyConfiguration() != OK)    // set interface parameters
  {
    close(m_FileDescriptor);
    m_FileDescriptor = INVALID_HANDLE_VALUE;
    return ERROR_VALUE;
  }
  m_Connected = true;
  return OK;
#endif
}
int mitk::SerialCommunication::Receive ( std::string &  answer,
unsigned int  numberOfBytes 
)

Read numberOfBytes characters from the serial interface.

This method tries to read numberOfBytes characters from the serial interface. If The ReceiveTimeout is set to 0, the Receive() method will wait indefinetly until all characters are received. If the ReceiveTimeout is set to another value, it will return after m_ReceiveTimeout milliseconds (or after all characters are read). The received characters are stored in the string answer. Note that this will overwrite the content of answer!

Definition at line 150 of file mitkSerialCommunication.cpp.

References ERROR_VALUE, INVALID_HANDLE_VALUE, and OK.

{
  if (numberOfBytes == 0)
    return OK;
  if (m_Connected == false)
    return ERROR_VALUE;

#ifdef WIN32
  if (m_ComPortHandle == INVALID_HANDLE_VALUE)
    return ERROR_VALUE;

  DWORD numberOfBytesRead = 0;
  char* buffer = new char[numberOfBytes];
  if (ReadFile(m_ComPortHandle, buffer, numberOfBytes, &numberOfBytesRead, NULL) != 0)
  {
    if (numberOfBytesRead > 0) // data read
    {
      answer.assign(buffer, numberOfBytesRead); // copy buffer to answer
      if (numberOfBytesRead == numberOfBytes)
        return OK;           // everything was received
      else
        return ERROR_VALUE;  // some data was received, but not as much as expected
    }
    else // error
    {
      answer = "";
      return ERROR_VALUE;
    }
  }
  delete buffer;
  return OK;


#else  // Posix
  if (m_FileDescriptor == INVALID_HANDLE_VALUE)
    return ERROR_VALUE;

  unsigned long bytesRead = 0;
  unsigned long bytesLeft = numberOfBytes;
  char* buffer = new char[numberOfBytes];

  while ((bytesLeft > 0) && (bytesRead < numberOfBytes))
  {
    int num = read(m_FileDescriptor, &buffer[bytesRead], 1); // read one byte
    if (num == -1) // ERROR_VALUE
    {
      if (errno == EAGAIN) // nonblocking, no byte there right now, but maybe next time
        continue;
      else
        break; // ERROR_VALUE, stop trying to read
    }
    if (num == 0) // timeout or eof(?)
      break;

    bytesLeft -= num;  // n is number of chars left to read
    bytesRead += num;  // i is the number of chars read
  }
  if (bytesRead > 0)
    answer.assign(buffer, bytesRead); // copy buffer to answer
  delete buffer;
  if (bytesRead == numberOfBytes)
    return OK;           // everything was received
  else
    return ERROR_VALUE;  // some data was received, but not as much as expected
#endif
}
int mitk::SerialCommunication::Send ( const std::string &  input )

Send the string input.

This method will send the string input to the serial interface. It does not send the string termination character \0.

Definition at line 218 of file mitkSerialCommunication.cpp.

References ERROR_VALUE, INVALID_HANDLE_VALUE, OK, and TRUE.

{
  //long retval = E2ERR_OPENFAILED;
  if (input.empty())
    return OK;
  if (m_Connected == false)
    return ERROR_VALUE;

#ifdef WIN32
  if (m_ComPortHandle == INVALID_HANDLE_VALUE)
    return ERROR_VALUE;

  DWORD bytesWritten = 0;
  if (WriteFile(m_ComPortHandle, input.data(), static_cast<DWORD>(input.size()), &bytesWritten, NULL) == TRUE)
    return OK;
  else
    return GetLastError();

#else // Posix
  if (m_FileDescriptor == INVALID_HANDLE_VALUE)
    return ERROR_VALUE;

  long bytesWritten = 0;
  long bytesLeft = input.size();

  while (bytesLeft > 0)
  {
    bytesWritten = write(m_FileDescriptor, input.data() + bytesWritten, bytesLeft);
    if (bytesWritten <= 0)
      return ERROR_VALUE; //return ERROR_VALUE
    bytesLeft -= bytesWritten;
  }
  return OK;
#endif
}
void mitk::SerialCommunication::SendBreak ( unsigned int  ms = 400 )

Send the break signal for ms milliseconds.

Definition at line 395 of file mitkSerialCommunication.cpp.

References INVALID_HANDLE_VALUE.

{
#ifdef WIN32
  if (m_ComPortHandle == INVALID_HANDLE_VALUE)
    return;
  SetCommBreak(m_ComPortHandle);
  itksys::SystemTools::Delay(ms);
  ClearCommBreak(m_ComPortHandle);
  return;

#else  // Posix

  if (m_FileDescriptor == INVALID_HANDLE_VALUE)
    return;
  tcsendbreak(m_FileDescriptor, ms);
  return;
#endif
}
virtual void mitk::SerialCommunication::SetBaudRate ( BaudRate  _arg ) [virtual]

Set the baud rate of the serial interface.

virtual void mitk::SerialCommunication::SetDataBits ( DataBits  _arg ) [virtual]

Set the number of data bits of the serial interface.

virtual void mitk::SerialCommunication::SetDeviceName ( const char *  _arg ) [virtual]

Set the device name.

if the device name is set (!=""), OpenConnection() will try to open the serial device on that device name. Normally, the serial interfaces are named COM1-COM9 on windows and /dev/ttyS0 to /dev/ttyS9 on linux, but other names are possible too (e.g. /dev/ttyUSB0).

virtual void mitk::SerialCommunication::SetHardwareHandshake ( HardwareHandshake  _arg ) [virtual]

Set if hardware handshake should be used.

virtual void mitk::SerialCommunication::SetParity ( Parity  _arg ) [virtual]

Set the parity mode of the serial interface.

virtual void mitk::SerialCommunication::SetPortNumber ( PortNumber  _arg ) [virtual]

Set the port number of the serial interface.

SerialCommunication can either use PortNumber to create serial interface device names COM1 to COM9 for windows and /dev/ttyS0 to /dev/ttyS8 on linux (SetPortNumber(COM1) is mapped to /dev/ttyS0 and so on). Alternatively, use SetDeviceName() to set the device name directly (e.g. "CNCA0" for a com0com virtual com port or "/dev/ttyUSB0" for a USB to serial adapter on linux. If a device name is set (m_DeviceName != "") then OpenConnection() will try to open that device. Otherwise, it will build the device name using the port number

virtual void mitk::SerialCommunication::SetReceiveTimeout ( unsigned int  _arg ) [virtual]

set the send timeout in milliseconds

Specify the receive timeout in milliseconds. Setting this value to 0 will cause the Receive() method to wait until all expected characters are received.

virtual void mitk::SerialCommunication::SetSendTimeout ( unsigned int  _arg ) [virtual]

set the send timeout in milliseconds

virtual void mitk::SerialCommunication::SetStopBits ( StopBits  _arg ) [virtual]

Set number of stop bits of the serial interface.


Member Data Documentation

baud rate of the serial interface connection

Definition at line 277 of file mitkSerialCommunication.h.

is set to true if a connection currently established

Definition at line 285 of file mitkSerialCommunication.h.

number of data bits per symbol

Definition at line 278 of file mitkSerialCommunication.h.

std::string mitk::SerialCommunication::m_DeviceName [protected]

device name that is used to connect to the serial interface (will be used if != "")

Definition at line 275 of file mitkSerialCommunication.h.

Definition at line 293 of file mitkSerialCommunication.h.

Referenced by SerialCommunication().

whether to use hardware handshake for the connection

Definition at line 281 of file mitkSerialCommunication.h.

parity mode

Definition at line 279 of file mitkSerialCommunication.h.

port number of the device

Definition at line 276 of file mitkSerialCommunication.h.

timeout for receiving data from the serial interface in milliseconds

Definition at line 282 of file mitkSerialCommunication.h.

unsigned int mitk::SerialCommunication::m_SendTimeout [protected]

timeout for sending data to the serial interface in milliseconds

Definition at line 283 of file mitkSerialCommunication.h.

number of stop bits per symbol

Definition at line 280 of file mitkSerialCommunication.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines