-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhexfile.h
More file actions
69 lines (49 loc) · 1.86 KB
/
Copy pathhexfile.h
File metadata and controls
69 lines (49 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef HEXFILE_H
#define HEXFILE_H
#include "segment.h"
#include "mcbootflash-cpp.cpp"
// Intel hex types.
#define IHEX_DATA 0
#define IHEX_END_OF_FILE 1
#define IHEX_EXTENDED_SEGMENT_ADDRESS 2
#define IHEX_START_SEGMENT_ADDRESS 3
#define IHEX_EXTENDED_LINEAR_ADDRESS 4
#define IHEX_START_LINEAR_ADDRESS 5
std::string bytesToHexString(const std::vector<uint8_t> &bytes);
std::vector<uint8_t> hexStringToBytes(const std::string &str);
struct Chunk
{
unsigned int address;
std::vector<uint8_t> data;
};
class HexFile
{
private:
int current_segment_index; //utilisé dans addSegment (en python Segments.add) pour l'insertion rapide
//int parce que prends la valeur -1 à l'initialisation
//I did not copy the "_current_segment" member in python, because I can get it by its index
unsigned int word_size_bytes;
unsigned int execution_start_address;
public:
std::vector<Segment> debug_segments; //this works
std::vector<Segment> debug_segments_before_crop;
std::vector<Segment> segments;
unsigned int processed_total_bytes;
HexFile();
unsigned int crc_ihex(const std::vector<uint8_t> &bytes);
void unpack_ihex(
const std::string &record,
unsigned int &type_,
unsigned int &address,
unsigned int &size,
std::vector<uint8_t> &data);
void addSegment(const Segment &seg);
void crop(unsigned int minimum_address, unsigned int maximum_address);
unsigned int getMaximumAdressOfLastSegment();
void removeSegmentsBetween(unsigned int minimum_address, unsigned int maximum_address);
std::vector<Segment> chunked(std::string hexfile, BootAttrs bootattrs);
std::vector<Segment> chunks(unsigned int size, unsigned int alignment, std::vector<uint8_t> padding);
void add_ihex(std::vector<std::string> records);
unsigned int totalLength() const;
};
#endif /* HEXFILE_H */