does esp_log_set_vprintf() work with arduino framework?

azz-zza
Posts: 45
Joined: Tue Sep 17, 2019 2:58 am

does esp_log_set_vprintf() work with arduino framework?

Postby azz-zza » Fri Aug 07, 2020 4:28 am

Hello,
trying to leverage the esp_log_set_vprintf() to direct the output to network service. And having no luck with it. Is it because of the arduino framwork ?

Code: Select all

#include <AWS_IOT.h>
#include <WiFi.h>
...
int double_vprintf(const char *fmt, va_list args) {

	if (hornbill.publish(TOPIC_NAME,"Static payload") == 0) {
		Serial.println("Printing from double_vprintf()");
	} else {
	Serial.println("hornbill.publish failed from the vprintf() ");
	};
	Serial.println("Printing from doubel_vprintf");
	return vprintf(fmt, args);
}
...
void setup() {
...
if(0 == hornbill.subscribe(TOPIC_NAME,mySubCallBackHandler)) {
			ESP_LOGI(TAG,"Registering double_vprint() ");
			esp_log_set_vprintf(&double_vprintf);
			ESP_LOGI(TAG,"Subscribe Successful");
//			Serial.println("Subscribe Successful");
		} else {
			ESP_LOGE(TAG,"Subscribe Failed, Check the Thing Name and Certificates");
//			Serial.println("Subscribe Failed, Check the Thing Name and Certificates");
			while(1);
		}
...
}
oid loop() {

	if(msgReceived == 1) {
		msgReceived = 0;
		Serial.print("Received Message:");
		Serial.println(rcvdPayload);
	}
	if(tick >= 5) { // publish to topic every 5seconds
		tick=0;
		sprintf(payload,"Hello from hornbill ESP32 : %d",msgCount++);
		if(hornbill.publish(TOPIC_NAME,payload) == 0) {
			ESP_LOGI(TAG,"Publish Message: %s",payload);
			Serial.print("Publish Message:");
			Serial.println(payload);
		} else {
			ESP_LOGI(TAG,"Publish failed");
			Serial.println("Publish failed");
		}
	}
	vTaskDelay(1000 / portTICK_RATE_MS);
	tick++;
}


in the output i see that it executes the esp_log_set_vprintf(&double_vprintf);. But nothing seemed to come out from the double_vprintf(). I expect to see messages going over to mqqt and on the serial...

thank you for helping out.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: does esp_log_set_vprintf() work with arduino framework?

Postby PeterR » Fri Aug 07, 2020 2:26 pm

Seems that you are not sending anything to the service!

You call vprintf() which sends to stdout.
Instead vsnprintf() and then send the string to both stdout and your network device.
& I also believe that IDF CAN should be fixed.

azz-zza
Posts: 45
Joined: Tue Sep 17, 2019 2:58 am

Re: does esp_log_set_vprintf() work with arduino framework?

Postby azz-zza » Fri Aug 07, 2020 2:40 pm

PeterR wrote:
Fri Aug 07, 2020 2:26 pm
Seems that you are not sending anything to the service!

You call vprintf() which sends to stdout.
Instead vsnprintf() and then send the string to both stdout and your network device.
@Peter, thank you for your reply.

I beleive hornbill.publish sends the data over. I also wanted to test if the double_print function actually gets executed, thus Serial.print(). But i get neither message on mqqt nor on serial.

Im becoming convinced the arduino framework broke ulog functionality including vprint -https://community.platformio.org/t/is-i ... p32/6999/7

Who is online

Users browsing this forum: No registered users and 103 guests