5 years, 4 months ago.

queue printf directly.

Hi, I have queue EventQueue *queue = mbed_event_queue();

Currenty i do queue->call(startAsyncMeasureTC) with simple

void startAsyncMeasureTC() {
  USB.printf("# Async US_Data until stop \r\n");
}

but since this is a slingle line I would like to invoke printf directly. I have MODSERIAL USB(...) and so I would like to write

queue->call(&USB,&MODSERIAL::printf,"# Async US_Data until stop \r\n")

This does not compile... what do I do wrong???

1 Answer

5 years, 3 months ago.

Put the printf statement in its own function. Call the function that contains the printf.

print_statement()
{
  printf("stuff to print\r\n")
}

...

queue->call(&print_statement)