|
|
@ -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; |
|
|
|
} |