fix receive wave bugs

This commit is contained in:
zhangsheng 2024-11-06 21:16:18 +08:00
parent 890f27dbd1
commit c674fe79b8
8 changed files with 86 additions and 72 deletions

View File

@ -32,6 +32,8 @@
<option id="gnu.cpp.compiler.option.debugging.level.287276407" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.801625659" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/boost/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/zlog/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/NewWLG/WLG"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/curl/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/fftw/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/jsoncpp/include"/>
@ -95,7 +97,7 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.config.gnu.cross.exe.release.770635657" name="Release" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="" postbuildStep="cp WLG Cidn-SH;arm-linux-gnueabihf-strip Cidn-SH" preannouncebuildStep="" prebuildStep="">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.config.gnu.cross.exe.release.770635657" name="Release" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="" postbuildStep="cp WirelessGateway Cidn-SH;arm-linux-gnueabihf-strip Cidn-SH" preannouncebuildStep="" prebuildStep="">
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.release.770635657." name="/" resourcePath="">
<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.exe.release.1737804687" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.release">
<option id="cdt.managedbuild.option.gnu.cross.prefix.1625525504" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" useByScannerDiscovery="false" value="arm-linux-gnueabihf-" valueType="string"/>
@ -113,6 +115,8 @@
<option id="gnu.cpp.compiler.option.debugging.level.2146025035" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1740362159" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/boost/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/NewWLG/WLG"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/zlog/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/WLG"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/curl/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/zlog/include"/>

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-600614757740630993" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="446663210403312388" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1102353172776392420" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-469859550318386951" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

50
.vscode/settings.json vendored
View File

@ -8,72 +8,68 @@
"**/Release": true
},
"files.associations": {
"string": "cpp",
"*.tcc": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"any": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"numeric": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"utility": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory_resource": "cpp",
"random": "cpp",
"set": "cpp",
"*.ipp": "cpp",
"unordered_set": "cpp"
"typeinfo": "cpp"
},
"C_Cpp.errorSquiggles": "disabled"
}

View File

@ -301,18 +301,20 @@ struct Param_57 {
};
struct Param_58 {
int mMode;
int featureInterVal;
int featureInterTime;
int waveInterVal;
int waveInterTime;
int maxSensorNum;
Param_58() : featureInterVal(0),featureInterTime(0),waveInterVal(0),waveInterTime(0),maxSensorNum(0){};
Param_58() : mMode(0),featureInterVal(0),featureInterTime(0),waveInterVal(0),waveInterTime(0),maxSensorNum(0){};
};
struct Param_59 {
int mMode;
std::string DataNodeNo;
Param_59() : mMode(0),DataNodeNo(""){};
std::string straxis;
Param_59() : mMode(0),DataNodeNo(""),straxis(""){};
};
#endif // PARAMETER_DEFINATION_HPP_

View File

