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

Sending messages to PC

Hi

I am using the SDK_16.0.0 and SDK_for_mesh_4.0.

Board: PCA10056, nRF52840.

1) I try to send strings to from the nRF to PC and then, using a python script, poll messages from the COM-Port.

I tried the UART example from the SDK16 and it worked. All the messages i send with printf() are received from my python script. 

Now I'm trying to use this printf() function in my main.c file in the experimental_lpn example from the SDK_for_mesh_4.0. The code looks like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
static void button_event_handler(uint32_t button_number)
{
switch(button_number)
{
case 0:
send_app_state(!hal_led_pin_get(BSP_LED_0));
printf("\r\nUART example started.\r\n"); //this does not work
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "test\n", button_number);
ERROR_CHECK(app_timer_start(m_state_on_timer,
HAL_MS_TO_RTC_TICKS(APP_STATE_ON_TIMEOUT_MS),
NULL));
break;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

if i don't include anything else in this main.c file, the program runs on the DevKit. However when i press the button_0, the LED goes on and my program then gets stuck in the printf() function. When I remove the printf() function, I can toggle the LED0 with button_0.

2) I then tried to edit the sdk_config.h file in experimental_lpn/include/sdk_config.h and set all the ENABLE_UART to 1. 

Fullscreen
1
2
3
4
5
6
7
#ifndef NRFX_UART_ENABLED
#define NRFX_UART_ENABLED 1
#endif
#ifndef UART_ENABLED
#define UART_ENABLED 1
#endif
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sdk_config.h

it should look similar to the sdk_config.h from the uart example. This did however not change anything in functionality.

3) Then I thought i should just include everything that's also included in the uart example:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "app_uart.h"
#include "app_error.h"
#include "nrf_delay.h"
#include "nrf.h"
#include "bsp.h"
#if defined (UART_PRESENT)
#include "nrf_uart.h"
#endif
#if defined (UARTE_PRESENT)
#include "nrf_uarte.h"
#endif
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

when i tried to build and run my code now, i get the error: Fatal error: can't create build/lpn_nrf52840_xxAA_s140_7.0.1_Debug/obj/lpn.o: Permission denied

my final main.c looks like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* Copyright (c) 2010 - 2019, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I have no idea how to proceed now. All i want is to send some strings from my LPN to my PC and read it using python (I have a functioning script to read a COM-Port).

Is there some easier way to do this where I don't have to include a hundred different .h files?

Thank you.

BR.