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

ble_app_uart_c losing characters

Hello again Nordic World.

We are slowly attempting to transition from the nRF51 environment to nRF52.  We are starting, not with development environment for our product, (it will remain at the 51 leve for now) but with the replacement of our nRF51 Dongles, which we use with the ble_app_uart_c code as a terminal interface to our board for testing.  We are attempt in to replace the nRF51 Dongle with the nRF52 DK.

The problem is that the ble_app_uart_c code from the 15.2 SDK, running on the 52 DK is dropping characters.   Please review the following snippets and note the alignment and missing characters which always seem to get lost in the 3rd column:

3689 4100 419 3689 4123 0 0 2 4100 4193 0 3689 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5190 4734 1
3682 4100 4193 3682 4123 -7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5191 4735 1
3682 4100 4193 3682 4123 0 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5192 4736 1
3682 4100 4193 3682 4123 0 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5193 4737 1
3682 4100 4193 3682 4123 0 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5194 4738 1
3689 4100 4193 3682 4123 7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5195 4739 1
3682 4100 4193 3682 4123 -7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5196 4740 1
3682 4100 4193 3682 4123 0 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5197 4741 1
3689 4100 4193 3682 4123 7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5198 4742 1
3682 4100 4193 3682 4123 -7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5199 4743 1
3689 4100 419 3682 4123 7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5200 4744 1
3682 4100 4193 3682 4123 -7 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5201 4745 1
3682 4100 4193 3682 4123 0 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5202 4746 1
3682 4100 4193 3682 4123 0 0 2 4100 4193 0 3682 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 5203 4747 1

Here is the exact same information as printed by the 51 Dongle under SDK 12.3:  Note the perfect alignment and no missing characters.

3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4861 4405 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4862 4406 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4863 4407 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4864 4408 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4865 4409 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4866 4410 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4867 4411 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4868 4412 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4869 4413 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4870 4414 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4871 4415 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4872 4416 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4873 4417 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4874 4418 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4875 4419 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4876 4420 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4877 4421 1
3710 4100 4193 3710 4123 0 0 2 4100 4193 0 3710 4123 0 4100 3400 0 4000 3300 0 1 1 0 0 4878 4422 1

Any ideas on where to search for and correct this problem is greatly appreciated.

Robin @ TL

Some additional information requested by stateside FAE:

The dropping is consistent in that the only characters dropped are the 16th, 17th, or possibly 18th (not know as both are spaces) in the first string sent.to each line.  However when it is dropped seems to be somewhat random.

The 52DK is connected form its u-usb connector on board to a USB-C on my computer by a short (~18") cable.

The only change is the hardware and the version of the unaltered example code running on each.

2 each 52DK's and 2 each cables have been tested.

  • On closer inspection, I am now seeing another character in differing column being replaced by a space.

  • Hello Robin,

    I don't know if I understood the 16th, 17th or 18th part, but it may be the same problem.

    Are you able to detect where in the path this information is lost? You are using the ble_app_uart_c, so I assume that the data is originally coming from another device over UART?

    Some source -> UART -> ble_app_uart -> BLE -> UART -> Computer.

    Is this correct?

    I don't know how large the chunks you are sending are, but if the entire line is sent in one message, the first character that is missing is the '3' in 4193, right? So that is the 14th character, right?

    So if you test the BLE link, that would be in the ble_nus_chars_received_uart_print() function in the ble_nus_c example, which is called from the BLE_NUS_C_EVT_NUS_TX_EVT event.

    Can you try to check whether the 4193 is missing the '3' there?

    static void ble_nus_chars_received_uart_print(uint8_t * p_data, uint16_t data_len)
    {
        ret_code_t ret_val;
    
        NRF_LOG_DEBUG("Receiving data.");
        NRF_LOG_HEXDUMP_DEBUG(p_data, data_len);
        if (p_data[12] != '3')      //p_data[12] contains the 13th element.
        {
            NRF_LOG_INFO("missing character");
        }
    
        for (uint32_t i = 0; i < data_len; i++)
        {
            ...

    Best regards,

    Edvin

  • Hello again Edvin,

    W/r/t the path the source is our custom board based on the ble_app_uart.  Our board does not use UART, so the path, as I understand it is is:

    my_board.ble_app_uart>ble>DK52.ble_app_uart_c>UART>computer.

    W/r/t missing characters, the paste function on this web page truncates whitespace, so you dont see all the problem.  Yes the first character missing is the 3 from the number 1493, in many cases it is one of the following spaces.  There are 2 spaces between each table entry, so the most common dropped characters are as I said, 16th, 17th, or 18th. Not sure about 17/18 since they are both spaces.  I have since found instances at another location where a digit is replaced by whitespace.

    Data chunk size for each transmission is 20 char including the null.  Each line is made up of several xmitted strings.

    With regard to your code to test, the data is not constant, so I cannot look for a fixed digit. I suppose I could change me code to send constant digits, but that a lot of work right now. 

    Also, where does the log message show in your code mod, the UART?

    I also want to make sure you understand that using the 51 Dongle, THERE ARE NOT PROBLEMS! So, it cannot be missing in the ble xmit, it would have to be a rcv issue in the 52DK.

    I kindly ask that you set up this test and debug, as I do not have the resource to do so easily, and I am certain that nothing in my code is causing the problem.  Can you do this please?  Here is some info on our board so you can emulate if you would:

    nRF51822 running under SDK 12.3,

    app is closely based on ble_app_uart, with string size counting, termination char detection, and a ring_buffer to resolve lost strings.  Her is a snippet of the send chars function:

    static void send_chars(const char * str)
    {
      if (connected)
      {
        uint8_t i = 0;
        while (str[i] != 0x00) 
        {
          i+=1;
        }
        tx_buffer_insert(&m_nus, (uint8_t*)str, i);
        tx_buffer_process();
      }
    }

    and the ring buffer:

    void tx_buffer_process(void)
    {
      if (m_tx_index != m_tx_insert_index)
      {
        uint32_t err_code;
        err_code = ble_nus_string_send(m_tx_buffer[m_tx_index].p_nus,
                                       m_tx_buffer[m_tx_index].p_data,
                                       m_tx_buffer[m_tx_index].length);
        if (err_code == NRF_SUCCESS)
        {
          ++m_tx_index;
          m_tx_index &= TX_BUFFER_MASK;
        }
      }
    }

    Any expeditious help you can offer is greatly appreciated. 

    As I mentioned, this code all works perfectly using and nRF51 dongle under SDK12.3. 

    We are in the process of setting up our production test workstations which, the intentions were, would each service up to 6 of our boards, each via a 52DK, for testing before final assembly.  Boards are due in next week, so I am sure you can understand my fright at not being ready at this point.  We would have continued using the 51 Dongle, but they are getting hard to find and the price is escalating because of that shortage.

    Thank you again,

    All expedience in the matter is greatly appreciated.

    Robin @ TL

  • Robin said:
    Also, where does the log message show in your code mod, the UART?

     That depends on your project settings, but in the ble_app_uart(_c) examples, the log is by default printing in the RTT Log. If you use Segger Embedded Studio, you will see these log messages in the IDE while you are debugging. If you are not debugging, or if you are using another IDE, you can use J-Link RTT Viewer.

    Is it possible for me to recreate the issue here in the office if I have an nRF52832 DK and an nRF51 dongle? Do you have the application that sends the strings that I can look for missing characters in, in addition to the application that you use on the DK?

    BR,
    Edvin

  • Hello Edvin,

    I see that somehow my response to this did not get posted, so here goes again:

    W/r/t the the IDE, I am using Keil, and not sure where to find the log with it as I have had no opportunity to use that feature as of yet.  Nor have I yet used the J-link RTT viewer. If you could give me a lead on using either of these options it would be greatly appreciated.

    W/r/t how you might be able to recreate this problem I would suggest you use a 51 based board running ble uart peripheral under SDK 12.3 and a 52 DK board ruing ble uart central under SDK 15.2 or 15.3. I am using Termite on a Windows 10 machine to view the characters sent by the peripheral.  Above are snippets of the send_chars routine and a circular buffer I am using to insure no lost groups.

    As mentioned when using the 51 dongle running the central under SDK 12.3 there are no issues and that is the only thing that changed.  The 52DK ruing the central under SDK 15.2 and 15.2 drop chars.

    Let me know what else may need from me to get moving and finding this "feature:.

    Sorry for the delay, I thought my last attempt at reply went through.

    Robin @ TL

     

Related