[Libphidget-cvs-commits] CVS: libphidget/src/libphidget phidget.c,1.5,1.6
Status: Alpha
Brought to you by:
jstrohm
From: Jack S. <js...@us...> - 2002-09-12 02:35:18
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv3431 Modified Files: phidget.c Log Message: Ok, hope this fixes everything, was having problem because I cut and paste this code out of another example. It didn't read the serial number properly. This uses the length of the serial number to extract the serial number from the string provided by the servo. Index: phidget.c =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** phidget.c 12 Sep 2002 01:15:22 -0000 1.5 --- phidget.c 12 Sep 2002 02:35:15 -0000 1.6 *************** *** 640,645 **** if (phidgetDevice->serial == -1) { ! char buffer[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; ! char serial[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; int i = 0, j = 0; --- 640,645 ---- if (phidgetDevice->serial == -1) { ! unsigned char buffer[128] = { 0 }; ! unsigned char serial[256] = { 0 }; int i = 0, j = 0; *************** *** 649,660 **** } ! j = 0; ! if (buffer[0] == 12 && buffer[1] == 3) { ! for (i = 0; i <= 10; i++) { ! if (buffer[i + 2] >= 48 && buffer[i + 2] <= 57) { ! serial[j] = buffer[i + 2]; ! j++; ! } ! } } serial[j] = (int) NULL; --- 649,657 ---- } ! j=0; ! for (i=2;i<buffer[0];i+=2) ! { ! serial[j]=buffer[i]; ! j++; } serial[j] = (int) NULL; |