This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C674x DSP/BIOS UART Driver Timeout

Hello,

 

I am using the UART driver in the DSP/BIOS PSP (1.30.01) at 115.2 k baud.  We have a UART packet protocol that I need to receive.

 

The packet length can vary, but the format it always the same.  Each field is a byte, except for the data

 

|     start    |   length  |  command |          variable data    |  checksum |

 

In order to handle the variable length data I want to read the number of bytes corresponding to theminimum packet length  (six)  and then read the remaining bytes once I know the length.

 

Can I change the timeout for IOM reads after I initialize the driver ?

 

The code below works fine (as long as I don’t get a timeout).    I can change the timeout and it always blocks until I get the start of the packet then I read the rest.

 

If I actually get a timeout the status of the IOCTL calls says they succeeded, but the UART driver never resumes reading packets. 

 

As several other people have posted it is a very common problem to need to read variable length data from a UART.

 

If it is not possible to do what is shown below, do you have any other suggestions ?

 

Thanks

 

 

while ( readRxData )

{

   // wait as long as necessary for the start of a packet   

   len = MIN_PKT_LEN;

   hUart_IN->timeout = SYS_FOREVER;


   // Read the minimum packet length

   status = GIO_submit(hUart_IN,IOM_READ, buf, &len, NULL);

 

    // calculate how many more (if any) bytes we need to read to get the rest of the packet

    len = CalculateRemainingBytes(buf);

 

    // once we have started to receive the packet, the rest should show up in less than 100 mS

    // set a timeout in case we have slipped synchronization

    hUart_IN->timeout = 100;  // mS

 

   status = GIO_submit(hUart_IN,IOM_READ, buf, &len, NULL);

 

  if (!((status == IOM_COMPLETED)||(status == IOM_PENDING)))

{

       LOG_printf(&trace, "\r\n Error from GIO_read \n");

                   

       // Reset the FIFO and cancel the current read. 

       status = GIO_control(hUart_IN, Uart_IOCTL_CANCEL_CURRENT_IO, 0);

       status = GIO_control(hUart_IN, Uart_IOCTL_RESET_RX_FIFO, 0);

}

  • I have done more testing.   GIO_submit(hUart_IN, IOM_READ...)  is returning  IOM_ETIMEOUTUNREC   (-11) .

    Does the psp UART driver support timeouts at all ?   (It's being used in interrupt mode)

    When I get this error calling GIO_abort(hUART_IN) does not fix the problem, is there anything else I need to do ?

     

  • Hi Mark,

     

    Mark Monson said:
    Can I change the timeout for IOM reads after I initialize the driver ?

    Yes, you can do it.

     

    Mark Monson said:
    If I actually get a timeout the status of the IOCTL calls says they succeeded, but the UART driver never resumes reading packets

    So when you get a timeout, you would not be able to perform the next/another transaction on UART. Is my understanding correct?.

     

    Mark Monson said:
    The code below works fine (as long as I don’t get a timeout).    I can change the timeout and it always blocks until I get the start of the packet then I read the rest.

    If it is not possible to do what is shown below, do you have any other suggestions ? 

    Since GIO_submit(...) is a synchronous call(blocking), at any point of time only one IO packet will be available with the driver/GIO. 

    So, in case of any error you can just do the following:

    1. status = GIO_control(hUart_IN, Uart_IOCTL_RESET_RX_FIFO, 0); first and then,

    2. status = GIO_control(hUart_IN, Uart_IOCTL_CANCEL_CURRENT_IO, 0);

     

    Mark Monson said:
    Does the psp UART driver support timeouts at all ?

    The psp UART driver supports only character timeout and depending on this, it updates the packet with appropriate error status and returns back to the app. The "IOM_ETIMEOUTUNREC" is returned from the GIO layer, and needs to be handled in the application. If this "IOM_ETIMEOUTUNREC" is detected, you can perform the same steps as above and should be able to go ahead in making the next request.

     

    Thanks & regards,

    Raghavendra