direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InterfaceAvr Class Reference

Provides the low level communication between the robots microcontroller and the laptop. More...

#include <interfaceAvr.h>

Collaboration diagram for InterfaceAvr:

List of all members.

Signals

void message (QString text, bool CR=true, bool sayIt=false, bool addTimestamp=true)
void robotState (bool state)
void tooMuchErrors ()

Public Member Functions

void closeComPort ()
bool convertStringToInt (QString string, int &value)
 InterfaceAvr ()
bool openComPort (QString comPort)
bool receiveChar (unsigned char *character, QString callingClassName="none")
bool receiveInt (int *value, QString callingClassName="none")
bool receiveString (QString &string, QString callingClassName="none")
bool sendChar (unsigned char character, QString callingClassName="none")
bool sendString (QString string, QString callingClassName="none")
 ~InterfaceAvr ()

Private Attributes

QString className
DirecsSerialserialPort
 this will contain the name of this class at runtime for debug messages

Static Private Attributes

static const int BAUDRATE = 38400
 For robot is "OFF".
static const bool OFF = false
 For robot is "ON".
static const bool ON = true
static const char starter = 42
 This is the baudrate with which the serial port will be opened. The other (not parameterized) settings are "8N1".
static const char terminator = 35
 This starts the serial string for the Atmel controller. 42 = *.

Detailed Description

Provides the low level communication between the robots microcontroller and the laptop.

Author:
Markus Knapp This class is used for the low level communication between the robots microcontroller and the laptop via a serial port, e.g. COM1 or /dev/ttyUSB0.

Definition at line 39 of file interfaceAvr.h.


Constructor & Destructor Documentation

InterfaceAvr::InterfaceAvr ( )

Definition at line 23 of file interfaceAvr.cpp.

Here is the call graph for this function:

InterfaceAvr::~InterfaceAvr ( )

Definition at line 37 of file interfaceAvr.cpp.


Member Function Documentation

void InterfaceAvr::closeComPort ( )

Closes the serial port

Definition at line 72 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool InterfaceAvr::convertStringToInt ( QString  string,
int &  value 
)

Returns an integer value which comes from a former recevied string. Example: With *42# the 42 is the 'string' here.

Parameters:
string
&valueis the int value when the conversion was successfull.
Returns:
true on access or false if an error occured.

Definition at line 259 of file interfaceAvr.cpp.

Here is the caller graph for this function:

void InterfaceAvr::message ( QString  text,
bool  CR = true,
bool  sayIt = false,
bool  addTimestamp = true 
)
signal

Emits a info or error message to a slot. This slot can be used to display a text on a splash screen, log file, to print it to a console...

Parameters:
textis the message to be emitted

Here is the caller graph for this function:

bool InterfaceAvr::openComPort ( QString  comPort)

Opens a serial port/device. On POSIX systems this looks like "/dev/tty4" oder "/dev/ttyUSB0". On Windows systems it's like "COM1".

Parameters:
comPortis the serial port
Returns:
true on access or false if an error occured, while opening the device.

Definition at line 43 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool InterfaceAvr::receiveChar ( unsigned char *  character,
QString  callingClassName = "none" 
)

Receives a character from the serial port/device.

Parameters:
character
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
true on access or false if an error occured.

Definition at line 107 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool InterfaceAvr::receiveInt ( int *  value,
QString  callingClassName = "none" 
)

Receives an integer value from the serial port/device (consisting of two char values, which are receivced one after another and combined to an int back).

Parameters:
*value
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
true on access or false if an error occured.

Definition at line 203 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool InterfaceAvr::receiveString ( QString &  string,
QString  callingClassName = "none" 
)

Receives a string from the serial port/device. It expects a starter at the beginning and a termintator at the end of the string which is currently defined as a const. Example: With *42# the 42 is the 'string' here.

Parameters:
&stringis the complete result - including the starter and the terminator!
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
true on access or false if an error occured.

Definition at line 162 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceAvr::robotState ( bool  state)
signal

This signal emits the robots state to all connected slots, to tell them if the robot is ON or OFF This signal is emitted, when the openComPort() method fails!

Parameters:
statecan be ON or OFF

Here is the caller graph for this function:

bool InterfaceAvr::sendChar ( unsigned char  character,
QString  callingClassName = "none" 
)

Sends a character to the serial port/device.

Parameters:
character
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
true on access or false if an error occured.

Definition at line 79 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool InterfaceAvr::sendString ( QString  string,
QString  callingClassName = "none" 
)

Sends a string to the serial port/device. When sending it prepends a start char and appends a terminator char wich the corresponting receiving Atmel expects. Example: *s8# sends the command 's8' to the receiver.

Parameters:
stringis the information to send - without starter and terminator!
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
true on access or false if an error occured.

Definition at line 128 of file interfaceAvr.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceAvr::tooMuchErrors ( )
signal

This signal is emmited, when too much errors occur while receiving or sending to the serial port.

See also:
Direcs::showExitDialog()

Here is the caller graph for this function:


Member Data Documentation

const int InterfaceAvr::BAUDRATE = 38400
staticprivate

For robot is "OFF".

Definition at line 140 of file interfaceAvr.h.

QString InterfaceAvr::className
private

Definition at line 134 of file interfaceAvr.h.

const bool InterfaceAvr::OFF = false
staticprivate

For robot is "ON".

Definition at line 138 of file interfaceAvr.h.

const bool InterfaceAvr::ON = true
staticprivate

Definition at line 137 of file interfaceAvr.h.

DirecsSerial* InterfaceAvr::serialPort
private

this will contain the name of this class at runtime for debug messages

Definition at line 135 of file interfaceAvr.h.

const char InterfaceAvr::starter = 42
staticprivate

This is the baudrate with which the serial port will be opened. The other (not parameterized) settings are "8N1".

Definition at line 142 of file interfaceAvr.h.

const char InterfaceAvr::terminator = 35
staticprivate

This starts the serial string for the Atmel controller. 42 = *.

Definition at line 143 of file interfaceAvr.h.


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