Page 1 of 1

How to read sting from a SD card

Posted: Fri Jun 21, 2024 6:48 pm
by ChPr
Hello everybody,

I have a file on an SD card containing the following lines :

Code: Select all

1;0;1;255;261;2;499;535;3;699;816;1;936
2;1;3;1440
3;551;0;671;738;2;858;0;1;276
4;399;2;519;0;3;120;628;1;1284
5;548;3;668;744;2;864;856;1;976;1022;0;1142
6;499;3;688;141;1;359;759;0;1434
How to do to read this file to get each line in a différent String. for example, if I have :

Code: Select all

String FP[6];
I want to get :

Code: Select all

FP[0] = 1;0;1;255;261;2;499;535;3;699;816;1;936
FP[1] = 2;1;3;1440
FP[2] = 3;551;0;671;738;2;858;0;1;276
FP[3] = 4;399;2;519;0;3;120;628;1;1284
FP[4] = 5;548;3;668;744;2;864;856;1;976;1022;0;1142
FP[5] = 6;499;3;688;141;1;359;759;0;1434
Sincerely.

Pierre.

Re: How to read string from a SD card

Posted: Fri Jun 21, 2024 8:44 pm
by STM32ardui
?
Do you have any specific questions?

Re: How to read sting from a SD card

Posted: Fri Jun 21, 2024 11:23 pm
by GonzoG
Read one character (1 byte) until end of line is reached. Usually line ends with "\r", "\n" or "\r\n" characters or end of file, but there can be other characters used to end a line:
https://en.wikipedia.org/wiki/Newline

Re: How to read sting from a SD card

Posted: Sat Jun 22, 2024 7:07 am
by ChPr
GonzoG wrote: Fri Jun 21, 2024 11:23 pm Read one character (1 byte) until end of line is reached. Usually line ends with "\r", "\n" or "\r\n" characters or end of file, but there can be other characters used to end a line:
https://en.wikipedia.org/wiki/Newline
Thank you. I was wrong because I used "\n\r" instead of "\r\n".

Sincerely.

Pierre.