-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (57 loc) · 2.14 KB
/
Copy pathmain.cpp
File metadata and controls
89 lines (57 loc) · 2.14 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <fstream>
#include <cstdint>
#include <iostream>
#include "src_manager.hpp"
#include <map>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
int main() {
std::string bin_file_name, log_file_name;
name_add_time_str(&bin_file_name, &log_file_name);
std::cout << "二进制文件名: " << bin_file_name << " 日志文件名:" << log_file_name << std::endl;
src_manager_init();
// 等待按下回车开始制作文件
// 等待按下回车或输入 'q'
printf("请按回车开始制作文件,或输入 'q' 退出程序...");
std::string input;
std::getline(std::cin, input);
if (input == "q") {
printf("程序已退出。\n");
exit(0);
}
else if (input.empty()) {
printf("继续执行...\n");
}
// 制作存储芯片的数据头
creat_flash_data_head(bin_file_name);
std::ofstream outfile(bin_file_name, std::ios::binary);
src_manager_write_head(outfile, src_head);
src_manager_write_addr_table(outfile);
src_manager_write_data(outfile);
src_manager_verify_data();
outfile.close();
std::cout << "Bin file out Done!" << std::endl;
// // 将 map 拷贝到 vector 并按地址排序
// std::vector<std::pair<std::string, size_t>> sorted_addr(src_addr_map.begin(), src_addr_map.end());
// std::sort(sorted_addr.begin(), sorted_addr.end(), [](const auto& a, const auto& b) {
// return a.second < b.second;
// });
// // 输出地址表到文件(十六进制,按地址顺序)
// std::ofstream addrfile(log_file_name, std::ios::out);
// if (addrfile.is_open()) {
// for (const auto& kv : sorted_addr) {
// addrfile << kv.first << ": 0x" << std::hex << std::uppercase << kv.second << std::endl;
// }
// addrfile.close();
// std::cout << "地址表已经输出 " << log_file_name << std::endl;
// }
// else {
// std::cout << "无法打开 " << log_file_name << "文件进行写入" << std::endl;
// }
// // 同时在控制台输出(十六进制,按地址顺序)
// for (const auto& kv : sorted_addr)
// std::cout << kv.first << ": 0x" << std::hex << std::uppercase << kv.second << std::endl;
return 0;
}