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

Sending UART data resets device SDK-14

Hello,

I'm trying to use examples/ble_peripheral/ble_app_uart with SDK-14 and NRF52 DK (pca10040).

The test case is very simple, I use python script to write data to /dev/ttyACM0, the data is splitted into chunks of predefined size. Newline character is appended to each chunk. On the other side I open nRF Connecitivity app on Android and I connect to the dev kit, enable notifications on TX characteristic and wait for the data to come. (I start the script after notifications are enabled)

This is the RTT output I get after starting the test script:

Process: JLinkExe
<warning> nrf_sdh_ble: RAM start should be adjusted to 0x20002760.
<warning> nrf_sdh_ble: RAM size should be adjusted to 0xD8A0.
<info> app: UART Start!
<info> app: Connected
<error> ble_gatt: sd_ble_gap_data_length_update() (request) on connection 0x0 returned unexpected value 0x13.
<info> app: Data len is set to 0x3D(61)
<error> app: Fatal

test.py:

#!/usr/bin/env python2.7

import base64
import serial
from time import sleep

CHUNK_SIZE=10

def chunkstring(string, length):
    return (string[0+i:length+i] for i in range(0, len(string), length))


lorem = '''
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum ornare purus a egestas. Proin blandit diam erat. Ut vitae orci luctus lacus accumsan vehicula feugiat a leo.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum ornare purus a egestas. Proin blandit diam erat. Ut vitae orci luctus lacus accumsan vehicula feugiat a leo.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum ornare purus a egestas. Proin blandit diam erat. Ut vitae orci luctus lacus accumsan vehicula feugiat a leo.
'''

encoded_string = ''.join('{:02x}'.format(ord(c)) for c in str(lorem))
chunks = list(chunkstring(encoded_string, CHUNK_SIZE))

with serial.Serial('/dev/ttyACM0', baudrate=115200, rtscts=True) as ser:
    for c in chunks:
        c += '\n'
        ser.write(c)
        print(c)

I noticed that the test works if sleep(1) is added to the writing loop.

Related