UART Framework Transmit Question

Hello All,

I have a question I hope someone can help me with. I am using the UART framework and trying to send a string with the following code...

void taskUart_entry( void)
{
    const uint8_t message[] = "UART is working\r\n" ;

    g_sf_comms1.p_api->open( g_sf_comms1.p_ctrl, g_sf_comms1.p_cfg) ; // open comm port

    while ( 1)
    {
        g_sf_comms1.p_api->write( g_sf_comms1.p_ctrl, message, sizeof( message), 0) ;
        tx_thread_sleep( 125) ;
    }
}

it will only send one character unless I set the timeout to a larger value. I thought since I am using the DTC, it would handle the xfer without setting a timeout. Am I overlooking something? I am using SSP 1.6.0

 

Thanks,

jp

  • You are not checking the return from the API call to the UART comms framework. If you did :-

     

    void taskUart_entry( void)
    {
        ssp_err_t err;
        const uint8_t message[] = "UART is working\r\n" ;

        err = g_sf_comms0.p_api->open( g_sf_comms0.p_ctrl, g_sf_comms0.p_cfg) ; // open comm port
        if (SSP_SUCCESS != err)
        {
            while(1);
        }

        while ( 1)
        {
            err = g_sf_comms0.p_api->write( g_sf_comms0.p_ctrl, message, sizeof( message), 0) ;
            if (SSP_SUCCESS != err)
            {
                while(1);
            }
            tx_thread_sleep( 125) ;
        }
    }

     

    you would see that the call to write with a timeout of 0 returns SSP_ERR_TIMEOUT. The call to the write API is a blocking call, waiting for all the data to be transmitted. So a wait of zero is too short to allow the data to be transmitted (even if the DTC is used), so a longer timeout is required.

  • Have you try “strlen” on the piace of “sizeof” im not sure that sizeof of array work in the same way

    Simone