Provides the low level communication between the robots microcontroller and the laptop.
More...
#include <interfaceAvr.h>
List of all members.
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 |
( |
| ) |
|
InterfaceAvr::~InterfaceAvr |
( |
| ) |
|
Member Function Documentation
void InterfaceAvr::closeComPort |
( |
| ) |
|
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 | |
&value | is 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.
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:
-
text | is the message to be emitted |
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:
-
comPort | is 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.
bool InterfaceAvr::receiveChar |
( |
unsigned char * |
character, |
|
|
QString |
callingClassName = "none" |
|
) |
| |
Receives a character from the serial port/device.
- Parameters:
-
character | |
callingClassName | may 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.
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 | |
callingClassName | may 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.
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:
-
&string | is the complete result - including the starter and the terminator! |
callingClassName | may 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.
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:
-
bool InterfaceAvr::sendChar |
( |
unsigned char |
character, |
|
|
QString |
callingClassName = "none" |
|
) |
| |
Sends a character to the serial port/device.
- Parameters:
-
character | |
callingClassName | may 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.
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:
-
string | is the information to send - without starter and terminator! |
callingClassName | may 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.
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()
Member Data Documentation
const int InterfaceAvr::BAUDRATE = 38400 |
|
staticprivate |
QString InterfaceAvr::className |
|
private |
const bool InterfaceAvr::OFF = false |
|
staticprivate |
const bool InterfaceAvr::ON = true |
|
staticprivate |
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: