You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

1 year ago
  1. #include <fstream>
  2. #include <functional>
  3. #include <iostream>
  4. #include <list>
  5. #include <map>
  6. #include <memory>
  7. #include <set>
  8. #include <sstream>
  9. #include <string>
  10. #include <thread>
  11. #include <vector>
  12. //
  13. #include <winsock2.h>
  14. //
  15. #include <Windows.h>
  16. //
  17. #include <stdio.h>
  18. #pragma comment(lib, "ws2_32.lib")
  19. #define PORT 8988
  20. int main(int argc, char *argv[]) {
  21. // ���� 0.bin
  22. // ��ȡ 0.bin ��������
  23. // ÿ�ζ�9byte
  24. // 3byte 3byte 3byte
  25. // ���ŵ�0.csv��
  26. std::ifstream ifs("0.bin", std::ios::binary);
  27. if (!ifs) {
  28. std::cerr << "open 0.bin failed" << std::endl;
  29. return -1;
  30. }
  31. std::ofstream ofs("0.csv", std::ios::binary | std::ios::trunc);
  32. if (!ofs) {
  33. std::cerr << "open 0.csv failed" << std::endl;
  34. return -1;
  35. }
  36. char buf[9];
  37. while (ifs.read(buf, 9)) {
  38. unsigned int a = 0;
  39. unsigned int b = 0;
  40. unsigned int c = 0;
  41. a = (unsigned char)buf[0] | (unsigned char)buf[1] << 8 | (unsigned char)buf[2] << 16;
  42. b = (unsigned char)buf[3] | (unsigned char)buf[4] << 8 | (unsigned char)buf[5] << 16;
  43. c = (unsigned char)buf[6] | (unsigned char)buf[7] << 8 | (unsigned char)buf[8] << 16;
  44. ofs << a << "," << b << "," << c << std::endl;
  45. }
  46. return 0;
  47. }