AnsweredAssumed Answered

printf to serial through a queue

Question asked by Zamek on Oct 30, 2016
Latest reply on Nov 14, 2016 by Zamek
Hi All,

I would like to use a queue to send printf outputs to a serial port.
When I try to send something into the queue, its freezes after 3rd character. Here is the queue init code:

static struct {
    osMessageQId receive_queue;
    osMessageQId transmit_queue;
void console_init(void) {
    if (!console_stream)
    osMessageQDef(transmit_queue,CONSOLE_BUFFER_SIZE, sizeof(uint8_t));
    console.transmit_queue = osMessageCreate(osMessageQ(transmit_queue), NULL);
    osMessageQDef(receive_queue, CONSOLE_BUFFER_SIZE, sizeof(uint8_t));
    console.receive_queue = osMessageCreate(osMessageQ(receive_queue), NULL);

here is the putchar code:
    osMessagePut(console.transmit_queue, ch, 100);
    return ch;

and here is the serial task code:
void console_task_func(void) {
    if (!console_stream)
    osEvent ev;
    for(;;) {
        ev  = osMessageGet(console.transmit_queue, 100);
        if (ev.status==osEventMessage)
            HAL_UART_Transmit(console_stream, (uint8_t *)&ev.value, (uint16_t)1, 10U);

I there any specialities if I want to use it from printf?