Although I consider myself a competent programmer in Real Studio, I’m the first to admit I’m a terrible C coder. One of the reasons I use Real Studio is because I don’t have to worry about the complexities of strings/character arrays, etc.
I need some help. I’m trying to control my arduino via messages sent over serial. The messages are in the format:
<Header(@)><3 letter command id><footer (!)>
E.g. to turn on digital pin 2 I’d send (SDP = Set Digital Pin):
@SDP2,1!
I haven’t got access to my actual arduino sketch at the moment (am at work) but in the SerialEvent() function I had been concatenating the incoming bytes into a string and setting a boolean flag when it’s all received. The main loop just keeps checking if this flag is set. If it is, it calls the function handleCommand().
My problem is that I don’t know how to take the command string (e.g SDP2,1) and split it into one string called ID that would contain the three letter code (in this case SDP) and an array of integers containing the passed data (in this case 2 and 1). The number of integers sent may be anything from 0 to about 10).
Could anyone help me out please?
Thanks,
FieldDoc