fix bugs
This commit is contained in:
parent
9a6cfe2823
commit
5828cec9ec
@ -127,7 +127,7 @@
|
||||
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/jsoncpp/include"/>
|
||||
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/sqlite/include"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.dialect.std.411963263" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.dialect.std.411963263" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.c++1y" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.542083696" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1480789657" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
|
||||
@ -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="-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 "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-469859009740510951" 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 "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
||||
18
.vscode/c_cpp_properties.json
vendored
Normal file
18
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"/home/chaos/WorkSpace/Tools/GatewayThirdParty/jsoncpp/include"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "gnu++14",
|
||||
"intelliSenseMode": "linux-gcc-x64",
|
||||
"configurationProvider": "ms-vscode.makefile-tools"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
@ -951,7 +951,7 @@ int getSysIntValue(char *key) {
|
||||
fclose(fp);
|
||||
return value;
|
||||
}
|
||||
int GetSysStatusCMT(int& cpu_use,int& mem_use,int& disk_remain,int& cpu_temp)
|
||||
void GetSysStatusCMT(int& cpu_use,int& mem_use,int& disk_remain,int& cpu_temp)
|
||||
{
|
||||
long mem_used = -1;
|
||||
long mem_free = -1;
|
||||
@ -969,7 +969,6 @@ int GetSysStatusCMT(int& cpu_use,int& mem_use,int& disk_remain,int& cpu_temp)
|
||||
float fMemRate = 1.0 * mem_used / mem_total;
|
||||
|
||||
char name[8];
|
||||
double cpu_sys = -1;
|
||||
double cpu_user = -1;
|
||||
double cpu_total = -1;
|
||||
long int user, nice, sys, idle, iowait, irq, softirq;
|
||||
@ -981,15 +980,12 @@ int GetSysStatusCMT(int& cpu_use,int& mem_use,int& disk_remain,int& cpu_temp)
|
||||
sscanf(strCpu2.c_str(), "%s%ld%ld%ld%ld%ld%ld%ld", name, &userNext, &niceNext, &sysNext, &idleNext, &iowaitNext, &irqNext, &softirqNext);
|
||||
cpu_total = (userNext + niceNext + sysNext + idleNext + iowaitNext + irqNext + softirqNext) - (user + nice + sys + idle + iowait + irq + softirq);
|
||||
cpu_user = userNext - user;
|
||||
cpu_sys = sysNext - sys;
|
||||
float rateUser = cpu_user * 100.0 / cpu_total;
|
||||
float rateSys = cpu_sys * 100.0 / cpu_total;
|
||||
if (rateUser > 95) {
|
||||
rateUser = 92;
|
||||
}
|
||||
char hardTotal[32];
|
||||
char hardFree[32];
|
||||
char rateHardUse[32];
|
||||
char chRes[100];
|
||||
memset(chRes, 0, 100);
|
||||
getDiskInfo(hardTotal, hardFree);
|
||||
|
||||
@ -380,7 +380,7 @@ void ZoneConfig(std::string zoneid);
|
||||
* @return std::string CPU MEM DISK info
|
||||
*/
|
||||
std::string GetSysStatus(Json::Value &jsData);
|
||||
int GetSysStatusCMT(int& cpu_use,int& mem_use,int& disk_remain,int& cpu_temp);
|
||||
void GetSysStatusCMT(int& cpu_use,int& mem_use,int& disk_remain,int& cpu_temp);
|
||||
bool CheckIP(const char* ip);
|
||||
|
||||
bool IsValidMask(std::string mask);
|
||||
|
||||
@ -47,14 +47,13 @@ void JsonData::CmtCmd_81(char* recv_body,int& count,char* send_data,int& send_le
|
||||
int waveInterVal;
|
||||
int waveInterTime;
|
||||
int maxSensorNum;
|
||||
int sensorCount;
|
||||
array_t arrRes;
|
||||
char whereCon[512]={0};
|
||||
if (recv_body != NULL)
|
||||
{
|
||||
printf("count = %d\n",count);
|
||||
char short_addr_[256]={0};
|
||||
for (size_t i = 0; i < count; i++){
|
||||
for (int i = 0; i < count; i++){
|
||||
char temp[5]={0};
|
||||
memcpy(temp,recv_body + i * 4,4);
|
||||
printf("short_addr = %s\n",temp);
|
||||
@ -72,7 +71,7 @@ void JsonData::CmtCmd_81(char* recv_body,int& count,char* send_data,int& send_le
|
||||
}
|
||||
int iResult = arrRes.size();
|
||||
printf("result = %d\n",iResult);
|
||||
size_t j = 0;
|
||||
int j = 0;
|
||||
if (iResult > 0) {
|
||||
SensorInfo sensor_info[iResult];
|
||||
for (; j < iResult; j++)
|
||||
@ -178,7 +177,7 @@ void JsonData::CmtCmd_81(char* recv_body,int& count,char* send_data,int& send_le
|
||||
memcpy(sensor_info[j].upgrade_time,upgrade_time.c_str(),sizeof(sensor_info[j].upgrade_time));
|
||||
sensor_info[j].version = 1;
|
||||
}
|
||||
memcpy(send_data,&sensor_info,sizeof(SensorInfo) * j);
|
||||
memcpy(send_data ,(char*)&sensor_info[0],sizeof(SensorInfo) * j);
|
||||
send_length = sizeof(SensorInfo) * j;
|
||||
zlog_info(zct,"sizeof(SensorInfo) = %d",sizeof(SensorInfo)*j);
|
||||
zlog_info(zct,"send_length = %d",send_length);
|
||||
@ -190,7 +189,7 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s
|
||||
{
|
||||
FILE* pFile = NULL;
|
||||
char* buffer = NULL;
|
||||
int thisSize = 0;
|
||||
int thisSize = 32;
|
||||
WaveRes wave;
|
||||
char whereCon[64]={0};
|
||||
sprintf(whereCon,"MeasurementID = '%s'",MeasurementID);
|
||||
@ -217,7 +216,7 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s
|
||||
buffer = (char*)malloc(thisSize - 32);
|
||||
fread(buffer, sizeof(char), thisSize - 32, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
wave.sampling_rate = atoi(vecRes[0].c_str());
|
||||
wave.sampling_time = atoi(vecRes[1].c_str());
|
||||
wave.version = 1;
|
||||
@ -225,6 +224,7 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s
|
||||
memcpy(send_data,(char*)&wave,sizeof(WaveRes));
|
||||
memcpy(send_data + sizeof(WaveRes) ,buffer,thisSize - 32);
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void JsonData::CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_length)
|
||||
@ -235,7 +235,7 @@ void JsonData::CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_le
|
||||
if (recv_body){
|
||||
printf("count = %d\n",count);
|
||||
char MeasurementID_[256]={0};
|
||||
for (size_t i = 0; i < count; i++){
|
||||
for (int i = 0; i < count; i++){
|
||||
char temp[21]={0};
|
||||
memcpy(temp,recv_body + i * 20,20);
|
||||
printf("short_addr = %s\n",temp);
|
||||
@ -252,7 +252,6 @@ void JsonData::CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_le
|
||||
arrRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), "*", NULL);
|
||||
}
|
||||
if (arrRes.size() > 0){
|
||||
char localtimestamp[32] = {0};
|
||||
std::string current_time = GetLocalTimeWithMs();
|
||||
filename = "/opt/DataNode/config_" + GlobalConfig::MacAddr_G + "_" + std::string(current_time)+ ".csv";
|
||||
std::ofstream csvFile(filename);
|
||||
@ -264,7 +263,7 @@ void JsonData::CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_le
|
||||
csvFile << "GW MAC,Product,IP,PanID,Signal Channel,Terminal Name,SN,Sensor MAC,Measurement ID,"
|
||||
"Short Addr,Sensor Name,Update Date,Gateway RSSI,Sensor RSSI,HW Ver,Soft Ver,Sampling Rate,"
|
||||
"Range,Sampling Time,VIFF,Power,Retry Time\n";
|
||||
for (size_t i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DownloadConfig download_config;
|
||||
memcpy(download_config.gw_mac,GlobalConfig::MacAddr_G.c_str(),sizeof(download_config.gw_mac));
|
||||
@ -390,7 +389,7 @@ void JsonData::CmtCmd_84(char* filename,char* file_md5,char* send_data,int& sen
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
short_addr = strtol(vecDataNode[i].ZigbeeShortAddr.c_str(), &end_ptr, 16);
|
||||
int res = scheduler::instance().UpdateSensorConfig(short_addr);
|
||||
scheduler::instance().UpdateSensorConfig(short_addr);
|
||||
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
memset(updateSql, 0x00, sizeof(updateSql));
|
||||
@ -402,7 +401,7 @@ void JsonData::CmtCmd_84(char* filename,char* file_md5,char* send_data,int& sen
|
||||
|
||||
void JsonData::CmtCmd_85(char* filename,char* file_md5,char* send_data,int& send_length)
|
||||
{
|
||||
zlog_info(zct,"file_path = %s,file_md5 = %d",filename,file_md5);
|
||||
zlog_info(zct,"file_path = %s,file_md5 = %s",filename,file_md5);
|
||||
sleep(3);
|
||||
int iRet = system("/opt/opt.sh");
|
||||
zlog_info(zct, "iRet = %d", iRet);
|
||||
@ -413,7 +412,7 @@ void JsonData::CmtCmd_85(char* filename,char* file_md5,char* send_data,int& sen
|
||||
|
||||
void JsonData::CmtCmd_86(char* recv_body,int& count,char* filename,char* file_md5,char* send_data,int& send_length)
|
||||
{
|
||||
zlog_info(zct,"file_path = %s,file_md5 = %d",filename,file_md5);
|
||||
zlog_info(zct,"file_path = %s,file_md5 = %s",filename,file_md5);
|
||||
UpgradeSensorRes upgrade_sensor_res;
|
||||
upgrade_sensor_res.code = 0;
|
||||
sprintf(upgrade_sensor_res.message ,"%s","");
|
||||
@ -477,7 +476,7 @@ void JsonData::CmtCmd_86(char* recv_body,int& count,char* filename,char* file_m
|
||||
zlog_info(zct,"sum = %x\n",sum % 256);
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
for (size_t i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
char wherecon[100] = {0};
|
||||
char insertSql[200] = {0};
|
||||
@ -504,7 +503,7 @@ void JsonData::CmtCmd_86(char* recv_body,int& count,char* filename,char* file_m
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
||||
int res = scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
|
||||
scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
@ -75,6 +75,16 @@ public:
|
||||
std::string JsonCmd_Cgi_64(Param_64 ¶m);
|
||||
std::string JsonCmd_Cgi_default();
|
||||
|
||||
//CMT tcp
|
||||
void CmtCmd_80(char* send_data,int& return_length);
|
||||
void CmtCmd_81(char* recv_body,int& count,char* send_data,int& return_length);
|
||||
void CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& return_length);
|
||||
void CmtCmd_83(char* recv_body,int& count,char* send_data,int& return_length);
|
||||
void CmtCmd_84(char* filename,char* file_md5,char* send_data,int& send_length);
|
||||
void CmtCmd_85(char* filename,char* file_md5,char* send_data,int& send_length);
|
||||
void CmtCmd_86(char* recv_body,int& count,char* filename,char* file_md5,char* send_data,int& send_length);
|
||||
void CmtCmd_88(char* recv_body,int& count);
|
||||
|
||||
private:
|
||||
Json::FastWriter show_value_;
|
||||
};
|
||||
|
||||
@ -75,7 +75,7 @@ void CMTSession::do_read() {
|
||||
pkg_head.head[2] = 0xAA;
|
||||
pkg_head.cmd = cmd;
|
||||
pkg_head.len = send_data_len;
|
||||
memset(data_,0,sizeof(data_));
|
||||
memset(data_,0,sizeof(CMT_TCP_LEN));
|
||||
memcpy(data_, &pkg_head, head_len_);
|
||||
memcpy(data_ + head_len_, &send_data, send_data_len);
|
||||
do_write(head_len_ + send_data_len);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user