/*--------------------------------------------------------------------*/
 int initKH3( void )
 {
   /* This is required */
   kh3_init(); 
   
   /* open various socket and store the handle in their respective pointers */
   dsPic = knet_open( "Khepera3:dsPic" , KNET_BUS_I2C , 0 , NULL );
   mot1  = knet_open( "Khepera3:mot1" , KNET_BUS_I2C , 0 , NULL );
   mot2  = knet_open( "Khepera3:mot2" , KNET_BUS_I2C , 0 , NULL );
 
   if(dsPic!=0)
   {
     if((mot1!=0)&&(mot2!=0))
     {
       initMot(mot1);
       initMot(mot2);
       return 0;
     }
     else
       return -1;
   }
 
   return -2;
 
 } 
Exemple #2
0
/*! Init mot or reset motor controller
 *
 * \param narg number of argument
 * \param larg argument array
 *
 * \return A value :
 *      - 0 if success
 *      - <0 if any error
 */
int InitMot(int narg,string *larg)
{
	int rc;
	char Buffer[MAXBUFFERSIZE];

  if(dsPic)
  {
    if((mot1!=0)&&(mot2!=0))
    {
      initMot(mot1);
      initMot(mot2);
      sprintf(Buffer,"m\r\n");
			com_send(Buffer,strlen(Buffer));
      return 0;
    }
  }
	
	return -1;
}	
/**
* \fn void ajouterAccentMot(listeCM liste, int pos, mot word, Dictionnaire* dico)
* \brief Permet d'ajouter une lettre accentuée dans un mot à une position donnée, le mot est ajouté dans la liste si il est présent dans le dictionnaire
*
* \return listeCM
*/
listeCM ajouterAccentMot(listeCM liste,int pos,mot word,Dictionnaire* dico){
    char *debut,*fin,*total;
    int i,j;
    mot wordTemp;
    debut=calloc(pos,1);
    fin=calloc(obtenirLongueur(&word)-pos,1);
    total=calloc(obtenirLongueur(&word),1);
    for (i=0;i<pos;i++)
    {
        debut[i]=word.contenu[i];
    }
    for (j=pos;j<obtenirLongueur(&word);j++)
    {
        fin[j-pos-1]=word.contenu[j];
    }
    strcpy(total,debut);
    strcat(total,"é");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"à");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"è");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"ç");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"â");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"û");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"ë");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"½");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"î");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"ï");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"ô");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"ù");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"ö");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }

    strcpy(total,debut);
    strcat(total,"-");
    strcat(total,fin);
    initMot(&wordTemp,total);
    if (estPresent(dico,wordTemp)==1)
    {
        liste=ajouterListe(wordTemp,liste);
    }
    return liste;
}