My question is very much inline with this post, however I have a more direct need to be able to split the string received from the Terminal control.
The Terminal control offers me a non-graphical means of controlling devices without the need of cluttering my display with various controls e.g. Buttons, Sliders, Menu’s, etc.
This is what I am trying to achieve:
Use the Terminal to send a string, e.g:
- R1:ON // set Relay1 to 1
- L3:5 // turn Light3 on for 5min (1000 * 60 * 5)
The Arduino Sketch will receive the following string through param.asStr() :
In the Sketch I need to split the received string on the delimiter “:”… and this is where I have difficulty getting things to work.
(Please note that my knowledge and experience with C/C++ is very limited - non-existing actually)
I have tried strtok() but have difficulty in getting the string passed into a char array. I also don’t know if the string passed conforms to a C-string ended with “/0”. I’ve tried to test this with SizeOf() but I get an error. I’ve also tried both param.asStr() and param.getBuffer(), all failed. Also tried .toCharArray which also failed with data type conversion.
Unfortunately, most (90%) of the research I’ve done is focussed on the Serial.Read(). I’ve tried to implement the same logic they use there, but things go askew the moment I try to convert the received string to a char array.
Any suggestion would greatly be appreciated.