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.

IWR6843ISK: Uart_read() returning -2001

Part Number: IWR6843ISK

Hi Team,

I am trying to modify the level sensing demo codes for IWR68xx. The demo code uses 2 uarts - for data and commands. I am modifying the data uart to provide "on demand" data. This means that user will send some command on the Data Uart and get the data as a response. I have modified the code slightly as follows:

        unsigned char rxBuffer[1];
        int ret;
        ret = UART_read(uartHandle, rxBuffer, 1);
        printf("uart read ret: %d\n", ret);
        if(ret>0){
            printf("received byte: %c\n", rxBuffer[0]);
            switch(rxBuffer[0])
            {
            case 0x01: //send distance and magnitude data
                printf("sending data\n");
                UART_writePolling (uartHandle, crc_array, packet_size);
                UART_writePolling (uartHandle, (uint8_t*)&crc, sizeof(uint8_t));
                
            ....

"ret" variable gives value equal to -2001. I am not able to find the meaning of this code. Could you please point me to the resource for the same?

Regards,

Kamlesh

  • Hi Kamlesh,

    If you go to the doxygen documentation for the UART module, you can find a breakdown of the error codes. I found the specific module at the following location in my local SDK installation (note this location will depend on where you have installed the mmWave SDK):

    file:///C:/ti/mmwave_sdk_03_05_00_04/packages/ti/drivers/uart/docs/doxygen/html/group___u_a_r_t___d_r_i_v_e_r___e_r_r_o_r___c_o_d_e.html

    This indicates that the error you have is an invalid argument. To resolve this, you can check the arguments that you are passing into this function call, and you can also take a look at the UART source code to see exactly what is generating this error.

    Is there a reason that you are manually reading from the UART rather than using the CLI driver? I am not sure offhand how the interaction works if you read from the same UART port as the CLI driver, but I imagine that could cause issues. If you have not removed the CLI functionality, it may be easier to add a CLI command to accomplish what you are looking for. You can see an example of how to add a CLI command by looking at the Soft Reset Using CLI lab which can be found at the directory:

    <mmwave_industrial_toolbox>/labs/Fundamentals/Soft_Reset_Using_CLI

    Let me know if you have any further questions.

    Best Regards,
    Alec

  • Hi Alec,

    Thank you for the reply. 

    As I see in the html file use mentioned, I can't find the code. The file is as below:

    If I assume the error code is due to invalid arguments, I don't see any reason for that to occur. I slightly modified the data types as below as per the Uart_read() function call i.e. extern int32_t UART_read(UART_Handle handle, uint8_t *buffer, uint32_t size);

            uint8_t rxBuffer[1];
            uint32_t buffersize;
            buffersize = 1;
            int32_t ret;
            ret = UART_read(uartHandle, rxBuffer, buffersize);
            printf("uart read ret: %d\n", ret);
            if(ret>0){
                printf("received byte: %c\n", rxBuffer[0]);
                switch(rxBuffer[0])
                {
                case 0x01: //send distance and magnitude data
    

    This also gives the same error. 

    I am trying to implement a custom protocol over UART, for which I need to play with raw bytes reading and writing. Please let me know what I am missing here.

    Regards,

    Kamlesh

  • Kamlesh,

    All errors code have a module base (so as you see in your image, the error base for uart errors is -2000). At the top of the page, you will see the following: 

    So in this case, you have error -2001, which is UART base - 1, which is UART_EINVAL.

    Can you provide context on where you have inserted this code so that we can ensure that the UART instance has been already opened, and if so, what were the parameters used for the UART configuration?

    Best Regards,
    Alec

  • Alec,

    In the high_accuracy_demo_68xx project (Industrial Toolbox 10), I am modifying the mss_main.c file. When I only use the UART_WritePolling(), it works flawlessly. I can see the data on data_UART. Next, I am trying to write the Data only when it receives some command on the same Data_UART, otherwise my RTOS task will just bypass writing.

    Function: MmwDemo_transmitProcessedOutput()

    Regards,

    Kamlesh

  • Kamlesh,

    Understood. The problem here then is that the Data UART line is a TX-only line. The UART-USB bridge supports one bidirectional UART, and one Unidirectional UART connection. The error you are getting is likely indicating that there is no RX line pinmuxed to their UART handle. 

    To achieve the functionality you are looking for, here is what I would recommend:

    To disable UART output, send the command guiMonitor 0 0 0 0 0 0 via the CLI lines

    To re-enable UART output, send the command guiMonitor 1 1 0 0 0 1

    Best Regards,
    Alec