assert failed: pbuf_free /IDF/components/lwip/lwip/src/core/pbuf.c:753 (pbuf_free: p->ref > 0)
zaid13 opened this issue · 4 comments
Getting
11:12:00.719 -> assert failed: pbuf_free /IDF/components/lwip/lwip/src/core/pbuf.c:753 (pbuf_free: p->ref > 0)
11:12:00.751 ->
11:12:00.751 ->
11:12:00.751 -> Backtrace: 0x40082851:0x3ffb3200 0x4008de85:0x3ffb3220 0x4009346a:0x3ffb3240 0x400f194b:0x3ffb3370 0x400f2ae9:0x3ffb3390 0x400f3dd9:0x3ffb33b0 0x400f4053:0x3ffb33d0 0x400f561f:0x3ffb3400 0x400fa3d2:0x3ffb3440 0x400ff167:0x3ffb3470 0x400ef8c5:0x3ffb3490
11:12:00.751 ->
11:12:00.751 ->
11:12:00.751 ->
11:12:00.751 ->
11:12:00.751 -> ELF file SHA256: df24e2e02771320f
11:12:00.783 ->
11:12:00.783 -> Rebooting...
when calling Http.POST in loop im getting this error.
When the delay is greater than 10 seconds i dont see an error.but when delay is less than 10 seconds.
Here is my code.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
uint16_t BNO055_SAMPLERATE_DELAY_MS = 1000;
#define FORCE_SENSOR_PIN 35 // ESP32 pin GPIO36 (ADC0): the FSR and 10K pulldown are connected to A0
#define LED 2
const char* ssid = "S24Ultra";
const char* password = "12345678";
// const char* url ="http://ec2-54-224-138-109.compute-1.amazonaws.com:8003/logs/create_log?";
// id, address
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28, &Wire);
uint32_t uniqueNumber;
String stringList[10]; // Array to store up to 5 strings
int currentIndex = 0; // Current index for storing the next string
void setup(void) {
Serial.begin(115200);
pinMode(LED, OUTPUT);
while (!Serial) delay(10); // wait for serial port to open!
Serial.println("Orientation Sensor Test");
Serial.println("");
/* Initialise the sensor */
if (!bno.begin()) {
/* There was a problem detecting the BNO055 ... check your connections */
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while (1)
;
}
uniqueNumber = millis();
WiFi.begin(ssid, password);
Serial.println("Connecting");
while (WiFi.status() != WL_CONNECTED) {
// delay(500);
Serial.print(".");
}
digitalWrite(LED, HIGH);
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
}
unsigned long previousMillis = 0;
const long interval = 700; // Interval in milliseconds
void loop(void) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
// Place your API call or other tasks here
int analogReading = analogRead(FORCE_SENSOR_PIN);
// ////// force sensor
Serial.print("The force sensor value = ");
Serial.print(analogReading); // print the raw analog reading
if (analogReading < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (analogReading < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (analogReading < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (analogReading < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
digitalWrite(LED, LOW);
//could add VECTOR_ACCELEROMETER, VECTOR_MAGNETOMETER,VECTOR_GRAVITY...
sensors_event_t orientationData, angVelocityData, linearAccelData, magnetometerData, accelerometerData, gravityData;
bno.getEvent(&orientationData, Adafruit_BNO055::VECTOR_EULER);
bno.getEvent(&angVelocityData, Adafruit_BNO055::VECTOR_GYROSCOPE);
bno.getEvent(&linearAccelData, Adafruit_BNO055::VECTOR_LINEARACCEL);
bno.getEvent(&magnetometerData, Adafruit_BNO055::VECTOR_MAGNETOMETER);
bno.getEvent(&accelerometerData, Adafruit_BNO055::VECTOR_ACCELEROMETER);
bno.getEvent(&gravityData, Adafruit_BNO055::VECTOR_GRAVITY);
// ////// IMU sensor
int8_t boardTemp = bno.getTemp();
if (WiFi.status() == WL_CONNECTED) {
HTTPClient Http;
WiFiClient Client;
int ResponseCode;
String Url, ReqBody, ResponseStr;
Url = "http://ec2-54-224-138-109.compute-1.amazonaws.com:8009/logs/create_log/";
Http.begin(Client, Url.c_str());
Http.addHeader("accept", "application/json");
Http.addHeader("x-token", "your_X-Token"); // Same token for redirected request
Http.addHeader("Content-Type", "application/json");
StaticJsonDocument<200> doc;
// Prepare the JSON object
doc["session_id"] = uniqueNumber;
doc["orient_x"] = orientationData.orientation.x; //331.87;
doc["orient_y"] = orientationData.orientation.y; //-0.977;
doc["orient_z"] = orientationData.orientation.z; //-179.25;
doc["gyro_x"] = angVelocityData.gyro.x; // 0; //
doc["gyro_y"] = angVelocityData.gyro.y; //0;
doc["gyro_z"] = angVelocityData.gyro.z; //0;
doc["linear_x"] = linearAccelData.acceleration.x; // -0.02;
doc["linear_y"] = linearAccelData.acceleration.y; //0.07;
doc["linear_z"] = linearAccelData.acceleration.z; //0;
doc["mag_x"] = magnetometerData.magnetic.x; //-10;
doc["mag_y"] = magnetometerData.magnetic.y; //--42.5;
doc["mag_z"] = magnetometerData.magnetic.z; //--12;
doc["accl_x"] = accelerometerData.acceleration.x; // -0.18;
doc["accl_y"] = accelerometerData.acceleration.y; //;
doc["accl_z"] = accelerometerData.acceleration.z; //;
doc["gravity_x"] = gravityData.acceleration.x; // -0.16;
doc["gravity_y"] = gravityData.acceleration.y; // 0.12;
doc["gravity_z"] = gravityData.acceleration.z; // -9.8;
doc["temprature"] = boardTemp;
doc["pressure"] = analogReading;
serializeJson(doc, ReqBody);
ResponseCode = Http.POST(ReqBody);
if (ResponseCode == 200) {
digitalWrite(LED, HIGH);
}
ResponseStr = Http.getString();
Serial.println("ResponseCode: " + String(ResponseCode));
Serial.println("ResponseStr: " + ResponseStr);
Serial.println("1");
Http.end();
Serial.println("2");
} else {
Serial.println("WiFi Disconnected");
// digitalWrite(LED,LOW);
}
Serial.println("3");
}
}
void printEvent(sensors_event_t* event) {
double x = -1000000, y = -1000000, z = -1000000; //dumb values, easy to spot problem
if (event->type == SENSOR_TYPE_ACCELEROMETER) {
Serial.print("Accl:");
x = event->acceleration.x;
y = event->acceleration.y;
z = event->acceleration.z;
} else if (event->type == SENSOR_TYPE_ORIENTATION) {
Serial.print("Orient:");
x = event->orientation.x;
y = event->orientation.y;
z = event->orientation.z;
} else if (event->type == SENSOR_TYPE_MAGNETIC_FIELD) {
Serial.print("Mag:");
x = event->magnetic.x;
y = event->magnetic.y;
z = event->magnetic.z;
} else if (event->type == SENSOR_TYPE_GYROSCOPE) {
Serial.print("Gyro:");
x = event->gyro.x;
y = event->gyro.y;
z = event->gyro.z;
} else if (event->type == SENSOR_TYPE_ROTATION_VECTOR) {
Serial.print("Rot:");
x = event->gyro.x;
y = event->gyro.y;
z = event->gyro.z;
} else if (event->type == SENSOR_TYPE_LINEAR_ACCELERATION) {
Serial.print("Linear:");
x = event->acceleration.x;
y = event->acceleration.y;
z = event->acceleration.z;
} else if (event->type == SENSOR_TYPE_GRAVITY) {
Serial.print("Gravity:");
x = event->acceleration.x;
y = event->acceleration.y;
z = event->acceleration.z;
} else {
Serial.print("Unk:");
}
Serial.print("\tx= ");
Serial.print(x);
Serial.print(" |\ty= ");
Serial.print(y);
Serial.print(" |\tz= ");
Serial.println(z);
}Can I remove the assertion in
assert failed: pbuf_free /IDF/components/lwip/lwip/src/core/pbuf.c:753 (pbuf_free: p->ref > 0)
But im not able to find the location of the file.
@chenshupe Thanks for responding. Which files do i have to replace?
Can you explain how this will solve the issue?
@zaid13 the file at the link in that comment (which I have deleted) is malware. Please do not download or unzip the file. If you have done that, then you should immediately take appropriate measures to secure your computer from infection.
I have reported @chenshupe's comment to GitHub. @chenshupe I see you have what appears to be legitimate activity. Your account might have been hacked. Please take the appropriate measures to prevent the attackers from continuing to use your account to distribute malware.
@zaid13 you are using the "HTTPClient" library that is bundled with the "esp32" boards platform:
https://github.com/espressif/arduino-esp32/tree/master/libraries/HTTPClient
That is different from the library hosted in this repository. So I'll close this as off topic.
Since it is clear that your intention is to get assistance with your project rather than to submit a formal bug report to the developers, I recommend posting on Arduino forum:
That will be the best way for you to get quick assistance with your project.