Go Down

Topic: how do I do? for transforms string (Read 695 times) previous topic - next topic


Good morning.
I started with a mega 2560 and a shield W5100.
I am a device that sends data through a com port.
data looks like this:

$ Préchauffage;0008;1;1;zst;Kesseltemp.;0077;2;2;°C;Abgastemp.;0049;3;1;°C;Abgastemp S;0059;11;1;°C;Kesselstrg ;0008;4;1;%;Primärluft ;0000;5;1;%;Rest O2 ist;0207;6;10;%;O2 Regler  ;0100;7;1;%;Sekundärluft;0000;8;1;%;Saugzug Soll;0035;9;1;%;Saugzug Ist;1134;10;1;U;Einschub Ist;0000;12;1;%;O2 Regler Pell ;0035;13;1;%;Füllstand: ;19285;14;207;%;Ansauggeschw.;0193;15;100;m/s;Strom Austrags;1590;16;1000;A;Fühler 1;0081;17;2;°C;Kesselsoll ;0083;18;2;°C;Pufferoben ;0000;20;2;°C;Pufferunten ;0000;21;2;°C;Pufferpumpe ;8192;22;1;%;Boiler 1;0101;23;2;°C;Vorlauf 1;0076;24;2;°C;Vorlauf 2;0076;25;2;°C;HK Pumpe 1;0001;26;1; ;HK Pumpe 2;0001;27;1; ;Aussentemp;0017;28;2;°C;Kollektortemp;0000;29;2;°C;Betriebsstunden;0875;30;1;h;Fehler;Kein Fehler ;99;1; ;

and i want to perform it to :

Abgastemp S;0059;11;1;°C;
Kesselstrg ;0008;4;1;%;
Primärluft ;0000;5;1;%;
Rest O2 ist;0207;6;10;%;
O2 Regler  ;0100;7;1;%;
Saugzug Soll;0035;9;1;%;
Saugzug Ist;1134;10;1;U;
Einschub Ist;0000;12;1;%;
O2 Regler Pell ;0035;13;1;%;
Füllstand: ;19285;14;207;%;
Strom Austrags;1590;16;1000;A;
Fühler 1;0081;17;2;°C;
Kesselsoll ;0083;18;2;°C;
Pufferoben ;0000;20;2;°C;
Pufferunten ;0000;21;2;°C;

some body say me:
Each line has 5 ';' but unfortunately there is no clear indication for ends of lines.  I would suggest that you keep a counter 0..4 for the ';' characters.  Each time a ';' passes, change it to a ',' and increment the counter.  If the counter is 5, set it to 0 and send a newline ('\n').  If you see a % set the counter to 4.  That will re-synchronize the lines if any ';' gets added or lost in transmission.

I know when I do I count on a BP support but there!
if I understand correctly, I must count the number of ';' before being changed to ','
how do I do? some ideas or leads to follow?
thank you


Show the code that you are currently using.

Parsing data is very straightforward, if you are collecting and storing it appropriately. If you are not, then it is nearly impossible.
The art of getting good answers lies in asking good questions.


Do you simply want the Arduino to consume that input on serial and emit it on Serial with the newlines added? If so, John pretty much gave you the answer, although I'm puzzled by the need to transform semicolons to commas.

Read it character by character and count the semicolons you receive. Echo the characters as they come in, but for every 5th semicolon, emit a newline after it too.


sorry for my english I'm french and I google to translate desserts

for now I serialdataportlogger of desserts for the donnnées recorded on a SD, but at that moment that are not my goal!

my serial port and sends me the data I have as I do see, and I want to understand how to format.

I was told "string index" ...

I think not!

thank you!

for information:
this is for communication between arduino and Froling P4, heating pellets

Go Up