| AVR Z-LINKŪ | |||||
#include <hexfile.h>
Definition at line 58 of file hexfile.h.
Public Member Functions | |
| void | Add (std::vector< byte > data) |
| void | Add (byte data) |
| size_t | GetByteCount () const |
| HEXRecord (unsigned long address) | |
| HEXRecord () | |
| void | Print (std::ostream &os) const |
| void | SetAddress (unsigned long address) |
| ~HEXRecord () | |
Private Attributes | |
| unsigned long | m_address |
| std::vector< byte > | m_data |
| HEXRecord::HEXRecord | ( | ) | [inline] |
| HEXRecord::HEXRecord | ( | unsigned long | address | ) | [inline, explicit] |
| void HEXRecord::Add | ( | std::vector< byte > | data | ) |
Add set of data bytes to the end of the record.
Definition at line 68 of file hexfile.cpp.
References Add().
00069 { 00070 for( size_t idx = 0; idx < data.size(); ++idx ) { 00071 Add( data.at( idx ) ); 00072 } 00073 }
Here is the call graph for this function:

| void HEXRecord::Add | ( | byte | data | ) |
Add one data byte to the end of the record.
Definition at line 57 of file hexfile.cpp.
References m_data.
Referenced by Add(), and operator<<().
00058 { 00059 if( data > 255 ) { 00060 throw std::runtime_error( "Data larger than 255" ); 00061 } 00062 00063 m_data.push_back( data ); 00064 }
| size_t HEXRecord::GetByteCount | ( | ) | const [inline] |
| void HEXRecord::Print | ( | std::ostream & | os | ) | const |
Print this record as a valid HEX file record to an output stream.
Definition at line 77 of file hexfile.cpp.
References GetByteCount(), HEXDATARECORDTYPE, m_address, and m_data.
Referenced by operator<<().
00078 { 00079 if( GetByteCount() > 255 ) { 00080 throw std::runtime_error( "HEX record have more than 255 data bytes" ); 00081 } 00082 00083 if( m_address > 65535 ) { 00084 throw std::runtime_error( "HEX record base address exceeds 16 bits" ); 00085 } 00086 00087 if( m_address + GetByteCount() > 65536 ) { 00088 throw std::runtime_error( "HEX record data crosses segment boundary" ); 00089 } 00090 00091 byte checksum = 0; 00092 checksum += GetByteCount(); // First byte in record. 00093 checksum += m_address & 0xff; // Second byte in record. 00094 checksum += (m_address >> 8) & 0xff; // Third byte in record. 00095 checksum += HEXDATARECORDTYPE; // Fourth byte in record. 00096 00097 os << ":" << std::setfill('0') << std::hex 00098 << std::setw(2) << GetByteCount() 00099 << std::setw(2) << ((m_address >> 8) & 0xff) 00100 << std::setw(2) << (m_address & 0xff) 00101 << std::setw(2) << HEXDATARECORDTYPE; 00102 00103 for( size_t idx = 0; idx < GetByteCount(); ++idx ) { 00104 byte data = m_data.at( idx ); 00105 os << std::setw(2) << data; 00106 checksum += data; 00107 } 00108 00109 os << std::setw(2) << ((-checksum) & 0xff) // 2's complement of total sum. 00110 << std::endl; 00111 }
Here is the call graph for this function:

| void HEXRecord::SetAddress | ( | unsigned long | address | ) | [inline] |
unsigned long HEXRecord::m_address [private] |
std::vector< byte > HEXRecord::m_data [private] |
Data bytes.
Definition at line 62 of file hexfile.h.
Referenced by Add(), GetByteCount(), and Print().
Generated on Sun Oct 29 18:12:00 2006 for AVR414 User's Guide - ATAVRRZ502 - Accessory Kit (PC Tools - HEXMaker) by 1.4.7
|