9 changed files with 159 additions and 9 deletions
-
2app/src/board/board.h
-
17app/src/board/board_button.c
-
8app/src/device_ctrl_service.c
-
14app/src/heart_wave_sample_service.c
-
10sample_bin_parser/.clang-format
-
62sample_bin_parser/.vscode/settings.json
-
1sample_bin_parser/README.md
-
54sample_bin_parser/sample_bin_parse.cpp
-
BINsample_bin_parser/sample_bin_parse.exe
@ -0,0 +1,10 @@ |
|||
|
|||
# Defines the Chromium style for automatic reformatting. |
|||
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html |
|||
Language: Cpp |
|||
BasedOnStyle: Google |
|||
ColumnLimit: 160 |
|||
AlignConsecutiveMacros: true |
|||
AlignConsecutiveDeclarations: true |
|||
AlignConsecutiveAssignments: true |
|||
AlignOperands: true |
@ -0,0 +1,62 @@ |
|||
{ |
|||
"files.associations": { |
|||
"*.hpp": "cpp", |
|||
"fstream": "cpp", |
|||
"iostream": "cpp", |
|||
"string": "cpp", |
|||
"array": "cpp", |
|||
"atomic": "cpp", |
|||
"bit": "cpp", |
|||
"*.tcc": "cpp", |
|||
"cctype": "cpp", |
|||
"clocale": "cpp", |
|||
"cmath": "cpp", |
|||
"compare": "cpp", |
|||
"concepts": "cpp", |
|||
"cstdarg": "cpp", |
|||
"cstddef": "cpp", |
|||
"cstdint": "cpp", |
|||
"cstdio": "cpp", |
|||
"cstdlib": "cpp", |
|||
"cwchar": "cpp", |
|||
"cwctype": "cpp", |
|||
"deque": "cpp", |
|||
"list": "cpp", |
|||
"map": "cpp", |
|||
"set": "cpp", |
|||
"unordered_map": "cpp", |
|||
"vector": "cpp", |
|||
"exception": "cpp", |
|||
"algorithm": "cpp", |
|||
"functional": "cpp", |
|||
"iterator": "cpp", |
|||
"memory": "cpp", |
|||
"memory_resource": "cpp", |
|||
"numeric": "cpp", |
|||
"random": "cpp", |
|||
"string_view": "cpp", |
|||
"system_error": "cpp", |
|||
"tuple": "cpp", |
|||
"type_traits": "cpp", |
|||
"utility": "cpp", |
|||
"initializer_list": "cpp", |
|||
"iosfwd": "cpp", |
|||
"istream": "cpp", |
|||
"limits": "cpp", |
|||
"new": "cpp", |
|||
"numbers": "cpp", |
|||
"ostream": "cpp", |
|||
"sstream": "cpp", |
|||
"stdexcept": "cpp", |
|||
"streambuf": "cpp", |
|||
"typeinfo": "cpp", |
|||
"thread": "cpp", |
|||
"ctime": "cpp", |
|||
"ratio": "cpp", |
|||
"semaphore": "cpp", |
|||
"stop_token": "cpp", |
|||
"condition_variable": "cpp", |
|||
"mutex": "cpp" |
|||
}, |
|||
"files.encoding": "gbk" |
|||
} |
@ -0,0 +1 @@ |
|||
g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ .\sample_bin_parse.cpp -o sample_bin_parse.exe |
@ -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; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue