BWS2000倾角传感器c++测试代码

2023-12-20 13:36

本文主要是介绍BWS2000倾角传感器c++测试代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

使用瑞芬的倾角传感器配置的时候,数据手册一下就配置好了,但是BWS2000倾角传感器总是出错,这里进行一下记录出现的问题与解决方式。

1.初步测试

在配置BWS2000倾角传感器读取帧数据的时候,总是出现一个问题,就是进行输出的时候,得到的数据与实际设置的频率并不是不一致的。
其中,command_R1是对于输出频率的设置,command_R2是对于波特率的设置,command_R3保存设置命令。

问题一:注意当COM口大于10的时候,需要在前面添加\\\\.\\,否则会出现连接不上的情况,具体原因见博客:https://www.cnblogs.com/pandamohist/p/13681042.html

问题二:读出来的数据是16进制的,因此需要进行自己转换,转换过程代码如下所示(这个代码不是最优方式,比较麻烦,懒得再思考了):

if (sizeof(response_R) >= 13 && response_R[0] == 0x77 && response_R[1] == 0x10)//&& response[3] == 0x84)
{//x轴int hexValues[] = { response_R[5] & 0xFF, response_R[6] & 0xFF, response_R[7] & 0xFF };int numValues = sizeof(hexValues) / sizeof(hexValues[0]);std::stringstream ss;ss << std::setfill('0') << std::setw(2) << std::hex << hexValues[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues; i++) {ss << "." << std::setw(2) << std::hex << hexValues[i];}std::string resultString = ss.str();std::cout << "X轴 String representation: " << resultString << std::endl;std::string inputString = resultString;std::string outputString;size_t firstDotIndex = inputString.find('.');size_t secondDotIndex = inputString.find('.', firstDotIndex + 1);if (firstDotIndex != std::string::npos && secondDotIndex != std::string::npos) {outputString = inputString.substr(0, secondDotIndex) + inputString.substr(secondDotIndex + 1);}else {outputString = inputString;}double resultDouble = std::stod(outputString);if (response_R[4] == 0x00){Sensor_Angle_RX0 = resultDouble;}else{Sensor_Angle_RX0 = -resultDouble;}std::cout << "x轴角度" << std::fixed << std::setprecision(4) << resultDouble << std::endl;//Y轴int hexValues1[] = { response_R[9] & 0xFF, response_R[10] & 0xFF, response_R[11] & 0xFF };int numValues1 = sizeof(hexValues1) / sizeof(hexValues1[0]);// Convert hexadecimal values to a string "01.0102"std::stringstream ss1;ss1 << std::setfill('0') << std::setw(2) << std::hex << hexValues1[0];std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues1; i++) {ss1 << "." << std::setw(2) << std::hex << hexValues1[i];}std::string resultString1 = ss1.str();//std::cout << "Y轴 String representation: " << resultString1 << std::endl;std::string inputString1 = resultString1;std::string outputString1;size_t firstDotIndex1 = inputString1.find('.');size_t secondDotIndex1 = inputString1.find('.', firstDotIndex1 + 1);if (firstDotIndex1 != std::string::npos && secondDotIndex1 != std::string::npos) {outputString1 = inputString1.substr(0, secondDotIndex1) + inputString1.substr(secondDotIndex1 + 1);}else {outputString1 = inputString1;}double resultDouble1 = std::stod(outputString1);if (response_R[8] == 0x00){Sensor_Angle_RY0 = resultDouble1;}else{Sensor_Angle_RY0 = -resultDouble1;}std::cout << "y轴: " << std::fixed << std::setprecision(4) << resultDouble1 << std::endl;}

我写的测试代码如下所示:

#include <Windows.h>
#include <sstream> 
#include <iomanip>
#include <iostream>
#include <chrono>
#include <thread>
#include <Windows.h>int main() {HANDLE hSerial;DCB dcbSerialParams = { 0 };COMMTIMEOUTS timeouts = { 0 };DWORD bytesRead, bytesWritten, bytesWritten1, bytesWritten2, bytesWritten3, response_R1;char command_R[] = { 0x77, 0x04, 0x00, 0x04, 0x08 };//读X、Y轴角度 发送命令: 77 04 00 04 08char response_R[18] = { 18 };double Sensor_Angle_RX0;double Sensor_Angle_RY0;// 设置角度输出频率模式  77 05 00 0C 06(100Hz 05 50Hz 04 25Hz) 11 100Hz char command_R1[] = { 0x77, 0x05, 0x00, 0x0C, 0x04, 0x11 };//25Hz// 发送命令: 77 05 00 0B 04(115200 03 19200 02 9600) 12 115200  2 char command_R2[] = { 0x77, 0x05, 0x00, 0x0B, 0x02, 0x12 };// 保存设置命令: 77 04 00 0A 0E char command_R3[] = { 0x77, 0x04, 0x00, 0x0A, 0x0E };char dataReceived[100];wchar_t portName[] = L"\\\\.\\COM11"; // Note the 'L' before the stringhSerial = CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);if (hSerial == INVALID_HANDLE_VALUE) {if (GetLastError() == ERROR_FILE_NOT_FOUND) {std::cout << "Serial port not available." << std::endl;}return 1;}dcbSerialParams.DCBlength = sizeof(dcbSerialParams);if (!GetCommState(hSerial, &dcbSerialParams)) {std::cout << "Error getting serial port state." << std::endl;CloseHandle(hSerial);return 1;}dcbSerialParams.BaudRate = CBR_9600;dcbSerialParams.ByteSize = 8;dcbSerialParams.StopBits = ONESTOPBIT;dcbSerialParams.Parity = NOPARITY;if (!SetCommState(hSerial, &dcbSerialParams)) {std::cout << "Error setting serial port state." << std::endl;CloseHandle(hSerial);return 1;}timeouts.ReadIntervalTimeout = 50;timeouts.ReadTotalTimeoutConstant = 50;timeouts.ReadTotalTimeoutMultiplier = 10;timeouts.WriteTotalTimeoutConstant = 50;timeouts.WriteTotalTimeoutMultiplier = 10;if (!SetCommTimeouts(hSerial, &timeouts)) {std::cout << "Error setting timeouts." << std::endl;CloseHandle(hSerial);return 1;}if (!WriteFile(hSerial, command_R1, sizeof(command_R1), &bytesWritten1, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}//std::cout << "Data sent successfully." << std::endl;/*if (!ReadFile(hSerial, dataReceived, sizeof(dataReceived), &bytesRead, NULL)) {std::cout << "Error reading from serial port." << std::endl;CloseHandle(hSerial);return 1;}if (!WriteFile(hSerial, command_R2, sizeof(command_R2), &bytesWritten2, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}if (!ReadFile(hSerial, dataReceived, sizeof(dataReceived), &bytesRead, NULL)) {std::cout << "Error reading from serial port." << std::endl;CloseHandle(hSerial);return 1;}if (!WriteFile(hSerial, command_R3, sizeof(command_R3), &bytesWritten3, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}int i = 0;while (1){for (int i = 0; i < sizeof(response_R); i++) {printf("%02X ", response_R[i]);}std::cout << std::endl;std::cout << i++ << response_R<< std::endl;/*//右倾角传感器if (sizeof(response_R) >= 13 && response_R[0] == 0x77 && response_R[1] == 0x10)//&& response[3] == 0x84){*///x轴// Given hexadecimal valuesint hexValues[] = { response_R[5] & 0xFF, response_R[6] & 0xFF, response_R[7] & 0xFF };int numValues = sizeof(hexValues) / sizeof(hexValues[0]);// Convert hexadecimal values to a string "01.0102"std::stringstream ss;ss << std::setfill('0') << std::setw(2) << std::hex << hexValues[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues; i++) {ss << "." << std::setw(2) << std::hex << hexValues[i];}std::string resultString = ss.str();//std::cout << "X轴 String representation: " << resultString << std::endl;std::string inputString = resultString;std::string outputString;size_t firstDotIndex = inputString.find('.');size_t secondDotIndex = inputString.find('.', firstDotIndex + 1);if (firstDotIndex != std::string::npos && secondDotIndex != std::string::npos) {outputString = inputString.substr(0, secondDotIndex) + inputString.substr(secondDotIndex + 1);}else {outputString = inputString;}// Convert the string "01.0102" to double 01.0102double resultDouble = std::stod(outputString);if (response_R[4] == 0x00){Sensor_Angle_RX0 = resultDouble;}else{Sensor_Angle_RX0 = -resultDouble;}std::cout << "x轴角度" << std::fixed << std::setprecision(4) << resultDouble << std::endl;//Y轴int hexValues1[] = { response_R[9] & 0xFF, response_R[10] & 0xFF, response_R[11] & 0xFF };int numValues1 = sizeof(hexValues1) / sizeof(hexValues1[0]);std::stringstream ss1;ss1 << std::setfill('0') << std::setw(2) << std::hex << hexValues1[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues1; i++) {ss1 << "." << std::setw(2) << std::hex << hexValues1[i];}std::string resultString1 = ss1.str();std::string inputString1 = resultString1;std::string outputString1;size_t firstDotIndex1 = inputString1.find('.');size_t secondDotIndex1 = inputString1.find('.', firstDotIndex1 + 1);if (firstDotIndex1 != std::string::npos && secondDotIndex1 != std::string::npos) {outputString1 = inputString1.substr(0, secondDotIndex1) + inputString1.substr(secondDotIndex1 + 1);}else {outputString1 = inputString1;}double resultDouble1 = std::stod(outputString1);if (response_R[8] == 0x00){Sensor_Angle_RY0 = resultDouble1;}else{Sensor_Angle_RY0 = -resultDouble1;}std::cout << "y轴: " << std::fixed << std::setprecision(4) << resultDouble1 << std::endl;}getchar();CloseHandle(hSerial);return 0;
}

在上面的代码之中,我是使用的自动输出的方式,配置的25Hz进行输出,但是出现的问题就是当把下面的代码进行打开之后:

if (sizeof(response_R) >= 13 && response_R[0] == 0x77 && response_R[1] == 0x10)//&& response[3] == 0x84){//x轴int hexValues[] = { response_R[5] & 0xFF, response_R[6] & 0xFF, response_R[7] & 0xFF };int numValues = sizeof(hexValues) / sizeof(hexValues[0]);// Convert hexadecimal values to a string "01.0102"std::stringstream ss;ss << std::setfill('0') << std::setw(2) << std::hex << hexValues[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues; i++) {ss << "." << std::setw(2) << std::hex << hexValues[i];}std::string resultString = ss.str();//std::cout << "X轴 String representation: " << resultString << std::endl;std::string inputString = resultString;std::string outputString;size_t firstDotIndex = inputString.find('.');size_t secondDotIndex = inputString.find('.', firstDotIndex + 1);if (firstDotIndex != std::string::npos && secondDotIndex != std::string::npos) {outputString = inputString.substr(0, secondDotIndex) + inputString.substr(secondDotIndex + 1);}else {outputString = inputString;}double resultDouble = std::stod(outputString);if (response_R[4] == 0x00){Sensor_Angle_RX0 = resultDouble;}else{Sensor_Angle_RX0 = -resultDouble;}std::cout << "x轴角度" << std::fixed << std::setprecision(4) << resultDouble << std::endl;//Y轴int hexValues1[] = { response_R[9] & 0xFF, response_R[10] & 0xFF, response_R[11] & 0xFF };int numValues1 = sizeof(hexValues1) / sizeof(hexValues1[0]);std::stringstream ss1;ss1 << std::setfill('0') << std::setw(2) << std::hex << hexValues1[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues1; i++) {ss1 << "." << std::setw(2) << std::hex << hexValues1[i];}std::string resultString1 = ss1.str();std::string inputString1 = resultString1;std::string outputString1;size_t firstDotIndex1 = inputString1.find('.');size_t secondDotIndex1 = inputString1.find('.', firstDotIndex1 + 1);if (firstDotIndex1 != std::string::npos && secondDotIndex1 != std::string::npos) {outputString1 = inputString1.substr(0, secondDotIndex1) + inputString1.substr(secondDotIndex1 + 1);}else {outputString1 = inputString1;}// Convert the string "01.0102" to double 01.0102double resultDouble1 = std::stod(outputString1);if (response_R[8] == 0x00){Sensor_Angle_RY0 = resultDouble1;}else{Sensor_Angle_RY0 = -resultDouble1;}std::cout << "y轴: " << std::fixed << std::setprecision(4) << resultDouble1 << std::endl;
}

发现明显输出的频率是和25Hz是不一致的。

然后直接将相应的报文进行打印,调用

for (int i = 0; i < sizeof(response_R); i++) {printf("%02X ", response_R[i]);}

输出如下结果:

真正想用的的数据是0x77 0x10 0x00数据之后的,也就是尽量是要求每一帧的数据都是这个情况,由于设置了自动输出的频率为25Hz,所以你读取相应的response是不知道在哪一个时刻开始的,需要进行相应的频率进行设置。

2.应答测试

在每个帧信号之后,输出一个应答信号,检测是否输出正确?

#include <Windows.h>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <chrono>
#include <thread>
#include <Windows.h>
#include <iostream>#include <iomanip>
double convertStringToDouble(const std::string& str) {double result;std::istringstream stream(str);stream >> result;return result;
}
int main() {HANDLE hSerial;DCB dcbSerialParams = { 0 };COMMTIMEOUTS timeouts = { 0 };DWORD bytesRead, bytesWritten, bytesWritten1, bytesWritten2, bytesWritten3, response_R1;char command_R[] = { 0x77, 0x04, 0x00, 0x04, 0x08 };//读X、Y轴角度 发送命令: 77 04 00 04 08char response_R[18] = { 18 };double Sensor_Angle_RX0;double Sensor_Angle_RY0;// 设置角度输出频率模式  77 05 00 0C 06(100Hz 05 50Hz 04 25Hz) 11 100Hz char command_R1[] = { 0x77, 0x05, 0x00, 0x0C, 0x00, 0x11 };//25Hz// 发送命令: 77 05 00 0B 04(115200 03 19200 02 9600) 12 115200  2 char command_R2[] = { 0x77, 0x05, 0x00, 0x0B, 0x02, 0x12 };// 保存设置命令: 77 04 00 0A 0E char command_R3[] = { 0x77, 0x04, 0x00, 0x0A, 0x0E };char dataReceived[20];wchar_t portName[] = L"\\\\.\\COM10"; // Note the 'L' before the stringhSerial = CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);if (hSerial == INVALID_HANDLE_VALUE) {if (GetLastError() == ERROR_FILE_NOT_FOUND) {std::cout << "Serial port not available." << std::endl;}return 1;}dcbSerialParams.DCBlength = sizeof(dcbSerialParams);if (!GetCommState(hSerial, &dcbSerialParams)) {std::cout << "Error getting serial port state." << std::endl;CloseHandle(hSerial);return 1;}dcbSerialParams.BaudRate = CBR_9600;dcbSerialParams.ByteSize = 8;dcbSerialParams.StopBits = ONESTOPBIT;dcbSerialParams.Parity = NOPARITY;if (!SetCommState(hSerial, &dcbSerialParams)) {std::cout << "Error setting serial port state." << std::endl;CloseHandle(hSerial);return 1;}timeouts.ReadIntervalTimeout = 500;timeouts.ReadTotalTimeoutConstant = 500;timeouts.ReadTotalTimeoutMultiplier = 100;timeouts.WriteTotalTimeoutConstant = 500;timeouts.WriteTotalTimeoutMultiplier = 100;if (!SetCommTimeouts(hSerial, &timeouts)) {std::cout << "Error setting timeouts." << std::endl;CloseHandle(hSerial);return 1;}if (!WriteFile(hSerial, command_R1, sizeof(command_R1), &bytesWritten1, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}std::cout << "输出频率 " << std::endl;if (!ReadFile(hSerial, dataReceived, sizeof(dataReceived), &bytesRead, NULL)) {std::cout << "Error reading from serial port." << std::endl;CloseHandle(hSerial);return 1;}for (int i = 0; i < sizeof(dataReceived); i++) {printf("%02X ", dataReceived[i]);}if (!WriteFile(hSerial, command_R2, sizeof(command_R2), &bytesWritten2, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}std::cout << " 发送命令" << std::endl;if (!ReadFile(hSerial, dataReceived, sizeof(dataReceived), &bytesRead, NULL)) {std::cout << "Error reading from serial port." << std::endl;CloseHandle(hSerial);return 1;}for (int i = 0; i < sizeof(dataReceived); i++) {printf("%02X ", dataReceived[i]);}if (!WriteFile(hSerial, command_R3, sizeof(command_R3), &bytesWritten3, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}if (!ReadFile(hSerial, dataReceived, sizeof(dataReceived), &bytesRead, NULL)) {std::cout << "Error reading from serial port." << std::endl;CloseHandle(hSerial);return 1;}std::cout << "保存设置 " << std::endl;for (int i = 0; i < sizeof(dataReceived); i++) {printf("%02X ", dataReceived[i]);}std::cout << " " << std::endl;std::cout << "开始采集 " << std::endl;int i = 0;while (1){if (!WriteFile(hSerial, command_R, sizeof(command_R), &bytesWritten, NULL)) {std::cout << "Error writing to serial port." << std::endl;CloseHandle(hSerial);return 1;}if (!ReadFile(hSerial, response_R, sizeof(response_R), &response_R1, NULL)) {std::cout << "Error reading from serial port." << std::endl;//CloseHandle(hSerial);//return 1;}std::cout << i++ << std::endl;for (int i = 0; i < sizeof(response_R); i++) {printf("%02X ", response_R[i]);}std::cout << std::endl;/*//右倾角传感器if (sizeof(response_R) >= 13 && response_R[0] == 0x77 && response_R[1] == 0x10)//&& response[3] == 0x84){*///x轴int hexValues[] = { response_R[5] & 0xFF, response_R[6] & 0xFF, response_R[7] & 0xFF };int numValues = sizeof(hexValues) / sizeof(hexValues[0]);std::stringstream ss;ss << std::setfill('0') << std::setw(2) << std::hex << hexValues[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues; i++) {ss << "." << std::setw(2) << std::hex << hexValues[i];}std::string resultString = ss.str();std::string inputString = resultString;std::string outputString;size_t firstDotIndex = inputString.find('.');size_t secondDotIndex = inputString.find('.', firstDotIndex + 1);if (firstDotIndex != std::string::npos && secondDotIndex != std::string::npos) {outputString = inputString.substr(0, secondDotIndex) + inputString.substr(secondDotIndex + 1);}else {outputString = inputString;}double resultDouble = std::stod(outputString);if (response_R[4] == 0x00){Sensor_Angle_RX0 = resultDouble;}else{Sensor_Angle_RX0 = -resultDouble;}std::cout << "x轴角度" << std::fixed << std::setprecision(4) << resultDouble << std::endl;//Y轴int hexValues1[] = { response_R[9] & 0xFF, response_R[10] & 0xFF, response_R[11] & 0xFF };int numValues1 = sizeof(hexValues1) / sizeof(hexValues1[0]);std::stringstream ss1;ss1 << std::setfill('0') << std::setw(2) << std::hex << hexValues1[0];//std::cout << "String representation: " << numValues << std::endl;for (int i = 1; i < numValues1; i++) {ss1 << "." << std::setw(2) << std::hex << hexValues1[i];}std::string resultString1 = ss1.str();std::string inputString1 = resultString1;std::string outputString1;size_t firstDotIndex1 = inputString1.find('.');size_t secondDotIndex1 = inputString1.find('.', firstDotIndex1 + 1);if (firstDotIndex1 != std::string::npos && secondDotIndex1 != std::string::npos) {outputString1 = inputString1.substr(0, secondDotIndex1) + inputString1.substr(secondDotIndex1 + 1);}else {outputString1 = inputString1;}double resultDouble1 = std::stod(outputString1);if (response_R[8] == 0x00){Sensor_Angle_RY0 = resultDouble1;}else{Sensor_Angle_RY0 = -resultDouble1;}std::cout << "y轴: " << std::fixed << std::setprecision(4) << resultDouble1 << std::endl;std::this_thread::sleep_for(std::chrono::milliseconds(400));}getchar();CloseHandle(hSerial);return 0;
}

