TCode Library
A library to aid in decoding/using of Toy Code ("T-Code") data.
Loading...
Searching...
No Matches
TCodeParser Class Reference

Wrapper for parsing commands from TCode. More...

#include <TCodeParser.h>

Static Public Member Functions

static char toupper (const char value)
 Converts Lowecase Ascii to Uppercase.
 
static bool isnumber (const char value)
 Checks if the inputed ascii char is a number.
 
static bool isextention (const char value)
 Checks if an inputted char is one used for an extention Command in the decoding of TCode.
 
static bool isramp (const char value)
 Checks if an inputted char is one used for an ramp Command in the decoding of TCode.
 
static long getNextInt (unsigned char *buffer, const size_t length, size_t &index)
 In a string at the index pointed to by the index paramater gets the Integer contained at and after incrementing the index value.
 
static char getCharAt (unsigned char *buffer, const size_t length, size_t index)
 Gets the char at an index in an inputted buffer.
 
static size_t uintToStr (unsigned long value, unsigned char *buffer, const size_t length, size_t &placeIndex)
 Puts a converted int to string into a buffer.
 
static bool idValidRange (const TCode_Channel_Type type, const uint8_t channel, const uint8_t maxChannel)
 Checks if the given ID is in a valid range compared to a max channel input.
 
static bool idValidRange (const TCode_ChannelID id, const uint8_t maxChannel)
 Checks if the given id is in a valid range compared to a max channel input.
 
static bool idValid (const TCode_Channel_Type type, const uint8_t channel)
 Checks if the inputted type and channel number are valid.
 
static bool idValid (const TCode_ChannelID id)
 Checks if the inputted type and channel number are valid.
 
static int getStrfromID (unsigned char *buffer, const size_t length, const TCode_ChannelID &id)
 For a given ID returns the string representation of the ID.
 
static void getStrfromID (const TCode_ChannelID &id, String &out)
 For a given ID returns the string representation of the ID.
 
static TCode_ChannelID constructID (const TCode_Channel_Type type, const uint8_t channel)
 Takes a channel type and channel number and creates a Channel ID.
 
static TCode_Axis_Extention_Type getExtentionTypeFromStr (unsigned char *buffer, const size_t length, size_t &startIndex)
 Gets the Extention type from a string at the index specified.
 
static TCode_Axis_Ramp_Type getRampTypeFromStr (unsigned char *buffer, const size_t length, size_t &startIndex)
 Gets the Ramp type from a string at the index specified.
 
static TCode_ChannelID getIDFromStr (unsigned char *buffer, const size_t length, size_t &startIndex)
 Gets the ID from an inputted string from a given index.
 
static TCode_Command_Type getCommandType (unsigned char *buffer, const size_t length, size_t startIndex)
 Returns the type of command provided by the input string.
 
static bool parseAxisCommand (unsigned char *buffer, const size_t length, TCode_Axis_Command &out)
 Parses an Axis Command.
 
static bool parseDeviceCommand (unsigned char *buffer, const size_t length, TCode_Device_Command &out)
 Parses a Device Command.
 
static bool parseSetupCommand (unsigned char *buffer, const size_t length, TCode_Setup_Command &out)
 Parses a Setup Command.
 
static bool parseExternalCommand (unsigned char *buffer, const size_t length, TCode_External_Command &out)
 Parses an External Command.
 

Detailed Description

Wrapper for parsing commands from TCode.

Definition at line 15 of file TCodeParser.h.

Member Function Documentation

◆ constructID()

TCode_ChannelID TCodeParser::constructID ( const TCode_Channel_Type  type,
const uint8_t  channel 
)
static

Takes a channel type and channel number and creates a Channel ID.

Parameters
typethe TCode Channel Type
channelthe Channel number
Returns
returns a TCode_ChannelID from the channel type and channel number

Definition at line 88 of file TCodeParser.cpp.

◆ getCharAt()

static char TCodeParser::getCharAt ( unsigned char *  buffer,
const size_t  length,
size_t  index 
)
inlinestatic

Gets the char at an index in an inputted buffer.

