diff --git a/tools/build.bat b/tools/build.bat new file mode 100644 index 0000000..94e4901 --- /dev/null +++ b/tools/build.bat @@ -0,0 +1 @@ +g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ .\sample_bin_parse.cpp -o sample_bin_parse.exe \ No newline at end of file diff --git a/tools/sample_bin_parse.cpp b/tools/sample_bin_parse.cpp new file mode 100644 index 0000000..2e74d50 --- /dev/null +++ b/tools/sample_bin_parse.cpp @@ -0,0 +1,54 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// +#include +// +#include +// +#include + +#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; +} \ No newline at end of file diff --git a/tools/sample_bin_parse.exe b/tools/sample_bin_parse.exe new file mode 100644 index 0000000..dfaedda Binary files /dev/null and b/tools/sample_bin_parse.exe differ