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.

bios_uart problem

Hi

I am using the following code in in a BIOS_UART project.

     len = 21;//SIZEOF_UART_STRING;                                                   
     status = GIO_read(hUart_IN, &bufin, &len);

The programm wait forever until all 21 bytes are received .

Is it possible to use this function with a time limit to check if all 21 bytes received

or other function that will do the job.

Please Asdvise.

Thanks

  • Hi ephraim,

     

    Can you please confirm which BIOS PSP you are using?. 

     

    ephraim oved said:
    The programm wait forever until all 21 bytes are received

    This is expected, since GIO_read(...) is a synchronous call(blocking).

     

    If you need to provide timeout, then you can specify it in GIO_create(...)  call. 

    typedef struct GIO_Attrs {

    Int nPackets; /* number of asynch I/O packets */

    Uns timeout; /* for blocking calls (Default: SYS_FOREVER) */

    } GIO_Attrs;

    In your case:

     

        /* Initialize channel attributes. */

        gioAttrs.nPackets = 2;

        gioAttrs.timeout = 1000u; /* Specify timeout value according to your requirement */

        hUart_IN  = GIO_create("/UART",IOM_INPUT,&echoTskStatus,NULL,&gioAttrs);

     

    ephraim oved said:
         len = 21;//SIZEOF_UART_STRING;                                                   
         status = GIO_read(hUart_IN, &bufin, &len);

    After timeout the bufffer(bufin) will be updated with the data you have provided(Ex: serial console), but the "len" will not be updated since driver will not have completed the current request. "status" will be updated with appropriate error code(timeout).

     

    Thanks & regards,

    Raghavendra

  • Hi Raghavendra,

    We are having similar requirement, but to read the available bytes even if timeout occurred, therefore we need the "len" parameter to be updated with the available bytes, where should we modify in the driver for that? Also we noticed an exception when calling GIO_Control(uartRxHandle , UART_IOCTL_CANCEL_CURRENT_IO, 0), is that supposed to happen?

    GIO_Handle uartRxHandle=NULL, uartTxHandle=NULL;

    userUartInit(){

    Uart_init();

    g_uartParams = Uart_PARAMS;
    g_uartParams.opMode = Uart_OpMode_DMAINTERRUPT;
    g_uartParams.baudRate = Uart_BaudRate_115_2K;
    g_uartParams.hwiNumber = 9;
    g_uartParams.rxThreshold = Uart_RxTrigLvl_1;
    g_uartParams.softTxFifoThreshold = 1;
    g_uartParams.fc.fcType = Uart_FcType_NONE;
    g_uartParams.fc.fcParam = Uart_FcParam_NONE;

    /* initialise the edma library and get the EDMA handle */
    Uart_ChanParams chanParams;
    chanParams.hEdma = edma3init();

    /*
    * Initialize channel attributes.
    */
    Error_Block eb;
    GIO_Params ioParams;

    /* create R/W streams */
    Error_init(&eb);
    GIO_Params_init(&ioParams);
    ioParams.chanParams = (Ptr) &chanParams;
    ioParams.timeout = BIOS_WAIT_FOREVER;
    uartTxHandle = GIO_create("/uart2", GIO_OUTPUT, &ioParams, &eb);

    Error_init(&eb);
    GIO_Params_init(&ioParams);
    ioParams.chanParams = (Ptr) &chanParams;
    ioParams.timeout = 1000;                                                                                                               //what is the timeout, mS?
    uartRxHandle = GIO_create("/uart2", GIO_INPUT, &ioParams, &eb);

    }

    Best regards,

    David.

  • Hi David,

    As I have already mentioned, "The(len) will be updated in the driver during the completion of the current request. But if timeout occurs, the bufffer(bufin) may be updated with the data you have provided(Ex: serial console), but the "len" will not be updated.

    This is because, Timeout happens from a GIO layer. Whenever a 'timeout value' is provided, a counter starts and counts till timeout is reached (In BIOS)and if within this time still the remaining data is not sent then it times out with a error message. This a GIO level error. The driver will not have any control over this, and will not get a chance to update the buflen and related status.

    In such case, you can either increase the timeout value or -

    With an existing timeout value, register an application callback function(use GIO_submit(...)). Here, even if timeout occurs, after the completion of transfer the application callback will be called wherin you can check for buflen and other related status. Refer BIOS Userguide for more details.

    Timeout is system clock ticks which is approximately 1ms

    Best Regards,

    Raghavendra

  • Hi Raghavendra,

    Thank you for the update, I understand now the value for the timeout that's in the GIO layer. Even in the callback function there's no way to retrieve the number of available bytes in the buffer, I assume is internal DMA register value. We can get the remaining bytes using INTERRUPT mode but not in DMA mode. How do we get this value within the callback? 

    Any idea about the GIO_control exception?

    Best regards,

    David.


  • David,

    Interrrupt mode or DMA mode, in either of the cases, after the completion of transfer the "Uart_localCompleteCurrentIO(..)" is called(Refer Uart.c). And inside this, the application callback is invoked. The app callback is invoked with two parameters, "cbArg" and "activeIOP". The activeIOP shall contain all the required information.

    What is the exception you are getting? Are you getting any error message? Is the uartHandle that is given to the GIO_control(..) appropriate/valid?. Try probing into the driver and check where exactly it is failing. You can look for "uartMdControlChan(...)" in the UART driver.

    Best Regards,

    Raghavendra