DataLogger + MQTT
Answer
6/5/18 11:37 AM

Hello Community,

first of all a i want to appreciate the amount of work put into the XDK DataLogger demo. Now my issue:

I want to add another feature to the demo so the data saved onto the sd card will be sent with MQTT to a broker.

I allready managed to create an interrupt handler which allows me to block the SDC_writeBackBuffer() and UpdateSensorValues() with a ButtonPress event so i'm able to start my sending routine. However I'm facing the same problem another user had in this forum:

https://xdk.bosch-connectivity.com/community/-/message_boards/message/336704

The compiler is not able to find the Serval_Mqtt.h header file. I enabled MQTT as proposed but it is still not working. Is there a way to fix this problem?

The second issue I'm facing is the following :
ERROR : region RAM overflowed with stack    DataLogger             C/C++ Problem

I assume that my code is too big for the RAM of the XDK? Is there a way to enlarge the stack or do I have to reduce my code?

Is there a way to post my code as a zip file so you guys could inspect it? I don't want to post it as plain text because this would end up in a mess.

Cheers,

Robin

 

 

 

0 (0 Votes)
RE: DataLogger + MQTT
Answer
6/5/18 1:46 PM as a reply to Robin Ziegler.
Hello Robin,

regarding the RAM Overflow, the RAM consists of two major parts. The first is the FreeRTOS heap, where all dynamic data is stored. The other part is the MCU's stack. This is where global variables are stored.

Hence, if you allocate too much in global variables, the stack will overflow with the heap. Luckily, the heap's and the stack's size are known at compile time. Hence, this situation is prevented on runtime, and instead, compilation will fail.

As a matter of fact, there should be another error message, that tells you exactly by how many bytes your application overflowed. For example, when I tried to allocate a random array consisting of 30000 Byte, I received the error message region `RAM' overflowed by 261080 bytes .

As such, there are two options: Reduce the space you require on your stack, or reduce FreeRTOS heap size. Given that the application is heavily focused on the stack, I would recommend the latter. You can reduce the heap size in your SDK at xdk110 > Common > config > FreeRTOSConfig.h on line 159:
 
#define configTOTAL_HEAP_SIZE    (( size_t )(61 * 1024 ))

Make sure not to reduce it too much. It should offer enough space for the FreeRTOS kernel, for the timer service daemon task, and for every task, queue or semaphore you additionally create. I suggest reducing it to half first, and see if that fixes your issues without causing problems on runtime.

For more information on Memory Management in FreeRTOS, please take a look at the FreeRTOS guide in the XDK Learning Section .

As for the issue with MQTT, could you please post the exact error message you get for why the header file Serval_Mqtt.h cannot be included, and the line you try to include it in?

Additionally, which Workbench version are you using?

Kind regards,
Alex
0 (0 Votes)
RE: DataLogger + MQTT
Answer
6/6/18 6:47 AM as a reply to Alexander Sawtschuk.

Hello Alex,

thanks for the quick response. I also thought that the workbench would give me an overview about the current RAM used but unfortunately i can't find the second error message you mentioned. I activated the "Show heap status" setting in order to get informations about the heap size and it seems like there is enough space to reduce it to half.

The error messages for the MQTT library are for example:
 

'MqttEvent_t' could not be resolved	XDK_Datalogger_cc.c	/DataLogger	line 293	Semantic Error
'MqttEventData_t' could not be resolved	XDK_Datalogger_cc.c	/DataLogger	line 294	Semantic Error

etc...

Altough I included the "Serval_Mqtt.h" library it seems like it can't link it to my project.

Usually i should be forwarded to the header file containing the definition of for example 'MqttEvent_t" when pressing "F3" on my keyboard but this doesn't work.

I'm using the XDK Workbench verion: 3.3.1

 

Cheers,

Robin

 

0 (0 Votes)
RE: DataLogger + MQTT
Answer
6/6/18 1:03 PM as a reply to Robin Ziegler.
Hello Robin,

unfortunately, I do not know why the number of bytes for the overflow does not show, so I can not elaborate on that.

Otherwise, keep in mind that the heap size is changed for all applications you develop in that XDK-Workbench with that particular SDK. If that poses a long term problem, you could make a backup of the SDK, and configure only this project to use the version of the SDK with reduced heap size.

I will gladly explain how to set the project's properties to that, if the need should arise.

Regarding the issue with the header-file, since the import works (and compilation would probably work as well), I think this may just be an indexing problem. For this, please right-click the project, then select Index > Rebuild and wait for the process to finish. Afterwards, the XDK-Workbench should be able to link the interface correctly.

This is cause by the fact that the XDK-Workbench itself has an indexing system for content assist and to detect errors during development before compilation. Usually, the indexing system does not automatically refresh the tags.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Alex
0 (0 Votes)
RE: DataLogger + MQTT
Answer
6/6/18 2:16 PM as a reply to Alexander Sawtschuk.

Hey Alex,

thanks for the advice! After rebuilding the indexing the header file is linked correctly.

Now I can proceed with the project.

 

Cheers,

Robin

0 (0 Votes)
RE: DataLogger + MQTT
Answer
6/7/18 9:09 AM as a reply to Robin Ziegler.
Hello Robin,

I am always glad to help and glad to hear that it is working now.

Please feel free to ask if you have any kind of further concern or question.

Kind regards,
Alex
0 (0 Votes)