Parameters
bufferpointer to buffer to be processed
lengthlength of buffer
indexindex to get char from
Returns
returns a char pointed to at the index position in the buffer (returns '\0' if out of range)

Definition at line 126 of file TCodeParser.h.

◆ getCommandType()

TCode_Command_Type TCodeParser::getCommandType ( unsigned char *  buffer,
const size_t  length,
size_t  startIndex 
)
static

Returns the type of command provided by the input string.

Parameters
bufferstring to be processed
lengthlength of buffer
Returns
a TCode Command Type e.g. Axis, Device, Setup if it is not a valid command None is returned

Definition at line 167 of file TCodeParser.cpp.

◆ getExtentionTypeFromStr()

TCode_Axis_Extention_Type TCodeParser::getExtentionTypeFromStr ( unsigned char *  buffer,
const size_t  length,
size_t &  startIndex 
)
static

Gets the Extention type from a string at the index specified.

Parameters
bufferstring to be processed
lengthlength of buffer
startIndexstarting index of the char to be processed
Returns
returns a TCode Axis Extention Type used in the Axis to work out if an extention means Time or Speed

Definition at line 93 of file TCodeParser.cpp.

◆ getIDFromStr()

TCode_ChannelID TCodeParser::getIDFromStr ( unsigned char *  buffer,
const size_t  length,
size_t &  startIndex 
)
static

Gets the ID from an inputted string from a given index.

Parameters
bufferstring to be processed
lengthlength of buffer
startIndexstarting index of the char to be processed
Returns
returns a TCode Channel ID found at the location at the starting index

Definition at line 142 of file TCodeParser.cpp.

◆ getNextInt()

static long TCodeParser::getNextInt ( unsigned char *  buffer,
const size_t  length,
size_t &  index 
)
inlinestatic

In a string at the index pointed to by the index paramater gets the Integer contained at and after incrementing the index value.

Parameters
bufferstring to be processed
lengthlength of buffer
indexthe index pointing to a position in the string
Returns
returns a long the integer found in the string represented as base 10 unsigned if a integer string is found which is less than 4 characters long then it will be multiplied til it reaches that minimum e.g. "1" = 1000 ,"01" = 100

Definition at line 95 of file TCodeParser.h.

◆ getRampTypeFromStr()

TCode_Axis_Ramp_Type TCodeParser::getRampTypeFromStr ( unsigned char *  buffer,
const size_t  length,
size_t &  startIndex 
)
static

Gets the Ramp type from a string at the index specified.

Parameters
bufferstring to be processed
lengthlength of buffer
startIndexstarting index of the char to be processed
Returns
returns a TCode Ramp Type used in the Axis to work out which ramp to use

Definition at line 107 of file TCodeParser.cpp.

◆ getStrfromID() [1/2]

void TCodeParser::getStrfromID ( const TCode_ChannelID id,
String &  out 
)
static

For a given ID returns the string representation of the ID.

Parameters
idIs the combined form of TCode_Channel_Type and the channel number
outThe Output String

Definition at line 75 of file TCodeParser.cpp.

◆ getStrfromID() [2/2]

int TCodeParser::getStrfromID ( unsigned char *  buffer,
const size_t  length,
const TCode_ChannelID id 
)
static

For a given ID returns the string representation of the ID.

Parameters
bufferoutput buffer
lengthlength of buffer
idIs the combined form of TCode_Channel_Type and the channel number
Returns
The length of chars used in the buffer

Definition at line 49 of file TCodeParser.cpp.

◆ idValid() [1/2]

bool TCodeParser::idValid ( const TCode_Channel_Type  type,
const uint8_t  channel 
)
static

Checks if the inputted type and channel number are valid.

Parameters
typethe TCode Channel Type
channelthe Channel number
Returns
returns true if the type and channel number are within accepted ranges and values 0-9 on channel number and a valid channel type

Definition at line 39 of file TCodeParser.cpp.

◆ idValid() [2/2]

bool TCodeParser::idValid ( const TCode_ChannelID  id)
static

Checks if the inputted type and channel number are valid.

Parameters
idIs the combined form of TCode_Channel_Type and the channel number
Returns
returns true if the type and channel number are within accepted ranges and values 0-9 on channel number and a valid channel type

