Hello all
Hope you all had a great Christmas and new year
After a madly frustrating Christmas trying to get my wireless project working, I think it's time I retired my (clearly fried and useless) 51 year old brain.
I have a complicated little setup of a Mega, talking wirelessly to a Pro Mini, talking over serial to another Mega.
The links are there, and we had a lengthy discussion on this issue before Christmas about formatting the communications (using the NRFl01 module library).
The data is sent using a String. I KNOW... Strings suck. But it's the only way it 'nearly' works.
If Strings cause memory issues, is there not a way to clear the String memory back to zero/clear after you have used it?
Why has nobody ever fixed the Arduino String feature?
This was because as the command is assembled, I used the simple += method.
But, all my attempts, and literally days of Googling how to change this system to an Array based affair have proven fruitless.
You guys did give me some demo code, but it didn't work and I have not been able to fix that.
My way around this, would be to use Teensy's, as the String function works on those.
I have no doubt there are people rolling their eyes and unable to understand why I can't change the method of my communication, but I am a hobbiest with clearly limited knowledge.
For instance.... this is my current issue:
Data is requested from my CNC machine.
String DataFromCNC;
String EditedDataFromCNC;
byte StartPos;
It arrives in a String as: "Echo data blah blah blah X:100 Y:100 Z:100 blah blah";
I then search that retrieved data to find the start of the co-ords:
StartPos=DataFromCNC.indexOf('X');
EditedDataFromCNC=DataFromCNC.substring(StartPos);
This all works. But it won't now let me make the original String DataFromCNC the contents of EditedDataFromCNC.
It needs to be put back into/as the original String for the Transmit routine to send it.
You can't + them together. strcpy fails with a 'cannot convert String to char' argument.
Eh? They are both Strings... where did the char come from.
Any link to an idiots guide to using Arrays might help.
I think me posting my code will be a car crash. 3 weeks of editing has resulted in a right mess.