@ -109,11 +109,18 @@ SensorScheduler::SensorScheduler() {
seconds_per_wave_slice_ = rest_duration / wave_slice_num_per_eigen_interval_;
} else {
zlog_info(zbt, "use default configuration");
int eigen_value_send_interval = 300;
int wave_form_send_interval = 7200;
// int eigen_value_send_interval = 300;
// int wave_form_send_interval = 7200;
// int eigen_value_send_duration = 6;
// int wave_form_send_duration = 50;
// int max_sensor_num = 32;
int eigen_value_send_interval = 120;
int wave_form_send_interval = 240;
int eigen_value_send_duration = 6;
int wave_form_send_duration = 50;
int max_sensor_num = 32;
int wave_form_send_duration = 40;
int max_sensor_num = 4;
Config(eigen_value_send_interval,
wave_form_send_interval,
eigen_value_send_duration,

View File

@ -50,10 +50,8 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) {
zlog_info(zct, "===============0x9999 timeout= %d offSize = %d===============", timeoutflag, offSize);
zlog_info(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize);
FindRecvPackage(offSize, mUartRecvTmpBuf, head);
GlobalConfig::Zigbee_G.MyAddr = 0x8888;
now_task = -1;
wave_shortAddr = 0;
timeoutflag = 0;
offSize = 0;
maxSize = 0;
@ -373,6 +371,7 @@ int Uart::DealAskTask(uint16_t ushortAdd){
ModifyDistAddr(ushortAdd);
int next_duration = 0;
int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration);
taskID = 4;
ScheduleTask scheduleTask;
zlog_info(zct, "taskID = %d ", taskID);
if (taskID == kScheduleEigenValue) //1.特征值
@ -429,10 +428,12 @@ int Uart::DealReviveDuration(uint16_t ushortAdd){
ScheduleTask scheduleTask;
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd);
next_duration = 60;
zlog_info(zct, "next_duration = %d ", next_duration);
scheduleTask.cmd = REVIVE_DURATION;
scheduleTask.shortAddr = ushortAdd;
scheduleTask.duration = next_duration;
zlog_info(zct, "next_duration = %d ", next_duration);
TaskResp(scheduleTask);
return 0;
}
@ -448,17 +449,18 @@ int Uart::DealConfig(uint16_t ushortAdd){
}
int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
zlog_info(zct, "DealWaveCompress ");
char buf[20] = {0x00};
sprintf(buf, "%02x%02x", (ushortAdd >> 8) & 0xFF, ushortAdd & 0xFF);
std::string strShortAddr = std::string(buf);
compressWaveChannel tempchannel;
tempchannel.compressChannelX = pData[8];
tempchannel.compressChannelY = pData[9];
tempchannel.compressChannelZ = pData[10];
tempchannel.compressChannelX = pData[7];
tempchannel.compressChannelY = pData[8];
tempchannel.compressChannelZ = pData[9];
tempchannel.CountX = BUILD_UINT32(pData[14], pData[13],pData[12],pData[11]);
tempchannel.CountY = BUILD_UINT32(pData[18], pData[17],pData[16],pData[15]);
tempchannel.CountZ = BUILD_UINT32(pData[22], pData[21],pData[20],pData[19]);
tempchannel.CountX = BUILD_UINT32(pData[13], pData[12],pData[11],pData[10]);
tempchannel.CountY = BUILD_UINT32(pData[17], pData[16],pData[15],pData[14]);
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
g_mapCompress[strShortAddr] = tempchannel;
@ -952,7 +954,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
char buf[8] = {0x00};
sprintf(buf, "%02d", UartRecvBuf[i + 5]);
int command = atoi(buf);
zlog_info(zct, "command = %d ShortAddr :%s", command, strShortAddr.c_str());
//zlog_info(zct, "command = %d ShortAddr :%s", command, strShortAddr.c_str());
if ((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i + 6] == 0) && (!bUpdatePre && !bUpdateconfig)) {
mPackgeIndex = UartRecvBuf[i + 6] & 0xFF;
} else if ((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && (!bUpdatePre && !bUpdateconfig) && command != 2) {
@ -1014,7 +1016,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
g_VecWaveDataX.clear();
g_VecWaveDataY.clear();
g_VecWaveDataZ.clear();
break;
}
mlastSize = 0;
@ -1037,14 +1038,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
break;
}
}
if (command == WAVE_COMPRESS )
{
memcpy(RecvBuf, &UartRecvBuf[i], 23);
if (!CheckCrc(RecvBuf, 22)) {
zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
break;
}
}
if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)
{
memcpy(RecvBuf, &UartRecvBuf[i], 9);
@ -1053,7 +1046,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
break;
}
}
if (command == DEVICE_INF || command == MEAS_EVAL || command == DEVICE_INF2)
{
memcpy(RecvBuf, &UartRecvBuf[i], 100);
@ -1062,10 +1054,22 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
break;
}
}
DealRecvData(RecvBuf);
}else if(now_task == WAVE_CMD && command == WAVE_COMPRESS){
memcpy(RecvBuf, &UartRecvBuf[i], 23);
if (!CheckCrc(RecvBuf, 22)) {
zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
break;
}
char tmp[23] = {0x00};
char tmp2[23] = {0x00};
for (int j = 0; j < 23; j++) {
sprintf(tmp, "%02x ", UartRecvBuf[i + j] & 0xff);
strcat(tmp2, tmp);
}
zlog_info(zct, "str = %s", tmp2);
DealRecvData(RecvBuf);
} else if (command == 35) {
char signalNode[10] = {0x00};
sprintf(signalNode, "%02d", UartRecvBuf[i + 14] & 0xFF);

View File

@ -772,21 +772,21 @@ float Uart::ScaleConvert(int highbit) { return 0.0001f * pow(100.0f, highbit); }
void Uart::DealDataNodeWave(const char *pData, int comand) {
RecvData *pRecvData = (RecvData *)pData;
if (wave_trans_) {
if (comand == 3) {
if (comand == WAVE_X) {
VecWaveDataX.push_back(*pRecvData);
} else if (comand == 4) {
} else if (comand == WAVE_Y) {
VecWaveDataY.push_back(*pRecvData);
} else if (comand == 5) {
} else if (comand == WAVE_Z) {
VecWaveDataZ.push_back(*pRecvData);
}
} else {
if (comand == 3) {
if (comand == WAVE_X) {
g_VecWaveDataX[m_waveCountX] = *pRecvData;
m_waveCountX++;
} else if (comand == 4) {
} else if (comand == WAVE_Y) {
g_VecWaveDataY[m_waveCountY] = *pRecvData;
m_waveCountY++;
} else if (comand == 5) {
} else if (comand == WAVE_Z) {
g_VecWaveDataZ[m_waveCountZ] = *pRecvData;
m_waveCountZ++;
}
@ -934,12 +934,18 @@ void Uart::DealWave() {
std::vector<float> vecData;
if (wave_trans_) { //对每个传感器的每个通道进行遍历然后处理数据例如传感器1x轴的数据处理完后再去处理y轴的。传感器1的所有数据处理完后再处理传感器2的
char getLongAddr_sql[32] = {0};
sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", m_strDestShortAddr.c_str());
sprintf(getLongAddr_sql, "zigbeeShortAddr='%02x%02x'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF);
vec_t res = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " * ", getLongAddr_sql);
if (res.size() < 0)
{
wave_trans_ = false;
return;
}
strLongAddr = res[0];
strMeasurementID = res[44];
if (0 == strLongAddr.length()) {
sleep(1);
wave_trans_ = false;
return;
}
std::string ran = "";
@ -984,11 +990,6 @@ void Uart::DealWave() {
g_VecWaveDataZ.clear();
VecWaveDataZ.clear();
}
char whereCon[1024] = {0x00};
char updateSql[1024] = {0x00};
sprintf(whereCon, "dataNodeNo='%s'", strLongAddr.c_str());
sprintf(updateSql, "WaveTime = WaveTime + 1");
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
wave_trans_ = false;
}
}

View File

@ -528,8 +528,8 @@ int Uart::TaskResp(ScheduleTask scheduleTask){
UpdateData[6] = 0x00;
if (scheduleTask.cmd == REVIVE_DURATION)
{
UpdateData[7] = (scheduleTask.duration >> 8) & 0xFF;
UpdateData[8] = scheduleTask.duration & 0xFF;
UpdateData[7] = UINT16_LOW(scheduleTask.duration);
UpdateData[8] = UINT16_HIGH(scheduleTask.duration);
}
if (scheduleTask.cmd == MEAS_EVAL)
{