Webcam Tracker
V1.0
Using openCV and an Arduino Uno
|
is responsable for the serial communication between PC-application and the Arduino Uno More...
#include <SerialCom.h>
Public Member Functions | |
void | write (char *message) |
Sends a message(command) to the Arduino Uno. More... | |
void | readString () |
Reads the serial port for incomming messages. More... | |
bool | newMessageAvailable () |
Shows if a new message is recieved from the Serial input. More... | |
string * | getLastMessage () |
Returns last message. More... | |
Static Public Member Functions | |
static SerialCom * | initialize (string portName, long baudeRate, int dataSize, char parityType, float nStopBits) |
Creates a object if there isn't one already. More... | |
Private Member Functions | |
SerialCom (string portName, long baudeRate, int dataSize, char parityType, float nStopBits) | |
Constructor. More... | |
void | publishError (string message) |
shows a error message on the console More... | |
void | publishSucces (string message) |
shows a succes message on the console More... | |
Private Attributes | |
ceSerial | serial |
Object which holds the ceSerial communication class. | |
string | line |
string of all characters in the serial message | |
string | lastMessage |
last serial message | |
bool | newMessage |
new message available flag | |
Static Private Attributes | |
static SerialCom * | instance = 0 |
pointer to the current used instance | |
is responsable for the serial communication between PC-application and the Arduino Uno
|
private |
Constructor.
portName | name of the COM-port |
baudeRate | baudeRate of the COM-port |
dataSize | size of the data |
parityType | paraity type |
nStopBits | number of stop bits |
|
private |
shows a error message on the console
Also sets the message as lastMessage
message | string containing the message |
|
private |
shows a succes message on the console
Also sets the message as lastMessage
message | string containing the message |
|
static |
Creates a object if there isn't one already.
portName | name of the COM-port |
baudeRate | baude rate of the COM-port |
dataSize | size of the data |
parityType | parity type |
nStopBits | number of stop bits |
void SerialCom::write | ( | char * | message | ) |
Sends a message(command) to the Arduino Uno.
Won't send a message if the COM-port isn't opened.
message | command to be send |
void SerialCom::readString | ( | ) |
Reads the serial port for incomming messages.
If ther isn't a character the readstring will break, so it's non-blocking.
When the character is a line feed(LF) the serial message will be pushed on to the deque.
bool SerialCom::newMessageAvailable | ( | ) |
Shows if a new message is recieved from the Serial input.
std::string * SerialCom::getLastMessage | ( | ) |
Returns last message.