23 changed files with 510 additions and 834 deletions
-
5.gitmodules
-
6.vscode/settings.json
-
4app/app.uvoptx
-
8app/app.uvprojx
-
2app/src/app_basic_service/basic/event.h
-
6app/src/app_main.c
-
2app/src/app_main.h
-
2app/src/ble_data_processer_utils.c
-
2app/src/ble_data_processer_utils.h
-
4app/src/main.c
-
1oximeter_ble_server
-
2protocol
-
9scripter/build_app.bat
-
121tools/one_lead_realtime_report_parser.cpp
-
BINtools/one_lead_realtime_report_parser.exe
-
102tools/one_lead_upload_packet_parser.cpp
-
BINtools/one_lead_upload_packet_parser.exe
-
54tools/sample_bin_parse.cpp
-
BINtools/sample_bin_parse.exe
-
54tools/text2bin.cpp
-
BINtools/text2bin.exe
@ -1,5 +1,5 @@ |
|||
#pragma once |
|||
#include <stdint.h> |
|||
|
|||
void one_conduction_main(); |
|||
void app_main(); |
|||
void one_conduction_process_rx_packet(uint8_t* rx, int len); |
@ -1 +1 @@ |
|||
Subproject commit 286f8bbe136357e72b72f7d3e2a5b0ad64e99710 |
|||
Subproject commit 93ba9dbc3fe99c97276ab9737a710911642dc2b8 |
@ -1,121 +0,0 @@ |
|||
|
|||
#include <fstream>
|
|||
#include <functional>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <thread>
|
|||
#include <vector>
|
|||
//
|
|||
#include <winsock2.h>
|
|||
//
|
|||
#include <Windows.h>
|
|||
//
|
|||
#include <stdio.h>
|
|||
|
|||
#pragma comment(lib, "ws2_32.lib")
|
|||
#define PORT 8988
|
|||
|
|||
// #define EACH_FRAME_SIZE 180
|
|||
// #define DATA_NUM (EACH_FRAME_SIZE / 3)
|
|||
|
|||
// 5A A5
|
|||
// 03 00 65
|
|||
// 05 00 00 00
|
|||
// 77 07
|
|||
// 80 07
|
|||
// 7F 07
|
|||
// 88 07
|
|||
// 8D 07
|
|||
// 5B B5
|
|||
#pragma pack(1)
|
|||
typedef struct parse_packet_to_csv { |
|||
uint8_t h0; |
|||
uint8_t h1; |
|||
uint8_t header[3]; |
|||
uint8_t index[4]; |
|||
uint16_t data[5]; |
|||
uint8_t e0; |
|||
uint8_t e1; |
|||
}; |
|||
#pragma pack()
|
|||
|
|||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
|||
|
|||
uint16_t chdatacache[5]; |
|||
|
|||
void parse_chdatacache(parse_packet_to_csv *packet) { |
|||
chdatacache[0] = packet->data[0]; |
|||
chdatacache[1] = packet->data[1]; |
|||
chdatacache[2] = packet->data[2]; |
|||
chdatacache[3] = packet->data[3]; |
|||
chdatacache[4] = packet->data[4]; |
|||
} |
|||
|
|||
int main(int argc, char *argv[]) { |
|||
/**
|
|||
* @brief |
|||
* 打开raw.txt |
|||
* 读取raw.txt全部内容 |
|||
* 去掉换行,空格,回车 |
|||
* 将16进制字符串转换成二进制 |
|||
* 写入raw.bin |
|||
*/ |
|||
|
|||
std::ifstream ifs("Data.txt"); |
|||
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); |
|||
ifs.close(); |
|||
|
|||
std::string str2; |
|||
for (auto &c : str) { |
|||
if (c == ' ' || c == '\n' || c == '\r') { |
|||
continue; |
|||
} |
|||
str2.push_back(c); |
|||
} |
|||
|
|||
std::ofstream ofs("Data.bin", std::ios::binary); |
|||
for (size_t i = 0; i < str2.size(); i += 2) { |
|||
std::string str3 = str2.substr(i, 2); |
|||
char c = (char)std::stoi(str3, nullptr, 16); |
|||
ofs.write(&c, 1); |
|||
} |
|||
ofs.close(); |
|||
|
|||
/**
|
|||
* @brief |
|||
* 解析上报文件 |
|||
*/ |
|||
|
|||
{ |
|||
std::ifstream ifs("Data.bin", std::ios::binary); |
|||
std::vector<char> buffer((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); |
|||
ifs.close(); |
|||
|
|||
printf("buffer.size() = %d\n", buffer.size()); |
|||
std::ofstream ofs("Data.csv"); |
|||
for (size_t i = 0; i < buffer.size();) { |
|||
parse_packet_to_csv *packet = (parse_packet_to_csv *)&buffer[i]; |
|||
|
|||
if (packet->h0 == 0x5A && packet->h1 == 0xA5 && packet->e0 == 0x5B && packet->e1 == 0xB5) { |
|||
parse_chdatacache(packet); |
|||
for (size_t i = 0; i < ARRAY_SIZE(chdatacache); i += 1) { |
|||
ofs << chdatacache[i] << "\n"; |
|||
} |
|||
i += sizeof(parse_packet_to_csv); |
|||
} else { |
|||
i++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
printf("parse over\n"); |
|||
|
|||
while (true) { |
|||
std::this_thread::sleep_for(std::chrono::seconds(1)); |
|||
} |
|||
} |
@ -1,102 +0,0 @@ |
|||
|
|||
#include <fstream>
|
|||
#include <functional>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <thread>
|
|||
#include <vector>
|
|||
//
|
|||
#include <winsock2.h>
|
|||
//
|
|||
#include <Windows.h>
|
|||
//
|
|||
#include <stdio.h>
|
|||
|
|||
#pragma comment(lib, "ws2_32.lib")
|
|||
#define PORT 8988
|
|||
|
|||
// #define EACH_FRAME_SIZE 180
|
|||
// #define DATA_NUM (EACH_FRAME_SIZE / 3)
|
|||
|
|||
typedef struct parse_packet_to_csv { |
|||
uint8_t h0; |
|||
uint8_t h1; |
|||
uint8_t data[128]; |
|||
uint8_t e0; |
|||
uint8_t e1; |
|||
}; |
|||
|
|||
uint32_t chdatacache[64]; |
|||
void parse_chdatacache(parse_packet_to_csv *packet) { |
|||
for (size_t i = 0; i < 64; i++) { |
|||
chdatacache[i] = (packet->data[i * 2]) | (packet->data[i * 2 + 1] << 8); |
|||
} |
|||
} |
|||
|
|||
int main(int argc, char *argv[]) { |
|||
/**
|
|||
* @brief |
|||
* 打开raw.txt |
|||
* 读取raw.txt全部内容 |
|||
* 去掉换行,空格,回车 |
|||
* 将16进制字符串转换成二进制 |
|||
* 写入raw.bin |
|||
*/ |
|||
|
|||
std::ifstream ifs("Data.txt"); |
|||
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); |
|||
ifs.close(); |
|||
|
|||
std::string str2; |
|||
for (auto &c : str) { |
|||
if (c == ' ' || c == '\n' || c == '\r') { |
|||
continue; |
|||
} |
|||
str2.push_back(c); |
|||
} |
|||
|
|||
std::ofstream ofs("Data.bin", std::ios::binary); |
|||
for (size_t i = 0; i < str2.size(); i += 2) { |
|||
std::string str3 = str2.substr(i, 2); |
|||
char c = (char)std::stoi(str3, nullptr, 16); |
|||
ofs.write(&c, 1); |
|||
} |
|||
ofs.close(); |
|||
|
|||
/**
|
|||
* @brief |
|||
* 解析上报文件 |
|||
*/ |
|||
|
|||
{ |
|||
std::ifstream ifs("Data.bin", std::ios::binary); |
|||
std::vector<char> buffer((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); |
|||
ifs.close(); |
|||
|
|||
printf("buffer.size() = %d\n", buffer.size()); |
|||
std::ofstream ofs("Data.csv"); |
|||
for (size_t i = 0; i < buffer.size();) { |
|||
parse_packet_to_csv *packet = (parse_packet_to_csv *)&buffer[i]; |
|||
parse_chdatacache(packet); |
|||
if (packet->h0 == 0x4A && packet->h1 == 0xA4 && packet->e0 == 0x4B && packet->e1 == 0xB4) { |
|||
for (size_t i = 0; i < 64; i += 1) { |
|||
ofs << chdatacache[i] << "\n"; |
|||
} |
|||
i += sizeof(parse_packet_to_csv); |
|||
} else { |
|||
i++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
printf("parse over\n"); |
|||
|
|||
while (true) { |
|||
std::this_thread::sleep_for(std::chrono::seconds(1)); |
|||
} |
|||
} |
@ -1,54 +0,0 @@ |
|||
|
|||
#include <fstream>
|
|||
#include <functional>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <thread>
|
|||
#include <vector>
|
|||
//
|
|||
#include <winsock2.h>
|
|||
//
|
|||
#include <Windows.h>
|
|||
//
|
|||
#include <stdio.h>
|
|||
|
|||
#pragma comment(lib, "ws2_32.lib")
|
|||
#define PORT 8988
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
// 打开 0.bin
|
|||
// 读取 0.bin 到数组中
|
|||
// 每次读9byte
|
|||
// 3byte 3byte 3byte
|
|||
// 存放到0.csv中
|
|||
|
|||
std::ifstream ifs("0.bin", std::ios::binary); |
|||
if (!ifs) { |
|||
std::cerr << "open 0.bin failed" << std::endl; |
|||
return -1; |
|||
} |
|||
|
|||
std::ofstream ofs("0.csv", std::ios::binary | std::ios::trunc); |
|||
if (!ofs) { |
|||
std::cerr << "open 0.csv failed" << std::endl; |
|||
return -1; |
|||
} |
|||
|
|||
char buf[9]; |
|||
while (ifs.read(buf, 9)) { |
|||
unsigned int a = 0; |
|||
unsigned int b = 0; |
|||
unsigned int c = 0; |
|||
a = (unsigned char)buf[0] | (unsigned char)buf[1] << 8 | (unsigned char)buf[2] << 16; |
|||
b = (unsigned char)buf[3] | (unsigned char)buf[4] << 8 | (unsigned char)buf[5] << 16; |
|||
c = (unsigned char)buf[6] | (unsigned char)buf[7] << 8 | (unsigned char)buf[8] << 16; |
|||
ofs << a << "," << b << "," << c << std::endl; |
|||
} |
|||
|
|||
return 0; |
|||
} |
@ -1,54 +0,0 @@ |
|||
|
|||
#include <fstream>
|
|||
#include <functional>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <thread>
|
|||
#include <vector>
|
|||
//
|
|||
#include <winsock2.h>
|
|||
//
|
|||
#include <Windows.h>
|
|||
//
|
|||
#include <stdio.h>
|
|||
|
|||
#pragma comment(lib, "ws2_32.lib")
|
|||
#define PORT 8988
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
/**
|
|||
* @brief |
|||
* 打开raw.txt |
|||
* 读取raw.txt全部内容 |
|||
* 去掉换行,空格,回车 |
|||
* 将16进制字符串转换成二进制 |
|||
* 写入raw.bin |
|||
*/ |
|||
|
|||
std::ifstream ifs("raw.txt"); |
|||
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); |
|||
ifs.close(); |
|||
|
|||
std::string str2; |
|||
for (auto &c : str) { |
|||
if (c == ' ' || c == '\n' || c == '\r') { |
|||
continue; |
|||
} |
|||
str2.push_back(c); |
|||
} |
|||
|
|||
std::ofstream ofs("raw.bin", std::ios::binary); |
|||
for (size_t i = 0; i < str2.size(); i += 2) { |
|||
std::string str3 = str2.substr(i, 2); |
|||
char c = (char)std::stoi(str3, nullptr, 16); |
|||
ofs.write(&c, 1); |
|||
} |
|||
ofs.close(); |
|||
|
|||
return 0; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue