This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Cannot read to terminal from UART

Hello,

I am running the UART app example in SDK 0.9.1 with the nRF52 and PCA 10036. I am using putty to send and receive messages, as well as the nRF UART v2.0 app for Android to receive the data and send data back. Also, I am compiling using Keil and the s132 softdevice.

After I flash the example project and connect with the android app, I can send messages from the UART app through the COM setup and read the output on putty. But when I try to send messages through putty, the text does not appear in the terminal, nor does it send to my phone. So I can receive data in putty, but I cannot send data from putty. I also tried using realterm, but still could not send data from real term.

Any commentary is appreciated. Thanks in advance.

Parents
  • Hi

    When I try it I have to input 20 characters in RealTerm in order to have the data sent to the Android phone. That is because the ble_app_uart application will first send the BLE packet when 20 bytes are received on the UART, specified by the BLE_NUS_MAX_DATA_LEN constant. This is done in line 400 in main.c in the uart_event_handle function. I can set a breakpoint there and it is hit whenever I input a character in RealTerm.

    If I however modify the code to make the data packet be sent whenever a "carrier return" is received, then a packet is sent whenever "Enter" is pressed in RealTerm, i.e. input "abc" then press "enter" and then the three characters are seen in the nRF UART v2.0 app.

    The carrier return has hex code 0x0D but can be detected with \r also in C. So the code is now:

        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;
    
            if ((data_array[index - 1] == '\r') || (index >= (BLE_NUS_MAX_DATA_LEN)))
            {
                err_code = ble_nus_string_send(&m_nus, data_array, index);
                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }
                
                index = 0;
            }
            break;
    
  • Thank you! That worked perfectly once i powercycled my board

Reply Children
No Data
Related