ets_putc and VAlist with PrintF

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

ets_putc and VAlist with PrintF

Postby AgentSmithers » Wed Apr 17, 2019 1:51 am

Anyone know how to get vasprintF to operate?
I am trying to hook os_printf() to allow it to pass through multiple functions however I can't seem to get the VA list to render correctly via passing as arg to a nested function..

For my function below I keep getting undefined but when I replace it with something else I get Invalid Reach. Anyone get this little sniplet to work?


Code: Select all

void * user_printfHook[2] = {NULL, NULL};
void * ICACHE_FLASH_ATTR user_printf(const char *s, ...)
{
   /*
   os_printf("[%s]\n", __func__);
   int i=0;
   os_printf("a");
   for (i=0; i<(sizeof(user_printfHook)/4); i++)
   {
   os_printf("b");
      if (user_printfHook[i] != NULL)
      {
         os_printf("c");
         ((void (*)(const char *))user_printfHook[i])(s);
      }
   }
   */
   os_printf("1");
   va_list args;
   os_printf("2");
   va_start(args, s);
   os_printf("3");
   ets_vprintf(ets_putc, s, args);
   os_printf("4");
   va_end(args);
   os_printf("5");
}



*Update*
This works fine...

Code: Select all

void write_mychar(char ch)
{
   os_printf("%c", ch);
}

void * ICACHE_FLASH_ATTR user_printf(const char *s, ...)
{
   int i=0;
   for (i=0; i<(sizeof(user_printfHook)/4); i++)
   {
      if (user_printfHook[i] != NULL)
      {
         ((void (*)(const char *))user_printfHook[i])(s);
      }
   }
   va_list args;
   va_start(args, s);
   ets_vprintf(write_mychar, s, args);
   va_end(args);
}


I think this ultimately needs to point to ets_putc or something but it appears undefined.

Who is online

Users browsing this forum: No registered users and 274 guests