当设置波特率为9600,应答模式的情况下,可以见到输出完完全全正确:

但是我需要高频率的输出,见到技术手册里面存在这样一句话,

给定的软件是可以正常运行的。

3.解决高频率输出

当我把频率直接设置成115200的时候,发现还是存在错误,应答信号直接出错了。

我想了很久,然后技术手册之中有一句话是这样说的,

每次变更通信波特率成功之后,会以原来的波特率发送应答信号,然后立即改变通信波特率。

也就是说初始的时候,波特率还是应该设置为9600,发送command_R2完毕之后,才会发生改变。因此,下面这个代码值是不能够发生变化的

只需要将command_R2的值进行变化就是可以的。

运行1348次数据仍然是正确的。

4.界面化设计

此处使用的应答模式

因为代码之中使用自动输出模式,会出现检测代码的问题,前面已经提到过。

后面的思路是在界面之中设定一个定时器,以50Hz的方式进行写读,不会出现读出来的帧数据出错的问题,规避了自动输出的局限性。之后使用线程对于这个定时器进行实时调用就可以了。

这篇关于BWS2000倾角传感器c++测试代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/516233

相关文章

C++使用栈实现括号匹配的代码详解

《C++使用栈实现括号匹配的代码详解》在编程中,括号匹配是一个常见问题,尤其是在处理数学表达式、编译器解析等任务时,栈是一种非常适合处理此类问题的数据结构,能够精确地管理括号的匹配问题,本文将通过C+... 目录引言问题描述代码讲解代码解析栈的状态表示测试总结引言在编程中,括号匹配是一个常见问题,尤其是在

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

