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.

RTOS/LAUNCHXL-CC1350: String Functions not working

Part Number: LAUNCHXL-CC1350
Other Parts Discussed in Thread: CC1350,

Tool/software: TI-RTOS

Hello All, 

I am working on cc1350 launchpad. I have included some string functions in my project like ATOI and strcmp but this functions are not working. I have included string.h file in main.c file. I am receiving packet over the air and trying to manipulate that data. But string functions are not working and I have confirmed that by manually giving values to the variables. Please help me with this.

  • did you also include stdin.h?

    maybe a look at this can point you in the right direction

    dev.ti.com/.../
  • Thanks for replying back Sir.
    But by including this file I am getting following errors:
    #1965 cannot open source file "stdin.h"

    I am not getting what to look at in the link that you have mentioned. Can you please help me a little more Sir.
  • I try the following code (in red) in LAUNCHXL-CC1350 UART echo example to test atoi/strcmp. Everything works.

    /*
     *  ======== uartecho.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART.h>

    /* Example/Board Header files */
    #include "Board.h"

    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        char        input;
        const char  echoPrompt[] = "Echoing characters:\r\n";
        UART_Handle uart;
        UART_Params uartParams;

        int val;
        char str[20];
        char str_out[40];
        char str_out1[40];
        char str_out2[40];

        /* Call driver init functions */
        GPIO_init();
        UART_init();

        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);

        /* Create a UART with data processing off. */
        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.baudRate = 115200;

        uart = UART_open(Board_UART0, &uartParams);

        if (uart == NULL) {
            /* UART_open() failed */
            while (1);
        }

        UART_write(uart, echoPrompt, sizeof(echoPrompt));
        strcpy(str, "1350");
        val = atoi(str);
        sprintf(str_out1,"String value = %s, Int value = %d \n", str, val);
        UART_write(uart, str_out1, sizeof(str_out1));

        strcpy(str, "CC");
        val = atoi(str);
        sprintf(str_out2,"String value = %s, Int value = %d \n", str, val);
        UART_write(uart, str_out2, sizeof(str_out2));
        if (0==strcmp(str_out1, str_out2)){
            sprintf(str_out,"String value is the same \n");
        }else {
            sprintf(str_out,"String value is different \n");
        }
        UART_write(uart, str_out, sizeof(str_out));


        /* Loop forever echoing */
        while (1) {
            UART_read(uart, &input, 1);
            UART_write(uart, &input, 1);
        }
    }

  • Hello Sir,
    Thanks for the help but I am not able to see the values of variables that you have printed inside sprintf() function anywhere. I am not getting the value of val and other variables. Can you please help me with this and where i can see the value of this variables.

    Thanks a lot for this information.

    Regards
    Shubham Jindal
  • It should output from the virtual COM port simulated on Windows system. You can user terminal tool, such as teraterm, to check the output and the baudrate is 115200.
  • But sir this terminal is used to see the data from UART?? How can I print the values of variables at run time?? Say in this program, you have mentioned about "int val". How can i see the value of this variable and where?
    Please help me with this Sir.

    Thanks and Regards,
    Shubham Jindal
  • If you mean teraterm, it's used to see data from UART. If you want to check variables at run time, you can set breakpoint in the code and debug/trace it.
  • Yes sir, Breakpoints. How can i use breakpoints in my program. Can you please explain this in little detail. I don't know about this. Please help me with this Sir.

    Thanks
    Shubham Jindal