Browse Source

update

master
zhaohe 1 year ago
parent
commit
20918b72e7
  1. 1
      tools/build.bat
  2. 54
      tools/sample_bin_parse.cpp
  3. BIN
      tools/sample_bin_parse.exe

1
tools/build.bat

@ -0,0 +1 @@
g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ .\sample_bin_parse.cpp -o sample_bin_parse.exe

54
tools/sample_bin_parse.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[]) {
// 打开 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;
}

BIN
tools/sample_bin_parse.exe

Loading…
Cancel
Save