C++初始化数组的几种常见方法(简单易懂)

《C++初始化数组的几种常见方法(简单易懂)》本文介绍了C++中数组的初始化方法,包括一维数组和二维数组的初始化,以及用new动态初始化数组,在C++11及以上版本中,还提供了使用std::array... 目录1、初始化一维数组1.1、使用列表初始化(推荐方式)1.2、初始化部分列表1.3、使用std::

C++ Primer 多维数组的使用

《C++Primer多维数组的使用》本文主要介绍了多维数组在C++语言中的定义、初始化、下标引用以及使用范围for语句处理多维数组的方法,具有一定的参考价值,感兴趣的可以了解一下... 目录多维数组多维数组的初始化多维数组的下标引用使用范围for语句处理多维数组指针和多维数组多维数组严格来说,C++语言没

c++中std::placeholders的使用方法

《c++中std::placeholders的使用方法》std::placeholders是C++标准库中的一个工具,用于在函数对象绑定时创建占位符,本文就来详细的介绍一下,具有一定的参考价值,感兴... 目录1. 基本概念2. 使用场景3. 示例示例 1:部分参数绑定示例 2:参数重排序4. 注意事项5.

使用C++将处理后的信号保存为PNG和TIFF格式

《使用C++将处理后的信号保存为PNG和TIFF格式》在信号处理领域,我们常常需要将处理结果以图像的形式保存下来,方便后续分析和展示,C++提供了多种库来处理图像数据,本文将介绍如何使用stb_ima... 目录1. PNG格式保存使用stb_imagephp_write库1.1 安装和包含库1.2 代码解

