Skip to content

Commit 67f6826

Browse files
committed
Merge pull request #27 from Debianguru/master
fixes high CPU load if remote sensors not present
2 parents 4d0b7dc + 10d126c commit 67f6826

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

MySensor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void MySensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_
116116

117117
if (!RF24::isPVariant()) {
118118
debug(PSTR("check wires\n"));
119-
while(1);
119+
throw "check wires";
120120
}
121121
RF24::setAutoAck(1);
122122
RF24::setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
@@ -347,15 +347,17 @@ boolean MySensor::process() {
347347
#ifndef __Raspberry_Pi
348348
// Requires MySensors or other bootloader with watchdogs enabled
349349
wdt_enable(WDTO_15MS);
350-
for (;;);
350+
//for (;;);
351+
throw "I_REBOOT";
351352
#endif
352353
} else if (type == I_ID_RESPONSE) {
353354
if (nc.nodeId == AUTO) {
354355
nc.nodeId = msg.getByte();
355356
if (nc.nodeId == AUTO) {
356357
// sensor net gateway will return max id if all sensor id are taken
357358
debug(PSTR("full\n"));
358-
while (1); // Wait here. Nothing else we can do...
359+
//while (1); // Wait here. Nothing else we can do...
360+
throw "full";
359361
}
360362
setupNode();
361363
// Write id to EEPROM

PiGateway.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ int main(int argc, char** argv)
6666
{
6767
openSyslog();
6868
setup();
69-
while(1)
69+
while(1) {
7070
loop();
71+
sleep(1);
72+
}
7173
closeSyslog();
7274
return 0;
73-
}
75+
}

PiGatewaySerial.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ int main(int argc, char **argv)
271271
if (ret == -1)
272272
{
273273
log(LOG_ERR,"poll() error (%d) %s\n", errno, strerror(errno));
274+
sleep(10);
274275
}
275276
else if (ret == 0)
276277
{
@@ -294,6 +295,8 @@ int main(int argc, char **argv)
294295
buff[size] = '\0';
295296

296297
gw->parseAndSend(buff);
298+
} else {
299+
sleep(60);
297300
}
298301
}
299302
}

0 commit comments

Comments
 (0)