34 int sendCmd(
char cmd,
const char * arg);
39 struct termios options;
40 fd = open(path, O_RDWR | O_NOCTTY | O_NDELAY);
43 fcntl(fd, F_SETFL, 0);
44 tcgetattr(fd, &options);
45 options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
46 cfsetospeed (&options, B9600);
47 cfsetispeed (&options, B9600);
49 options.c_cc[VTIME]=0;
50 tcsetattr(fd, TCSANOW, &options);
55 perror(
"can't openSerial");
140 char cmdWithArg[20]={};
154 case DMB_MOVE: strcat(cmdWithArg,
"=");
155 strcat(cmdWithArg,arg);
157 case DMB_TURN: strcat(cmdWithArg,
"=");
158 strcat(cmdWithArg,arg);
161 int sizeCmd = strlen(cmdWithArg);
163 cmdWithArg[sizeCmd+1] =
'\r';
164 cmdWithArg[sizeCmd+2] =
'\0';
165 return write(
fd,cmdWithArg,strlen(cmdWithArg));
174 int taille = strlen(msg);
175 char checksum = msg[taille-2];
189 default :
return atoi(&msg[0]);
203 while((n=read(
fd,c,1)) <=0)
220 for(
int j = 0 ; j < 20 ; j++)
223 while(car !=
'\r' && car!=
'\n') {
241 int taille = strlen(msg);
242 for(i=0;i<taille;i++)
#define DMB_START_WITH_WD
Fonctions for communicating with robot.
char checkSumGO(char *msg)
int readSerial(char *msg)
#define DMB_START_WITHOUT_WD
int sendCmd(char cmd, const char *arg)
int send_command_to_robot(char cmd, const char *arg)
Envoi une commande au robot et attends sa réponse.
int open_communication_robot(const char *path)
Ouvre la communication avec le robot.
int close_communication_robot(void)
Ferme la communication avec le robot.