Definition at line 44 of file TCodeParser.cpp.

◆ idValidRange() [1/2]

bool TCodeParser::idValidRange ( const TCode_Channel_Type  type,
const uint8_t  channel,
const uint8_t  maxChannel 
)
static

Checks if the given ID is in a valid range compared to a max channel input.

Parameters
typeThe channel type Linear,Rotation,Vibration,Auxiliary
channelThe channel number if the ID
maxChannelthe max channel to check against

Definition at line 9 of file TCodeParser.cpp.

◆ idValidRange() [2/2]

bool TCodeParser::idValidRange ( const TCode_ChannelID  id,
const uint8_t  maxChannel 
)
static

Checks if the given id is in a valid range compared to a max channel input.

Parameters
idThe ID to check
maxChannelthe max channel to check against

Definition at line 34 of file TCodeParser.cpp.

◆ isextention()

static bool TCodeParser::isextention ( const char  value)
inlinestatic

Checks if an inputted char is one used for an extention Command in the decoding of TCode.

Parameters
valueis the char value which needs checking
Returns
returns true if the inputted char is used as an extention character

Definition at line 58 of file TCodeParser.h.

◆ isnumber()

static bool TCodeParser::isnumber ( const char  value)
inlinestatic

Checks if the inputed ascii char is a number.

Parameters
valueis the char value which needs checking
Returns
returns true for if the inputted char is a number

Definition at line 33 of file TCodeParser.h.

◆ isramp()

static bool TCodeParser::isramp ( const char  value)
inlinestatic

Checks if an inputted char is one used for an ramp Command in the decoding of TCode.

Parameters
valueis the char value which needs checking
Returns
returns true if the inputted char is used as an ramp character

Definition at line 75 of file TCodeParser.h.

◆ parseAxisCommand()

bool TCodeParser::parseAxisCommand ( unsigned char *  buffer,
const size_t  length,
TCode_Axis_Command out 
)
static

Parses an Axis Command.

Parameters
bufferstring to be processed
lengthlength of buffer
outa TCode Axis command struct so that the command can be executed easier

Definition at line 190 of file TCodeParser.cpp.

◆ parseDeviceCommand()

bool TCodeParser::parseDeviceCommand ( unsigned char *  buffer,
const size_t  length,
TCode_Device_Command out 
)
static

Parses a Device Command.

Parameters
bufferstring to be processed
lengthlength of buffer
outCommand to be outputted to
Returns
a TCode Device Command which is a data representation of the device command to be processed easier

Definition at line 281 of file TCodeParser.cpp.

◆ parseExternalCommand()

bool TCodeParser::parseExternalCommand ( unsigned char *  buffer,
const size_t  length,
TCode_External_Command out 
)
static

Parses an External Command.

Parameters
bufferstring to be processed
lengthlength of buffer
outa TCode Setup command struct in a data representation to be processed easier

Definition at line 268 of file TCodeParser.cpp.

◆ parseSetupCommand()

bool TCodeParser::parseSetupCommand ( unsigned char *  buffer,
const size_t  length,
TCode_Setup_Command out 
)
static

Parses a Setup Command.

Parameters
bufferstring to be processed
lengthlength of buffer
outa TCode Setup command struct in a data representation to be processed easier

Definition at line 239 of file TCodeParser.cpp.

◆ toupper()

static char TCodeParser::toupper ( const char  value)
inlinestatic

Converts Lowecase Ascii to Uppercase.

Parameters
valueis the value of the char which needs converting to uppercase
Returns
returns the uppercase representation of the inputted ascii char

Definition at line 23 of file TCodeParser.h.

◆ uintToStr()

static size_t TCodeParser::uintToStr ( unsigned long  value,
unsigned char *  buffer,
const size_t  length,
size_t &  placeIndex 
)
inlinestatic

Puts a converted int to string into a buffer.

Parameters
valueinteger to be converted
bufferpointer to buffer where string is going to be put
lengthlength of buffer
placeIndexindex to put the converted int
Returns
returns length of writen value

Definition at line 141 of file TCodeParser.h.


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