File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -135,12 +135,16 @@ void P1MeterBase::Init()
135
135
m_gasoktime=0 ;
136
136
137
137
std::vector<std::vector<std::string> > result;
138
- result = m_sql.safe_query (" SELECT Value FROM UserVariables WHERE (Name == 'P1GasMeterChannel')" );
139
- if (( result.size () > 0 ) && (result[ 0 ][ 0 ]. size ()== 1 ) && (result[ 0 ][ 0 ]> " 0 " ) && (result[ 0 ][ 0 ]< " 5 " ))
138
+ result = m_sql.safe_query (" SELECT Value FROM UserVariables WHERE (Name= 'P1GasMeterChannel')" );
139
+ if (! result.empty ( ))
140
140
{
141
- m_gasmbuschannel=(char )result[0 ][0 ][0 ];
142
- m_gasprefix[2 ]=m_gasmbuschannel;
143
- _log.Log (LOG_STATUS," P1 Smart Meter: Gas meter M-Bus channel %c enforced by 'P1GasMeterChannel' user variable" , m_gasmbuschannel);
141
+ std::string s_gasmbuschannel = result[0 ][0 ];
142
+ if ((s_gasmbuschannel.length ()==1 ) && (s_gasmbuschannel[0 ]>0x30 ) && (s_gasmbuschannel[0 ]<0x35 )) // value must be a single digit number between 1 and 4
143
+ {
144
+ m_gasmbuschannel=(char )s_gasmbuschannel[0 ];
145
+ m_gasprefix[2 ]=m_gasmbuschannel;
146
+ _log.Log (LOG_STATUS," P1 Smart Meter: Gas meter M-Bus channel %c enforced by 'P1GasMeterChannel' user variable" , m_gasmbuschannel);
147
+ }
144
148
}
145
149
}
146
150
You can’t perform that action at this time.
0 commit comments