<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>how to make a reliable consecutive transmission over UART</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68936/how-to-make-a-reliable-consecutive-transmission-over-uart</link><description>Hello, 
 I&amp;#39;m using the following code to communicate my NRF52-DK with pc. 
 But sometimes the DK transmitting repeat data and sometimes error data is sent(missing 1 byte). 
 Especially when two peripherals connected. 
 Can somebody assist me? 
 
 
 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Jan 2021 06:43:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68936/how-to-make-a-reliable-consecutive-transmission-over-uart" /><item><title>RE: how to make a reliable consecutive transmission over UART</title><link>https://devzone.nordicsemi.com/thread/291170?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 06:43:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a42b7988-21d9-4f7d-a362-e0fe9c3acc92</guid><dc:creator>leo.lau</dc:creator><description>&lt;p&gt;Thank you so much for the suggestions.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem actually related to the event length.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hope this code helps the people with similar questions.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In sdk_config.h&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;#define NRF_SDH_BLE_GAP_EVENT_LENGTH 3&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void conn_evt_len_ext_set(bool status)
{
    ret_code_t err_code;
    ble_opt_t  opt;

    memset(&amp;amp;opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = status ? 1 : 0;

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &amp;amp;opt);
    APP_ERROR_CHECK(err_code);

    m_test_params.conn_evt_len_ext_enabled = status;
}


int main(void){
    ...
    conn_evt_len_ext_set(true);
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to make a reliable consecutive transmission over UART</title><link>https://devzone.nordicsemi.com/thread/282746?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 17:17:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52010b7b-5574-4e82-91bf-f8570c74ca5e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Adding additional BLE peripheral links are in essence just more high priority interrupts that cause more frequent pending of code execution in the application main() and interrupts. I am not sure where to begin to debug here, but adding a counter in the buffer, could make it easier to catch that the same&amp;nbsp;nrf_libuarte_async_tx() was called two times with the same counter. That could be a start to narrow it down?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to make a reliable consecutive transmission over UART</title><link>https://devzone.nordicsemi.com/thread/282644?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 12:03:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c350d86-a187-428d-b677-7e9bf28b4c90</guid><dc:creator>leo.lau</dc:creator><description>&lt;p&gt;Because the problems&amp;nbsp;is getting worse when two peripherals connected.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1&amp;nbsp;&lt;span&gt;peripheral:&lt;/span&gt;&lt;/p&gt;
&lt;table width="198"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="128"&gt;total time&lt;/td&gt;
&lt;td width="70"&gt;117.73&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;total packet&lt;/td&gt;
&lt;td&gt;11774&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;repeated packet&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CRC erorr&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2&amp;nbsp;&lt;span&gt;peripherals,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;table width="251"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="94"&gt;&lt;/td&gt;
&lt;td width="87"&gt;p1&lt;/td&gt;
&lt;td width="70"&gt;p2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;total time&lt;/td&gt;
&lt;td&gt;53.9&lt;/td&gt;
&lt;td&gt;53.58&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;total packet&lt;/td&gt;
&lt;td&gt;5393&lt;/td&gt;
&lt;td&gt;3528&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;repeated packet&lt;/td&gt;
&lt;td&gt;137&lt;/td&gt;
&lt;td&gt;862&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CRC erorr&lt;/td&gt;
&lt;td&gt;-3&lt;/td&gt;
&lt;td&gt;1830&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Receiving side is a PC running Python. It keeps checking inWaiting() and printing out the value.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think my pc is slower than a DK...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is the testing code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;import binascii

import serial
import serial.tools.list_ports as ports
import time
import sys
import threading
import queue


inputQueue = queue.Queue()


def receive_thread(com, inputQueue):
    while com:
        if com.inWaiting() &amp;gt; 0:
            line = com.readline()
            hex_str = &amp;quot;&amp;quot;
            for i in range(len(line)):
                hex_str += chr(line[i])
            print(hex_str)
            
            try:
                (int(hex_str, 16))     # check CRC 
                if len(hex_str) == 74: # check string legnth
                    inputQueue.put(hex_str)
            except ValueError:
                print(&amp;quot;ValueError&amp;quot;)


def convert_data_thread(inputQueue):
    # convert and log data in another thread
    

if __name__ == &amp;quot;__main__&amp;quot;:
    port = serial.tools.list_ports.comports()[0].device

    com = serial.Serial(port=port,
                        baudrate=460800,
                        parity=serial.PARITY_NONE,
                        stopbits=serial.STOPBITS_ONE,
                        bytesize=serial.EIGHTBITS,
                        rtscts=True,
                        timeout=1)

    if com is None:
        print(&amp;quot;cannot open serial port&amp;quot;)
        sys.exit()
        
    t1 = threading.Thread(target=receive_thread, args=[com, inputQueue])
    t1.daemon = True
    t1.start()
    convert_data_thread(inputQueue)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to make a reliable consecutive transmission over UART</title><link>https://devzone.nordicsemi.com/thread/282531?ContentTypeID=1</link><pubDate>Mon, 30 Nov 2020 17:49:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:642f6513-d38a-4f4f-a968-c825292997f5</guid><dc:creator>awneil</dc:creator><description>[quote userid="81755" url="~/f/nordic-q-a/68936/how-to-make-a-reliable-consecutive-transmission-over-uart"]&lt;p&gt;sometimes the DK transmitting repeat data and sometimes error data is sent(missing 1 byte).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;How do you know that the problems are in the DK ... ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>