I have copied a program (read a string - output the string) and this works fine. But That is not what I need.
I want to read the a command (including its parameters), parse it and execute that command with its parameters.
Ihave the follwing commands: (all motors are stepper-motors)
IMA (Initialise ALL motors)
IM1 (Intialise motor 1 )
IM2 (Intialise motor 2 )
IM3 (Intialise motor 3 )
IM4 (Intialise motor 4 )
IMx command "resets" motor n to its "middle / center" position.
RM1 (Read motor 1 position )
RM2 (Read motor 2 position )
RM3 (Read motor 3 position)
RM4 (Read motor 4 position)
(All stepper-motors are mechanically connected to a pot-meter again connected to a ANALOG-port).
Value will be 0 - 1023 )
SM1(value) (set motor 1 position according to value - compared to ANALOGport reading)
SM2(value) (set motor 2 position - - - - - )
SM3(value) (set motor 3 position - - - - - )
SM4(value) (set motor 4 position - - - - - )
But I have studied the code that reads a char from the PC-keyb. saves it into a buffer - repeats until inData = CR (or LF) and then writes the line to the PC-console. Its part of the ARD- library.
(I'am sitting at my LABTOP now, I dont have the code her (on this pC) - sorry !)
BUt You gave me an idea, I could use an Index-pointer (char(1) could go to buffer[1] and so on ) and then read index and test for correct char... (including digits where appropriate )...