Dear list, We have 10 epucks and use them simultaneous in our experiments, but are having reliablility issues in the bluetooth communication. To be able to use multiple epucks from Matlab I created a few mex-files to control them from C. But for now assume I control them using a simple C-program to control them, see the attachment. This is all under Linux. With such programs we are able to quickly control up to 7 epucks in a single piconet, also from Matlab.
But often after 2 to 500 seconds after starting a session the connections with bluetooth are dropped one after the other. At the moment I am suspecting the bluetooth chip on the epuck, and the question is whether anybody has simular experience or an idea what to do. Let me explain a bit more in detail. We are mainly concerned in moving the epucks, and are using an external camera to look how the epucks are moving. We only use the l- and d-commands to the epuck. To make it as fast as possible, I removed the replays for these commands in BTcom.c. This makes it much faster. (We could use pipelining with the other commands) Sending l- or d-commands to all epucks in a loop works perfectly, but if some delay (50 to 100 msec) is added after each round the problem arises. See the attached C-program. It is most strange that without delays everything is working perfectly. Note that there is no flow control between dsPIC and bluetooth controller LM9838, and the l- and d-commands do not replay anything. So from the perspecive of the LM9838 ONLY data is send to the epuck. For the communication it is not even relevant whether or not the LM9838 is connected to anything! So problems in communicating are in the bluetooth on the epucks or on the pc. I also tested communicating to other things than epucks (actually extra bluetooth adapters on the PC), and that works perfectly. I am almost at a point to connect a different bluetooth module to the second uart. But hopefully somebody can shed a light on this problem. Thanks in advance, Sietse Achterop University of Groningen The Netherlands
#include<unistd.h> #include<stdlib.h> #include<stdio.h> #include<string.h> #include <sys/time.h> #include <errno.h> FILE *f1,*f2,*f3,*f4; struct timeval told,t; int a,i; char *p; char x[1000]; int cleanconnection(FILE *fd) { /* printf("Nocleanconn\n"); return; */ i=fprintf(fd,"p,0,0\n"); if (i <= 0) { printf("Error code 1st writing: %d\n",i); } p=fgets(x, 500, fd); // printf("Clean1: %d chars returned: %s",(int)strlen(x),x); // als er niet "z,command .." terugkomt een reset uitvoeren? i=fprintf(fd,"p,0,0\n"); if (i <= 0) { printf("Error code 2nd writing: %d\n",i); } p=fgets(x, 500, fd); // printf("Clean2: %d chars returned: %s",(int)strlen(x),x); } FILE *btopen(char *dev) { int a=3; FILE *f; while (!(f =fopen(dev, "r+"))) { a--; printf("retry %s\n",dev); if (a==0) { printf("Opening %s failed\n",dev); exit(1); } } printf("Connected %s\n",dev); cleanconnection(f); return f; } void pt() { gettimeofday(&t, NULL); told=t; // printf("%ld.%ld\n", t.tv_sec,t.tv_usec); } int tincr ( ) { gettimeofday(&t, NULL); // printf("%ld msec.\n", (t.tv_sec - told.tv_sec)*1000+(t.tv_usec - told.tv_usec)/1000); printf("%ld sec.\n", (t.tv_sec - told.tv_sec)); told=t; } int main() { /* f1=btopen("/dev/rfcomm0"); f2=btopen("/dev/rfcomm5"); f3=btopen("/dev/rfcomm9"); */ f1=btopen("/dev/rfcomm1"); f2=btopen("/dev/rfcomm2"); f3=btopen("/dev/rfcomm3"); // for tincr. pt(); // sleep(5); pt(); a = 12000*60; while (a > 0) { a--; i=fprintf(f1,"l,0,1\n"); if (i <= 0) { printf("Write error 1: %d\n",errno); } i=fprintf(f2,"l,0,1\n"); if (i <= 0) { printf("Write error 2: %d\n",errno); } i=fprintf(f3,"l,0,1\n"); if (i <= 0) { printf("Write error 2: %d\n",errno); } usleep(50000); i=fprintf(f1,"l,0,0\n"); if (i <= 0) { printf("Write error 1: %d\n",errno); } i=fprintf(f2,"l,0,0\n"); if (i <= 0) { printf("Write error 2: %d\n",errno); } i=fprintf(f3,"l,0,0\n"); if (i <= 0) { printf("Write error 2: %d\n",errno); } usleep(50000); if (a%100 == 0) printf("%d\n",a); } tincr(); fclose(f1); fclose(f2); fclose(f3); return 0; }
_______________________________________________ E-puck-user mailing list E-puck-user@gna.org https://mail.gna.org/listinfo/e-puck-user