loraraspi91 / LoRa4Raspi

MIT License
12 stars 9 forks source link

High CPU usage #2

Closed gbaruffa closed 4 years ago

gbaruffa commented 4 years ago

Hello, I was wondering whether it is normal to have a 100% CPU usage when running the receivers on a Raspberry Pi Zero W, or 30% on a Raspberry Pi 3 Mod B. I have tried both the LoRaReceiver and LoRaReceiverCallback programs. BTW, I am using this with an Adafruit LoRa Radio Bonnet with OLED and, apart the high CPU usage, it seems to work fine. I am instantiating the module with

...
LoRa.setPins(11, 6, 3);
...

in the code.

loraraspi91 commented 4 years ago

Hello,

Yes it is normal since the example make an infinite loop without any delay or sleep You can change the program by adding a "sleep" instruction to make the cpu breathing.

Le sam. 18 juil. 2020 à 09:10, Giuseppe notifications@github.com a écrit :

Hello, I was wondering whether it is normal to have a 100% CPU usage when running the receivers on a Raspberry Pi Zero W, or 30% on a Raspberry Pi 3 Mod B. I have tried both the LoRaReceiver and LoRaReceiverCallback programs. BTW, I am using this with an Adafruit LoRa Radio Bonnet with OLED and, apart the high CPU usage, it seems to work fine. I am instantiating the module with

... LoRa.setPins(11, 6, 3); ...

in the code.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/loraraspi91/LoRa4Raspi/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOXEAABKVKGHRJEOVBO763DR4FDHDANCNFSM4O7Q4XKA .

loraraspi91 commented 4 years ago

You can also use the example "callback" it makes receipt or sending message via interrupt. So no cpu is used to wait for an incomming message. The library working exactly like the original library in term of cpu usage

Le dim. 19 juil. 2020 à 12:17, laurent Rioux loraraspi91@gmail.com a écrit :

Hello,

Yes it is normal since the example make an infinite loop without any delay or sleep You can change the program by adding a "sleep" instruction to make the cpu breathing.

Le sam. 18 juil. 2020 à 09:10, Giuseppe notifications@github.com a écrit :

Hello, I was wondering whether it is normal to have a 100% CPU usage when running the receivers on a Raspberry Pi Zero W, or 30% on a Raspberry Pi 3 Mod B. I have tried both the LoRaReceiver and LoRaReceiverCallback programs. BTW, I am using this with an Adafruit LoRa Radio Bonnet with OLED and, apart the high CPU usage, it seems to work fine. I am instantiating the module with

... LoRa.setPins(11, 6, 3); ...

in the code.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/loraraspi91/LoRa4Raspi/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOXEAABKVKGHRJEOVBO763DR4FDHDANCNFSM4O7Q4XKA .

gbaruffa commented 4 years ago

Nice, thank you! I have put the CPU to sleep within the loop() function

#include <unistd.h>
...
void loop() {
  ...
  usleep(50000);
  ...
}
...

and now the loads are normalized (<1%).