EtherCard
Ardino interface library for the ENC28J60 Ethernet controller chip (GPL).
BufferFiller Class Reference

This class populates network send and receive buffers. More...

#include <EtherCard.h>

Public Member Functions

 BufferFiller ()
 Empty constructor.
 
 BufferFiller (uint8_t *buf)
 Constructor. More...
 
void emit_p (const char *fmt PROGMEM,...)
 Add formatted text to buffer. More...
 
void emit_raw (const char *s, uint16_t n)
 Add data to buffer from main memory. More...
 
void emit_raw_p (const char *p PROGMEM, uint16_t n)
 Add data to buffer from program space string. More...
 
uint8_t * buffer () const
 Get pointer to start of buffer. More...
 
uint16_t position () const
 Get cursor position. More...
 
virtual WRITE_RESULT write (uint8_t v)
 Write one byte to buffer. More...
 

Detailed Description

This class populates network send and receive buffers.

This class provides formatted printing into memory. Users can use it to write into send buffers.

Nota: PGM_P: is a pointer to a string in program space (defined in the source code, updated to PROGMEM)

Format string

Format Parameter Output
$D uint16_t Decimal representation
$T ¤ double Decimal representation with 3 digits after decimal sign ([-]d.ddd)
$H uint16_t Hexadecimal value of lsb (from 00 to ff)
$L long Decimal representation
$S const char* Copy null terminated string from main memory
$F PGM_P Copy null terminated string from program space
$E byte* Copy null terminated string from EEPROM space
$$ none '$'

¤ Available only if FLOATEMIT is defined

Examples

uint16_t ddd = 123;
double ttt = 1.23;
uint16_t hhh = 0xa4;
long lll = 123456789;
char * sss;
char fff[] PROGMEM = "MyMemory";
sss[0] = 'G';
sss[1] = 'P';
sss[2] = 'L';
sss[3] = 0;
buf.emit_p( PSTR("ddd=$D\n"), ddd ); // "ddd=123\n"
buf.emit_p( PSTR("ttt=$T\n"), ttt ); // "ttt=1.23\n" **TO CHECK**
buf.emit_p( PSTR("hhh=$H\n"), hhh ); // "hhh=a4\n"
buf.emit_p( PSTR("lll=$L\n"), lll ); // "lll=123456789\n"
buf.emit_p( PSTR("sss=$S\n"), sss ); // "sss=GPL\n"
buf.emit_p( PSTR("fff=$F\n"), fff ); // "fff=MyMemory\n"
Examples:
etherNode.ino, JeeUdp.ino, and rbbb_server.ino.

Constructor & Destructor Documentation

◆ BufferFiller()

BufferFiller::BufferFiller ( uint8_t *  buf)
inline

Constructor.

Parameters
bufPointer to the ethernet data buffer

Member Function Documentation

◆ buffer()

uint8_t* BufferFiller::buffer ( ) const
inline

Get pointer to start of buffer.

Returns
uint8_t* Pointer to start of buffer

◆ emit_p()

void BufferFiller::emit_p ( const char *fmt  PROGMEM,
  ... 
)

Add formatted text to buffer.

Parameters
fmtFormat string (see Class description)
...parameters for format string
Examples:
etherNode.ino, JeeUdp.ino, and rbbb_server.ino.

◆ emit_raw()

void BufferFiller::emit_raw ( const char *  s,
uint16_t  n 
)
inline

Add data to buffer from main memory.

Parameters
sPointer to data
nNumber of characters to copy

◆ emit_raw_p()

void BufferFiller::emit_raw_p ( const char *p  PROGMEM,
uint16_t  n 
)
inline

Add data to buffer from program space string.

Parameters
pProgram space string pointer
nNumber of characters to copy

◆ position()

uint16_t BufferFiller::position ( ) const
inline

Get cursor position.

Returns
uint16_t Cursor position
Examples:
etherNode.ino, JeeUdp.ino, and rbbb_server.ino.

◆ write()

virtual WRITE_RESULT BufferFiller::write ( uint8_t  v)
inlinevirtual

Write one byte to buffer.

Parameters
vByte to add to buffer