Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Saving array to text file using the nRF SDK v2.2.0 or higher

Hello everyone,

I am working on a bluetooth camera project using the nRF5340 DK and SDK v.2.2.0. Since the Image data is quite large, I want to store it in a Text file for further processing using matlab or python. 

I tried the following code:

 

FILE *fp = fopen("image01.txt", "w");
fwrite(framebuffer, sizeof(uint8_t), 320*320, fp);
fclose(fp);

However, it says that it does not know the fopen and fclose function, and if I have included the stdio.h:

c:\ncs\hello_world_3\src\main.c:22:20: warning: implicit declaration of function 'fopen' [-Wimplicit-function-declaration]
   22 |         FILE *fp = fopen("image01.txt", "w");
      |                    ^~~~~
c:\ncs\hello_world_3\src\main.c:11:1: note: 'fopen' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
   10 | #include <zephyr/kernel.h>
  +++ |+#include <stdio.h>

although I have already included it. I have found out that the standerd zephyr stdio.h library does not include the fopen functoion, but the sdk contains a stdio.h that does. Is there a way to include them both, although they have the same name? Or is there any other, more efficient way to store an array directly to a text file?

Thanks in advance!

Paul

Related