Browse Source

update

only_u2
zhaohe 1 year ago
parent
commit
4815e93aff
  1. 54
      .vscode/settings.json
  2. BIN
      only_u2_data_parser/20240206_3ch.xlsx
  3. 2
      only_u2_data_parser/build.bat
  4. 63
      only_u2_data_parser/parse_packet_to_csv.cpp
  5. BIN
      only_u2_data_parser/parse_packet_to_csv.exe
  6. BIN
      only_u2_data_parser/raw.bin
  7. 26099
      only_u2_data_parser/raw.csv
  8. 13324
      only_u2_data_parser/raw.txt
  9. 54
      only_u2_data_parser/text2bin.cpp
  10. BIN
      only_u2_data_parser/text2bin.exe

54
.vscode/settings.json

@ -108,7 +108,59 @@
"nrf_soc.h": "c",
"sample_data_manager_service.h": "c",
"app_event.h": "c",
"compiler_abstraction.h": "c"
"compiler_abstraction.h": "c",
"ostream": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp"
},
"files.encoding": "gbk"
}

BIN
only_u2_data_parser/20240206_3ch.xlsx

2
only_u2_data_parser/build.bat

@ -0,0 +1,2 @@
g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ text2bin.cpp -o text2bin.exe
g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ parse_packet_to_csv.cpp -o parse_packet_to_csv.exe

63
only_u2_data_parser/parse_packet_to_csv.cpp

@ -0,0 +1,63 @@
#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
#pragma pack(1)
typedef struct parse_packet_to_csv {
uint8_t h0;
uint8_t h1;
uint32_t ch0;
uint32_t ch1;
uint32_t ch2;
uint8_t e0;
uint8_t e1;
};
#pragma pack()
int main(int argc, char* argv[]) {
/**
* @brief
* raw.bin
* raw.bin全部内容
*
*/
std::ifstream ifs("raw.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());
// 将通道数据存储到raw.csv
std::ofstream ofs("raw.csv");
ofs << "II,V1,V5\n";
for (size_t i = 0; i < buffer.size();) {
parse_packet_to_csv* packet = (parse_packet_to_csv*)&buffer[i];
if (packet->h0 == 0xA2 && packet->h1 == 0x02 && packet->e0 == 0x02 && packet->e1 == 0xA2) {
// printf("ch0 = %d, ch1 = %d, ch2 = %d\n", packet->ch0, packet->ch1, packet->ch2);
ofs << packet->ch0 << "," << packet->ch1 << "," << packet->ch2 << "\n";
i += sizeof(parse_packet_to_csv);
} else {
i++;
}
}
return 0;
}

BIN
only_u2_data_parser/parse_packet_to_csv.exe

BIN
only_u2_data_parser/raw.bin

26099
only_u2_data_parser/raw.csv
File diff suppressed because it is too large
View File

13324
only_u2_data_parser/raw.txt
File diff suppressed because it is too large
View File

54
only_u2_data_parser/text2bin.cpp

@ -0,0 +1,54 @@
#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;
}

BIN
only_u2_data_parser/text2bin.exe

Loading…
Cancel
Save