Hi,
My programm is advancing but i have some problems.
To recuperate letters from the terminal (with serial port), i use the fonction
int read_chain(int argc,char *params[])
In my principal programm (
[quote]int main (int argc,char *params[]) [/quote])
i use this fonction to activate some actions, like a motor :
[code]
int read_chain(int argc,char *params[])
{
int i;
for (i=1; i<argc;i++) //Boucle de test des caratères envoyés.
{
if(strcmp(params[i],"-motor")==0)
{
printf("\r\n°°°°moto activation°°°°\r\n");
motor=1;
goto ok;
}
}
erreur : printf("Bad command\r\n");
return 0;
ok : printf("Make Command\r\n");
return 1;
}[/code]
My principal programm :
[code]
int main (int argc,char *params[])
{
if (read_chain(argc,params))
{
if ( OpenDevice(0)<0 )
{
printf(“Could not open the k8055 (port:0)\n”);
return (-1);
}
else
{
if(motor==1)
{
WriteAllDigital(1); //Activation
printf("Motor ON\r\n");
}
CloseDevice();
}
}
return 0;
}[/code]
This programm does’nt have problems, but i want to have a confirmation of the motor’s activation. So, to activate the motor, i want user write in terminal : “k8055 -motor”
then a sentence tell him : “be carefull ,this command will activate the motor. Send -ok to confirm”.
Then, if the user write “-ok”, the motor start, but if the user doesn’t write “-ok”, the motor doesn’t start.
I hope you will understand my request.
Thank’s.