frankjoshua / rosserial_arduino_lib

58 stars 46 forks source link

Keep Crashing on ESP32 #16

Open garudaonekh opened 3 years ago

garudaonekh commented 3 years ago

HI, I try nearly all example. All of them keep crashing on my ESP32-Wroom 32

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4 assertion "Invalid mbox" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c", line 374, function: tcpip_send_msg_wait_sem abort() was called at PC 0x400ea737 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x40085084:0x3ffb1dd0 0x40085301:0x3ffb1df0 0x400ea737:0x3ffb1e10 0x400d97c3:0x3ffb1e40 0x400d925d:0x3ffb1e70 0x400d9410:0x3ffb1e90 0x400dc964:0x3ffb1ed0 0x400d27a6:0x3ffb1ef0 0x400d21a6:0x3ffb1f40 0x400d1c81:0x3ffb1f70 0x400d3282:0x3ffb1fb0 0x40086302:0x3ffb1fd0

FullMetalRico commented 2 years ago

Apparently that is happening because the ESP32 is not connected to a WiFi network. It seems all the examples are using TCP/IP and if you are not connected to a network it will simply crash.

I fixed the error by using this code (change "your-wifi-network-ssid" and "your-wifi-network-password" according to your wifi settings)

I have not tried to actually receive the messages but at least it is not crashing anymore

#include <WiFi.h>

const char* ssid     = "your-wifi-network-ssid";
const char* password = "your-wifi-network-password";

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

char hello[13] = "hello world!";

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  delay(100);

  nh.initNode();
  nh.advertise(chatter);
}

void loop()
{
  str_msg.data = hello;
  chatter.publish( &str_msg );
  nh.spinOnce();
  delay(1000);
}