Webcam Tracker  V1.0
Using openCV and an Arduino Uno
CommandParser.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <stdio.h>
10 #include <string.h>
11 #include <HardwareSerial.h>
12 
13 
18 {
19 private:
20  char ch;
21  char buf[255];
22  uint8_t bufIndex;
23 
25 
26 public:
27 
29  enum COMMANDS{
33  HOME,
34  ERROR
35  };
36 
37 private:
39  CommandParser();
40 
47  uint8_t createBuffer();
48 
52  uint8_t checkCommand();
53 
54 public:
58  static CommandParser* initialize();
59 
64  uint8_t parse();
65 
68  char* getCommand();
69 };
70 
Parses the serial input for commands.
Definition: CommandParser.h:18
char * getCommand()
Get the command buffer.
Definition: CommandParser.cpp:72
static CommandParser * instance
pointer to current used instance
Definition: CommandParser.h:24
COMMANDS
Definition: CommandParser.h:29
@ WAITING
Indicates parser is waiting for a command ('/n' or '/r' character)
Definition: CommandParser.h:30
@ ERROR
Indicates that the command is not recognized.
Definition: CommandParser.h:34
@ PAN_TILT
Indicates a Pan and Tilt command.
Definition: CommandParser.h:31
@ PAN_TILT_OFFSET
Indicates a Pan and Tilt offset command.
Definition: CommandParser.h:32
@ HOME
Indicates a Home command.
Definition: CommandParser.h:33
char buf[255]
All characters read from serial port.
Definition: CommandParser.h:21
CommandParser()
Constructor of the class.
Definition: CommandParser.cpp:13
uint8_t checkCommand()
Checks the buffer for a command Checks the buffer to see if there is a known command....
Definition: CommandParser.cpp:36
static CommandParser * initialize()
Creates a new instance of the class if there isn't one.
Definition: CommandParser.cpp:53
uint8_t createBuffer()
Checks the serial port for input if the character is a line feed(LF) or carriage return(CR) the end o...
Definition: CommandParser.cpp:18
uint8_t bufIndex
Location index off the last character placed in the buffer.
Definition: CommandParser.h:22
uint8_t parse()
Reads serial input and checks for commands.
Definition: CommandParser.cpp:64
char ch
Last read character from serial port.
Definition: CommandParser.h:20