CharDev Class Referenceabstract

#include <char_dev.hpp>

Inheritance diagram for CharDev:

Public Member Functions

virtual bool getChar (char *pInputChar, unsigned int timeout=portMAX_DELAY)=0
 
virtual bool putChar (char out, unsigned int timeout=portMAX_DELAY)=0
 
virtual bool flush (void)
 
bool gets (char *pBuff, int maxLen, unsigned int timeout=0xffffffff)
 
int printf (const char *format,...)
 
int scanf (const char *format,...)
 
uint16_t getPrintfMemSize (void) const
 
bool put (const char *pString, unsigned int timeout=0xffffffff)
 
void putline (const char *pBuff, unsigned int timeout=0xffffffff)
 
bool isReady (void)
 
void setReady (bool r)
 

Protected Member Functions

 CharDev ()
 
virtual ~CharDev ()
 

Detailed Description

Char device base class. You shouldn't use this directly because this is an abstract class and must be inherited and used by a parent object.

Constructor & Destructor Documentation

CharDev::CharDev ( )
protected
CharDev::~CharDev ( )
protectedvirtual

Member Function Documentation

virtual bool CharDev::flush ( void  )
inlinevirtual

Optional flush to flush out all the data

Reimplemented in UartDev, and NordicStream.

virtual bool CharDev::getChar ( char *  pInputChar,
unsigned int  timeout = portMAX_DELAY 
)
pure virtual
Returns
a character from the UART input
Parameters
pInputCharThe pointer to input char to store received character
timeoutOptional parameter which defaults to maximum value that will allow you to wait forever for a character to be received
Returns
true if a character was obtained within the given timeout

Implemented in UartDev, and NordicStream.

uint16_t CharDev::getPrintfMemSize ( void  ) const
inline

Get the size for the printf() memory used by printf() function

bool CharDev::gets ( char *  pBuff,
int  maxLen,
unsigned int  timeout = 0xffffffff 
)

Get a string of input up to maxLen

Parameters
pBuffThe buffer to store data to
maxLenThe maximum chars to get
timeoutThe timeout in ticks to wait
bool CharDev::isReady ( void  )
inline

This API just provides a means to set a flag if UART is ready or not This doesn't cause any change to the way UART functions.

int CharDev::printf ( const char *  format,
  ... 
)

Just like printf, except it will print to this output interface

Returns
the number of characters printed
bool CharDev::put ( const char *  pString,
unsigned int  timeout = 0xffffffff 
)

Output a null-terminated string puts() will also output newline chars "\r\n" at the end of the string

virtual bool CharDev::putChar ( char  out,
unsigned int  timeout = portMAX_DELAY 
)
pure virtual

Outputs a char given by

Parameters
out
timeoutOptional parameter which defaults to maximum value that will allow you to wait forever for a character to be sent
Returns
true if the output char was successfully written to Queue, or false if the output queue was full within the given timeout

Implemented in UartDev, and NordicStream.

void CharDev::putline ( const char *  pBuff,
unsigned int  timeout = 0xffffffff 
)
int CharDev::scanf ( const char *  format,
  ... 
)

Just like scanf, except this will perform scanf after receiving a line of input using the gets() method.

Warning
scanf() requires a
(newline) terminated char to work.
void CharDev::setReady ( bool  r)
inline

The documentation for this class was generated from the following files:
  • /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L2_Drivers/base/char_dev.hpp
  • /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L2_Drivers/base/char_dev.cpp