Fletchgen
The Fletcher Design Generator
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
fletchgen::srec::Record Class Reference

Structure to build up a single Record of an SREC file. More...

#include <srec.h>

Public Types

enum  Type {
  HEADER = 0 , DATA16 = 1 , DATA24 = 2 , DATA32 = 3 ,
  RESERVED = 4 , COUNT16 = 5 , COUNT24 = 6 , TERM32 = 7 ,
  TERM24 = 8 , TERM16 = 9
}
 The SREC Record type.
 

Public Member Functions

 Record (const Record &rec)
 SREC Record copy constructor.
 
 Record (Type type, uint32_t address, const uint8_t *data, size_t size)
 SREC Record constructor. Data is copied into the Record. More...
 
 ~Record ()
 Record destructor.
 
std::string ToString (bool line_feed=false)
 Return the SREC Record string.
 
uint32_t address () const
 Return the address of this record.
 
size_t size () const
 Return the size in bytes of this record.
 
uint8_t * data () const
 Return the data source pointer of this record.
 

Static Public Member Functions

static std::optional< RecordFromString (const std::string &line)
 Attempt to construct a Record from a string.
 
static Record Header (const std::string &header_str="HDR", uint16_t address=0)
 Create an SREC header Record. More...
 
template<uint32_t S>
static Record Data (uint32_t srec_address, const uint8_t *data, size_t size)
 Create an SREC data Record. More...
 

Static Public Attributes

static constexpr size_t MAX_DATA_BYTES = 32
 Maximum number of data bytes per Record.
 

Detailed Description

Structure to build up a single Record of an SREC file.

Definition at line 34 of file srec.h.

Constructor & Destructor Documentation

◆ Record()

fletchgen::srec::Record::Record ( Type  type,
uint32_t  address,
const uint8_t *  data,
size_t  size 
)

SREC Record constructor. Data is copied into the Record.

Parameters
typeThe type of the SREC record.
addressThe address of the data in the SREC file.
dataThe data.
sizeThe size of the data in bytes.

Definition at line 24 of file srec.cc.

Member Function Documentation

◆ Data()

template<uint32_t S>
static Record fletchgen::srec::Record::Data ( uint32_t  srec_address,
const uint8_t *  data,
size_t  size 
)
inlinestatic

Create an SREC data Record.

Template Parameters
SThe size of the address field.
Parameters
srec_addressThe address in the SREC file.
dataThe data.
sizeThe size of the data.
Returns
An SREC data record.

Definition at line 93 of file srec.h.

◆ Header()

Record fletchgen::srec::Record::Header ( const std::string &  header_str = "HDR",
uint16_t  address = 0 
)
static

Create an SREC header Record.

If header_str is longer than MAX_DATA_BYTES, the remainder of the characters are chopped off.

Parameters
header_strThe header ASCII string, typically "HDR"
addressThe header address, typically 0.
Returns
An SREC Record of type S0 (Header)

Definition at line 44 of file srec.cc.


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