This class represents a microcontroller. More...
#include <microcont.h>


Public Member Functions | |
| MCInterface () | |
| Initializes the interface. More... | |
| void | OpenPort (const QString &port) |
| Opens the specified port. More... | |
| void | ClosePort (void) |
| Closes the serial connection with the microcontroller. More... | |
| void | ResetPort (void) |
| Resets the port (closes and then reopens the port) More... | |
| bool | IsOpen (void) |
| Returns true if the port is opened. More... | |
| QByteArray | SendCommand (const quint8 *command, int len, unsigned int expectedreslen, int timeout=500) |
| Sends a command to the microcontroller. More... | |
| int | GetMCError (void) const |
| Returns the current error state of the microcontroller. More... | |
| int | GetMCErrorID (void) const |
| Returns the id returned from the microcontroller during an error. More... | |
| int | GetMCErrorCMD (void) const |
| Returns the command returned from the microcontroller during an error. More... | |
| QSerialPort::SerialPortError | GetSPError (void) const |
| Returns the error code from the serial port. More... | |
| QByteArray | RetrieveInfo (void) |
| Gets state info from the microcontroller. More... | |
Private Member Functions | |
| Q_DISABLE_COPY (MCInterface) | |
| Disables copying of this class. More... | |
| void | ThrowException (const QString &desc) const |
| Throws an exception using the current error numbers. More... | |
Private Attributes | |
| QSerialPort | _sp |
| Serial port object. More... | |
| int | _mcerror |
| Microcontroller error flag. More... | |
| int | _mcerrorcmd |
| Command returned by the microcontroller during an error. More... | |
| int | _mcerrorid |
| ID of the power unit, etc, causing the error. More... | |
This class represents a microcontroller.
This command is mostly used to connect and send commands.
Definition at line 20 of file microcont.h.
| MCInterface::MCInterface | ( | ) |
Initializes the interface.
Definition at line 14 of file microcont.cpp.
| void MCInterface::ClosePort | ( | void | ) |
Closes the serial connection with the microcontroller.
Definition at line 72 of file microcont.cpp.

| int MCInterface::GetMCError | ( | void | ) | const |
Returns the current error state of the microcontroller.
See ConvertMCError()
Definition at line 24 of file microcont.cpp.
| int MCInterface::GetMCErrorCMD | ( | void | ) | const |
Returns the command returned from the microcontroller during an error.
The ID should represent which command had a problem
Definition at line 34 of file microcont.cpp.
| int MCInterface::GetMCErrorID | ( | void | ) | const |
Returns the id returned from the microcontroller during an error.
The ID should represent which PowerUnit had a problem
Definition at line 29 of file microcont.cpp.
| QSerialPort::SerialPortError MCInterface::GetSPError | ( | void | ) | const |
Returns the error code from the serial port.
See documentation for QSterialPort
Definition at line 19 of file microcont.cpp.

| bool MCInterface::IsOpen | ( | void | ) |
Returns true if the port is opened.
Definition at line 134 of file microcont.cpp.
| void MCInterface::OpenPort | ( | const QString & | port) |
Opens the specified port.
After opening the port, it waits for the identification string. If something goes wrong, it throws a MCInterfaceException (through ThrowException())
Definition at line 39 of file microcont.cpp.


|
private |
Disables copying of this class.
| void MCInterface::ResetPort | ( | void | ) |
Resets the port (closes and then reopens the port)
Definition at line 78 of file microcont.cpp.

| QByteArray MCInterface::RetrieveInfo | ( | void | ) |
Gets state info from the microcontroller.
Information, including dimmer levels, timestamps, etc, are stored in a specific way in a QByteArray
| MCInterfaceException | An error occurred during sending the command or receiving the response |
Definition at line 127 of file microcont.cpp.

| QByteArray MCInterface::SendCommand | ( | const quint8 * | command, |
| int | len, | ||
| unsigned int | expectedreslen, | ||
| int | timeout = 500 |
||
| ) |
Sends a command to the microcontroller.
Commands are stored in an array of bytes. The reason for this is that it is a bit cleaner to write the commands, ie
| command | Array of bytes to send |
| len | The length of the command to send |
| expectedreslen | The length of the result expected (not including the 3 header bytes) |
| timeout | The amount of time to wait for a response from the microcontroller (in ms) |
| MCInterfaceException | An error occurred during sending the command or receiving the response |
Definition at line 86 of file microcont.cpp.


|
private |
Throws an exception using the current error numbers.
This also taks a description
Definition at line 122 of file microcont.cpp.


|
private |
Microcontroller error flag.
Definition at line 108 of file microcont.h.
|
private |
Command returned by the microcontroller during an error.
Definition at line 111 of file microcont.h.
|
private |
ID of the power unit, etc, causing the error.
Definition at line 114 of file microcont.h.
|
private |
Serial port object.
Definition at line 105 of file microcont.h.
1.8.4