HALFRED  0.4.0
Functions
TXTDevice interface

Detailed Description

Introduction.

The TXTDevice interface is used for sending and receiving textual data through IODevices (see IODevice interface) such as UART.

Functions

void TXTDEV_WriteString (IODevice device, const char *str)
 
void TXTDEV_WriteINT32 (IODevice device, int32_t value, uint8_t base)
 
void TXTDEV_WriteUINT32 (IODevice device, uint32_t value, uint8_t base)
 
void TXTDEV_WriteINT64 (IODevice device, int64_t value, uint8_t base)
 
void TXTDEV_WriteUINT64 (IODevice device, uint64_t value, uint8_t base)
 
void TXTDEV_WriteFLOAT (IODevice device, float value, int precision)
 
void TXTDEV_WriteNL (IODevice device)
 
void TXTDEV_WriteDate (IODevice device, uint16_t year, uint8_t month, uint8_t day)
 
void TXTDEV_WriteTime (IODevice device, uint8_t hours, uint8_t minutes, uint8_t seconds)
 
void TXTDEV_WriteData (IODevice device, const uint8_t *data, size_t size, int base, int spacing, const char *space)
 
void TXTDEV_ReadString (IODevice input_device, IODevice mirror_device, char *str, size_t max_len)
 

Function Documentation

void TXTDEV_WriteString ( IODevice  device,
const char *  str 
)

Writes a NULL-terminated string to an IODevice.

Parameters
deviceIODevice to write to
strNULL-terminated string to write

References IODEV_Write().

Referenced by TXTDEV_WriteData().

void TXTDEV_WriteINT32 ( IODevice  device,
int32_t  value,
uint8_t  base 
)

Converts a 32bit signed integer to string using specified base, and writes the result to the provided IODevice.

Parameters
deviceIODevice to write to
valuesigned 32bit integer value to write
baseconversion base (10 for decimal number, 16 for hex etc.)

References IODEV_Write(), and TXTDEV_WriteUINT32().

Referenced by TXTDEV_WriteFLOAT().

void TXTDEV_WriteUINT32 ( IODevice  device,
uint32_t  value,
uint8_t  base 
)

Converts a 32bit unsigned integer to string using specified base, and writes the result to the provided IODevice.

Parameters
deviceIODevice to write to
valueunsigned 32bit integer value to write
baseconversion base (10 for decimal number, 16 for hex etc.)

References IODEV_Write().

Referenced by TXTDEV_WriteData(), TXTDEV_WriteDate(), TXTDEV_WriteFLOAT(), TXTDEV_WriteINT32(), and TXTDEV_WriteTime().

void TXTDEV_WriteINT64 ( IODevice  device,
int64_t  value,
uint8_t  base 
)

Converts a 64bit signed integer to string using specified base, and writes the result to the provided IODevice.

Parameters
deviceIODevice to write to
valuesigned 64bit integer value to write
baseconversion base (10 for decimal number, 16 for hex etc.)

References IODEV_Write(), and TXTDEV_WriteUINT64().

void TXTDEV_WriteUINT64 ( IODevice  device,
uint64_t  value,
uint8_t  base 
)

Converts a 64bit unsigned integer to string using specified base, and writes the result to the provided IODevice.

Parameters
deviceIODevice to write to
valueunsigned 64bit integer value to write
baseconversion base (10 for decimal number, 16 for hex etc.)

References IODEV_Write().

Referenced by TXTDEV_WriteINT64().

void TXTDEV_WriteFLOAT ( IODevice  device,
float  value,
int  precision 
)

Converts a float number to a string and writes the result to the provided IODevice.

Parameters
deviceIODevice to write to
valuefloat value to write
precisionnumber of digits after the dot

References IODEV_Write(), TXTDEV_WriteINT32(), and TXTDEV_WriteUINT32().

void TXTDEV_WriteNL ( IODevice  device)

Writes new line terminator to a specified IODevice.

Parameters
deviceIODevice to write to

References IODEV_Write().

void TXTDEV_WriteDate ( IODevice  device,
uint16_t  year,
uint8_t  month,
uint8_t  day 
)

Writes data in YYYY-MM-DD format.

Parameters
deviceIODevice to write to
yearyear
monthmonth (1..12)
dayday (1..31)

References IODEV_Write(), and TXTDEV_WriteUINT32().

void TXTDEV_WriteTime ( IODevice  device,
uint8_t  hours,
uint8_t  minutes,
uint8_t  seconds 
)

Writes time in HH:MM:SS format.

Parameters
deviceIODevice to write to
hourshours (0..23)
minutesminutes (0..59)
secondsseconds (0..59)

References IODEV_Write(), and TXTDEV_WriteUINT32().

void TXTDEV_WriteData ( IODevice  device,
const uint8_t *  data,
size_t  size,
int  base,
int  spacing,
const char *  space 
)

Writes contents of a data buffer.

Parameters
deviceIODevice to write to
datadata buffer
sizesize of the data buffer
basea base for integer to string conversion
spacingnumber of bytes after which a space string should be inserted
spacespace string or NULL

References IODEV_Write(), TXTDEV_WriteString(), and TXTDEV_WriteUINT32().

void TXTDEV_ReadString ( IODevice  input_device,
IODevice  mirror_device,
char *  str,
size_t  max_len 
)

Reads a string from input IODevice.

Parameters
input_deviceinput IODevice
mirror_devicean optional device that will receive the characters that are received by input_device
strdestination buffer for the string
max_lenmaximum size of the read string

References IODEV_Read(), and IODEV_Write().