@@ -61,6 +61,8 @@ m_berCount1(0U),
61
61
m_berCount2(0U ),
62
62
m_txFrequency(txFrequency),
63
63
m_rxFrequency(rxFrequency),
64
+ m_fl_txFrequency(0 .0F ),
65
+ m_fl_rxFrequency(0 .0F ),
64
66
m_displayTempInF(displayTempInF),
65
67
m_location(location)
66
68
{
@@ -84,19 +86,16 @@ bool CNextion::open()
84
86
return false ;
85
87
}
86
88
87
- info[0 ]= 0 ;
89
+ info[0 ] = 0 ;
88
90
m_network = new CNetworkInfo;
89
91
m_network->getNetworkInterface (info);
90
92
m_ipaddress = (char *)info;
91
93
92
94
sendCommand (" bkcmd=0" );
93
95
sendCommandAction (0U );
94
96
95
- m_fl_txFrequency = m_txFrequency;
96
- m_fl_txFrequency/=1000000U ;
97
-
98
- m_fl_rxFrequency = m_rxFrequency;
99
- m_fl_rxFrequency/=1000000U ;
97
+ m_fl_txFrequency = float (m_txFrequency) / 1000000 .0F ;
98
+ m_fl_rxFrequency = float (m_rxFrequency) / 1000000 .0F ;
100
99
101
100
setIdle ();
102
101
@@ -133,22 +132,24 @@ void CNextion::setIdleInt()
133
132
sendCommand (command);
134
133
sendCommandAction (21U );
135
134
136
- FILE *deviceInfoFile;
137
- double val;
138
- // CPU temperature
139
- deviceInfoFile = fopen (" /sys/class/thermal/thermal_zone0/temp" , " r" );
140
- if (deviceInfoFile != NULL ) {
141
- fscanf (deviceInfoFile, " %lf" , &val);
142
- fclose (deviceInfoFile);
143
- val /= 1000 ;
144
- if ( m_displayTempInF){
145
- val = (1.8 * val) + 32 ;
135
+ // CPU temperature
136
+ FILE* fp = ::fopen (" /sys/class/thermal/thermal_zone0/temp" , " rt" );
137
+ if (fp != NULL ) {
138
+ double val = 0.0 ;
139
+ int n = ::fscanf (fp, " %lf" , &val);
140
+ ::fclose (fp);
141
+
142
+ if (n == 1 ) {
143
+ val /= 1000.0 ;
144
+ if (m_displayTempInF) {
145
+ val = (1.8 * val) + 32.0 ;
146
146
::sprintf (command, " t20.txt=\" %2.1f %cF\" " , val, 176 );
147
147
} else {
148
148
::sprintf (command, " t20.txt=\" %2.1f %cC\" " , val, 176 );
149
149
}
150
150
sendCommand (command);
151
151
sendCommandAction (22U );
152
+ }
152
153
}
153
154
154
155
::sprintf (command, " t31.txt=\" %s\" " , m_location.c_str()); // location
0 commit comments