mirror of
https://github.com/eddyem/BTA_utils.git
synced 2025-12-06 02:35:13 +03:00
push old changes
This commit is contained in:
parent
0d40ee1f15
commit
eb93181fd6
@ -82,13 +82,13 @@ static int crc_check(uint8_t *buffer, int length){
|
||||
uint8_t byte;
|
||||
uint16_t crc = 0xFFFF;
|
||||
int valid_crc;
|
||||
/*
|
||||
|
||||
#ifdef EBUG
|
||||
printf("buffer: ");
|
||||
for(int i = 0; i < length; ++i) printf("%02x ", buffer[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
*/
|
||||
|
||||
while (length-- > 2) {
|
||||
byte = *buffer++ ^ crc;
|
||||
crc >>= 8;
|
||||
@ -181,80 +181,96 @@ params_ans check_meteo_params(){
|
||||
}
|
||||
DBG("Ctr=%d, size=%d, res=%d", ctr, size, res);
|
||||
// read all or end of packet
|
||||
if(size > 0 && res == 0 && (size == REQ_LEN || size == ANS_LEN)){
|
||||
if(crc_check(buffer, size)){
|
||||
if(size == REQ_LEN){
|
||||
DBG("request");
|
||||
ctr = 30;
|
||||
lastpar = buffer[2] << 8 | buffer[3];
|
||||
}else if(size == ANS_LEN){
|
||||
ctr = 30;
|
||||
DBG("answer");
|
||||
int16_t val = buffer[3] << 8 | buffer[4];
|
||||
int prval = 1;
|
||||
float f = (float)val / 10.f;
|
||||
switch(lastpar){
|
||||
case REG_WSPEED:
|
||||
DBG("wind speed");
|
||||
meteoflags |= WSFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_WND)){ // not entered by hands
|
||||
if(f >= 0.f && f < 200.f){
|
||||
val_Wnd = f;
|
||||
MeteoMode &= ~NET_WND;
|
||||
MeteoMode |= SENSOR_WND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REG_WDIR:
|
||||
DBG("wind direction");
|
||||
//meteoflags |= WDFLAG;
|
||||
break;
|
||||
case REG_TAIR:
|
||||
DBG("air temperature");
|
||||
meteoflags |= TFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_T1)){
|
||||
if(f > -40.f && f < 40.f){
|
||||
val_T1 = f;
|
||||
MeteoMode &= ~NET_T1;
|
||||
MeteoMode |= SENSOR_T1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REG_HUM:
|
||||
DBG("humidity");
|
||||
meteoflags |= HFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_HMD)){
|
||||
if(f >= 0.f && f <= 100.f){
|
||||
val_Hmd = f;
|
||||
MeteoMode &= ~NET_HMD;
|
||||
MeteoMode |= SENSOR_HMD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REG_DEW:
|
||||
DBG("dewpoint");
|
||||
break;
|
||||
case REG_PRES:
|
||||
DBG("pressure");
|
||||
f *= 760.f/1013.f; // convert hPa->mmHg
|
||||
meteoflags |= PFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_B)){
|
||||
if(f > 500.f && f < 700.f){
|
||||
val_B = f;
|
||||
MeteoMode &= ~NET_B;
|
||||
MeteoMode |= SENSOR_B;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
prval = 0;
|
||||
}
|
||||
if(size > 0 && res == 0 && (size == REQ_LEN || size == ANS_LEN || size == REQ_LEN + ANS_LEN)){
|
||||
int16_t val = 0;
|
||||
if(size == REQ_LEN){ // request from master
|
||||
if(!crc_check(buffer, size)){
|
||||
lastpar = 0;
|
||||
if(prval){
|
||||
DBG("=%.1f\n", f);
|
||||
return ANS_OK;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
DBG("request");
|
||||
lastpar = buffer[2] << 8 | buffer[3];
|
||||
continue;
|
||||
}
|
||||
if(size == ANS_LEN){
|
||||
if(!crc_check(buffer, size)){
|
||||
lastpar = 0;
|
||||
continue;
|
||||
}
|
||||
DBG("answer");
|
||||
val = buffer[3] << 8 | buffer[4];
|
||||
}else if(size == REQ_LEN + ANS_LEN){
|
||||
if(!crc_check(buffer, REQ_LEN) || !crc_check(buffer+REQ_LEN, ANS_LEN)){
|
||||
lastpar = 0;
|
||||
continue;
|
||||
}
|
||||
DBG("both request and answer");
|
||||
lastpar = buffer[2] << 8 | buffer[3];
|
||||
val = buffer[3 + REQ_LEN] << 8 | buffer[4 + REQ_LEN];
|
||||
}
|
||||
ctr = 30;
|
||||
int prval = 1;
|
||||
float f = (float)val / 10.f;
|
||||
switch(lastpar){
|
||||
case REG_WSPEED:
|
||||
DBG("wind speed");
|
||||
meteoflags |= WSFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_WND)){ // not entered by hands
|
||||
if(f >= 0.f && f < 200.f){
|
||||
val_Wnd = f;
|
||||
MeteoMode &= ~NET_WND;
|
||||
MeteoMode |= SENSOR_WND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REG_WDIR:
|
||||
DBG("wind direction");
|
||||
//meteoflags |= WDFLAG;
|
||||
break;
|
||||
case REG_TAIR:
|
||||
DBG("air temperature");
|
||||
meteoflags |= TFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_T1)){
|
||||
if(f > -40.f && f < 40.f){
|
||||
val_T1 = f;
|
||||
MeteoMode &= ~NET_T1;
|
||||
MeteoMode |= SENSOR_T1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REG_HUM:
|
||||
DBG("humidity");
|
||||
meteoflags |= HFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_HMD)){
|
||||
if(f >= 0.f && f <= 100.f){
|
||||
val_Hmd = f;
|
||||
MeteoMode &= ~NET_HMD;
|
||||
MeteoMode |= SENSOR_HMD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REG_DEW:
|
||||
DBG("dewpoint");
|
||||
break;
|
||||
case REG_PRES:
|
||||
DBG("pressure");
|
||||
f *= 760.f/1013.f; // convert hPa->mmHg
|
||||
meteoflags |= PFLAG;
|
||||
if(gotsegm && !(MeteoMode & INPUT_B)){
|
||||
if(f > 500.f && f < 700.f){
|
||||
val_B = f;
|
||||
MeteoMode &= ~NET_B;
|
||||
MeteoMode |= SENSOR_B;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
prval = 0;
|
||||
}
|
||||
lastpar = 0;
|
||||
if(prval){
|
||||
DBG("=%.1f\n", f);
|
||||
return ANS_OK;
|
||||
}
|
||||
size = 0;
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 6.0.0, 2022-06-09T15:28:23. -->
|
||||
<!-- Written by QtCreator 13.0.0, 2024-04-16T23:20:39. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{cf63021e-ef53-49b0-b03b-2f2570cdf3b6}</value>
|
||||
<value type="QByteArray">{7bd84e39-ca37-46d3-be9d-99ebea85bc0d}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
@ -28,7 +28,7 @@
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">KOI8-R</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
@ -37,33 +37,49 @@
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">1</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">false</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">8</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
@ -77,12 +93,12 @@
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{91347f2c-5221-46a7-80b1-0a054ca02f79}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{65a14f9e-e008-4c1b-89df-4eaa4774b6e3}</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eddy/Docs/SAO/BTA/Meteostation_new/BTA_modbusmeteo</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Big/Data/00-BTAmirtemp</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||
@ -91,9 +107,9 @@
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Сборка</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
@ -104,9 +120,9 @@
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Очистка</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
@ -117,12 +133,12 @@
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
@ -130,24 +146,29 @@
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user