Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
BlackGPIO Class Reference

Interacts with end user, to use GPIO pins. More...

#include <BlackLib.h>

Inheritance diagram for BlackGPIO:
BlackCoreGPIO

Public Types

enum  flags {
  exportFileErr = 0, exportErr = 1,
  directionFileErr = 2, directionErr = 3,
  readErr = 4, writeErr = 5,
  forcingErr = 6, initializeErr = 7
}
 

Public Member Functions

 BlackGPIO (gpio_name pn, gpio_type pt)
 Constructor of BlackGPIO class. More...
 
virtual ~BlackGPIO ()
 Destructor of BlackGPIO class. More...
 
std::string getValue ()
 Exports value of gpio pin. More...
 
gpio_name getName ()
 Exports name of gpio pin. More...
 
gpio_type getType ()
 Exports type of gpio pin. More...
 
bool setValue (gpio_value v)
 Sets value of GPIO pin. More...
 
bool isHigh ()
 Checks value of GPIO pin. More...
 
void toggleValue ()
 Toggles value of GPIO pin. More...
 
bool fail ()
 Is used for general debugging. More...
 
bool fail (BlackGPIO::flags f)
 Is used for specific debugging. More...
 

Private Member Functions

bool isExported ()
 Checks the export state of GPIO pin. More...
 
bool isDirectionSet ()
 Checks direction of GPIO pin. More...
 
bool isReady ()
 Checks ready state of GPIO pin. More...
 
- Private Member Functions inherited from BlackCoreGPIO
 BlackCoreGPIO ()
 Constructor of BlackCoreGPIO class. More...
 
virtual ~BlackCoreGPIO ()
 Destructor of BlackCoreGPIO class. More...
 
std::string triggerInitialization (gpio_name pin, gpio_type type)
 Executes initialization. More...
 
std::string getDirectionFilePath ()
 Exports direction file path to derived class. More...
 
errorCoreGPIOgetErrorsFromCoreGPIO ()
 Exports errorCoreGPIO struct to derived class. More...
 

Private Attributes

errorGPIOgpioErrors
 is used to hold the errors of BlackGPIO class More...
 
gpio_name pinName
 is used to hold the selected GPIO pin name More...
 
gpio_type pinType
 is used to hold the selected GPIO pin type More...
 
std::string valuePath
 is used to hold the value file path More...
 

Detailed Description

Interacts with end user, to use GPIO pins.

This class is end node to use GPIO. End users interact with gpio pins from this class. It includes public functions to set and get properties of GPIO pins.

Member Enumeration Documentation

This enum is used to define GPIO debugging flags.

Enumerator
exportFileErr 

enumeration for errorCoreGPIO::exportFileError status

exportErr 

enumeration for errorGPIO::exportError status

directionFileErr 

enumeration for errorCoreGPIO::directionFileError status

directionErr 

enumeration for errorGPIO::directionError status

readErr 

enumeration for errorGPIO::readError status

writeErr 

enumeration for errorGPIO::writeError status

forcingErr 

enumeration for errorGPIO::forcingError status

initializeErr 

enumeration for errorCoreGPIO::initializeError status

Constructor & Destructor Documentation

BlackGPIO::BlackGPIO ( gpio_name  pn,
gpio_type  pt 
)

Constructor of BlackGPIO class.

This function initializes errorGPIO struct, calls triggerInitialization() function for generating GPIO pin, and prints this function's return value for informing user. Then it sets value file path.

Parameters
[in]pngpio pin name(enum)
[in]ptgpio pin type(enum)
See Also
triggerInitialization()
gpio_name
gpio_type
BlackGPIO::~BlackGPIO ( )
virtual

Destructor of BlackGPIO class.

Member Function Documentation

bool BlackGPIO::fail ( )

Is used for general debugging.

Returns
True if any error occured, else false.
See Also
errorGPIO
bool BlackGPIO::fail ( BlackGPIO::flags  f)

Is used for specific debugging.

You can use this function, after call BlackGPIO member functions in your code. The input parameter is used for finding out status of selected error.

Parameters
[in]fspecific error type (enum)
Returns
Value of selected error.
See Also
errorGPIO
gpio_name BlackGPIO::getName ( )

Exports name of gpio pin.

Returns
BlackGPIO::pinName variable.
gpio_type BlackGPIO::getType ( )

Exports type of gpio pin.

Returns
BlackGPIO::pinType variable.
std::string BlackGPIO::getValue ( )
virtual

Exports value of gpio pin.

This function checks pin ready state by calling isReady() function. If pin is ready, it reads specified file from path, where defined at BlackGPIO::valuePath variable. This file holds gpio pin value.

Returns
string type GPIO pin value. If file opening fails or pin isn't ready, it returns error message.

Implements BlackCoreGPIO.

bool BlackGPIO::isDirectionSet ( )
private

Checks direction of GPIO pin.

This function reads specified file from path, where defined at BlackGPIO::directionPath variable.

Returns
True if direction file can open successfully and its value is equal to defined direction when class initialization, else false.
bool BlackGPIO::isExported ( )
private

Checks the export state of GPIO pin.

This function reads specified file from path, where defined at BlackGPIO::valuePath variable. If this file can open successfully, this means pin is exported successfully.

Returns
False if file opening fails, else true.
bool BlackGPIO::isHigh ( )

Checks value of GPIO pin.

This function calls getValue() function and evaluates return value.

Returns
False if return value equals 0, else true.
See Also
getValue()
bool BlackGPIO::isReady ( )
private

Checks ready state of GPIO pin.

This function calls isExported() and isDirectionSet() functions and evaluates return values of these.

Returns
True if both functions return true, else false.
See Also
isExported()
isDirectionSet()
bool BlackGPIO::setValue ( gpio_value  v)

Sets value of GPIO pin.

If pin type is output and pin is ready, this function sets pin value to 1 or 0. The input parameter is converted to 1 or 0 and this value is saved to value file.

Parameters
[in]vnew pin value(enum)
Returns
True if setting new value is successful, else false.
See Also
gpio_value
void BlackGPIO::toggleValue ( )

Toggles value of GPIO pin.

If pin type is output, this function sets pin value to 1 or 0, by value of current state. This new value is saved to value file.

Member Data Documentation

errorGPIO* BlackGPIO::gpioErrors
private

is used to hold the errors of BlackGPIO class

gpio_name BlackGPIO::pinName
private

is used to hold the selected GPIO pin name

gpio_type BlackGPIO::pinType
private

is used to hold the selected GPIO pin type

std::string BlackGPIO::valuePath
private

is used to hold the value file path


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