C++实现封装的顺序表的操作与实践

《C++实现封装的顺序表的操作与实践》在程序设计中,顺序表是一种常见的线性数据结构,通常用于存储具有固定顺序的元素,与链表不同,顺序表中的元素是连续存储的,因此访问速度较快,但插入和删除操作的效率可能... 目录一、顺序表的基本概念二、顺序表类的设计1. 顺序表类的成员变量2. 构造函数和析构函数三、顺序表

使用C++实现单链表的操作与实践

《使用C++实现单链表的操作与实践》在程序设计中,链表是一种常见的数据结构,特别是在动态数据管理、频繁插入和删除元素的场景中,链表相比于数组,具有更高的灵活性和高效性,尤其是在需要频繁修改数据结构的应... 目录一、单链表的基本概念二、单链表类的设计1. 节点的定义2. 链表的类定义三、单链表的操作实现四、

使用C/C++调用libcurl调试消息的方式

《使用C/C++调用libcurl调试消息的方式》在使用C/C++调用libcurl进行HTTP请求时,有时我们需要查看请求的/应答消息的内容(包括请求头和请求体)以方便调试,libcurl提供了多种... 目录1. libcurl 调试工具简介2. 输出请求消息使用 CURLOPT_VERBOSE使用 C

C++实现获取本机MAC地址与IP地址

《C++实现获取本机MAC地址与IP地址》这篇文章主要为大家详细介绍了C++实现获取本机MAC地址与IP地址的两种方式,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 实际工作中,项目上常常需要获取本机的IP地址和MAC地址,在此使用两种方案获取1.MFC中获取IP和MAC地址获取