I am getting a strange error message displaying frequently when I am displaying UDP data sent over a network.
0000029659 [net.en] ERROR: Failed to allocate pbuf
I tried searching for this error message but I couldn’t find any clues.
Here is the successful UDP message displayed on the Serial Monitor (*data removed for security) along with the error message described above.
What could be the cause of 0000029659 [net.en] ERROR: Failed to allocate pbuf
Source Code → Particle Argon, deviceOS@3.1.0
#include "Particle.h"
UDP Udp;
char message[128];
const int port = 7234;
long unsigned now = 0;
long unsigned lastTime = 0;
const int INTERVAL = 5000;
SerialLogHandler logHandler(LOG_LEVEL_WARN, {{ "app", LOG_LEVEL_INFO }});
void setup() {
Udp.begin (port);
}
void loop() {
now = millis();
if (now - lastTime > INTERVAL){
lastTime = now;
Udp.receivePacket((byte*)message, 127);
Log.info(message);
}
}
Corrected Code → No more [net.en] ERROR - Thank you @rickkas7
#include "Particle.h"
UDP Udp;
char message[128];
const int port = 7234;
long unsigned now = 0;
long unsigned lastTime = 0;
const int INTERVAL = 5000;
SerialLogHandler logHandler(LOG_LEVEL_WARN, {{ "app", LOG_LEVEL_INFO }});
void setup() {
Udp.begin (port);
}
void loop() {
now = millis();
Udp.receivePacket((byte*)message, 127); // Updated Location
if (now - lastTime > INTERVAL){
lastTime = now;
Log.info(message);
}
}