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.

CCS/LAUNCHXL-CC1352R1: Input from terminal to board

Part Number: LAUNCHXL-CC1352R1
Other Parts Discussed in Thread: CC1352P

Tool/software: Code Composer Studio


Hello to all
I use the disp_printf(...) or Display_printf() functions to output data from board to the terminal program on PC.
I need the ability to get data from the keyboard.  Something like  getchar() or  scanf().

Is there such a solution or how can i do it ?

Thank you in advance

Haim

  • Hi Haim,

    The CC32xx family of devices perform this in the network_terminal example in the SDK. Here's a function from that project used to get a command string from UART (the terminal window):

    //*****************************************************************************
    //
    //! Get the Command string from UART
    //!
    //! \param[in]  pucBuffer   - is the command store to which command will be
    //!                           populated
    //! \param[in]  ucBufLen    - is the length of buffer store available
    //!
    //! \return Length of the bytes received. -1 if buffer length exceeded.
    //!
    //*****************************************************************************
    int GetCmd(char *pcBuffer,
               unsigned int uiBufLen)
    {
        char cChar;
        int iLen = 0;
    
        UART_readPolling(uartHandle, &cChar, 1);
    
        iLen = 0;
    
        //
        // Checking the end of Command
        //
        while(1)
        {
            //
            // Handling overflow of buffer
            //
            if(iLen >= uiBufLen)
            {
                return(-1);
            }
    
            //
            // Copying Data from UART into a buffer
            //
            if((cChar == '\r') || (cChar == '\n'))
            {
                UART_writePolling(uartHandle, &cChar, 1);
                break;
            }
            else if(cChar == '\b')
            {
                //
                // Deleting last character when you hit backspace
                //
                char ch;
    
                UART_writePolling(uartHandle, &cChar, 1);
                ch = ' ';
                UART_writePolling(uartHandle, &ch, 1);
                if(iLen)
                {
                    UART_writePolling(uartHandle, &cChar, 1);
                    iLen--;
                }
                else
                {
                    ch = '\a';
                    UART_writePolling(uartHandle, &ch, 1);
                }
            }
            else
            {
                //
                // Echo the received character
                //
                UART_writePolling(uartHandle, &cChar, 1);
    
                *(pcBuffer + iLen) = cChar;
                iLen++;
            }
    
            UART_readPolling(uartHandle, &cChar, 1);
        }
    
        *(pcBuffer + iLen) = '\0';
    
        return(iLen);
    }

    If you want to further review this example for reference, you can download the SDK here: 

    Thanks,

    Alexis


  • Hi Alexis !
    Thanks for the quick response.
    Unfortunately this does not solve my problem.

    I work with CC1352 and in its SDK there is an example of "portable_CC1352P_2_LAUNCHXL_tirtos_ccs"
    where UART 0 is used to enter information from terminal but functions Display_init(), disp_printf(...) or Display_printf() do not work

    My question was different: Is it possible to provide input from the terminal when using the Display_init(), disp_printf(...) or Display_printf() functions?

    Is it possible in principle?

    Best Regards

    Haim

  • Hi Haim,

    No, it is not possible when using the Display_init(), disp_printf(...) or Display_printf() functions. You would have to use the UART driver.

    Thanks,

    Alexis

  • Thanks Alexis.
    Is it possible to use in the same code the functions Displa_***() for data output and functions UART for data input?
    If there is, please give me an example from SDK codes.

    Best regards Haim.

  • Hi Haim,

    No this is also not possible, as you would have two different drivers trying to control the same peripheral. Your best bet is to just use the UART driver for both data input and output.

    Thanks,

    Alexis