Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Nucleo_CaitSith_Firmware by
Diff: main.cpp
- Revision:
- 8:857b3285dc79
- Parent:
- 7:3fcb0d1c41aa
--- a/main.cpp Sat Mar 07 15:49:55 2015 +0000
+++ b/main.cpp Sat Mar 07 17:46:56 2015 +0000
@@ -100,29 +100,62 @@
//ルンバ移動指示
case 'M'://CTM+500-500
ret = true;
+
+ int left = 0;
+ int right = 0;
+
+ int length = strlen(buffer);
+ pc.printf("length:%d\n", length);
+ if(buffer[3] == 'L') {
+ left = atoi(buffer + 4);
+ pc.printf("left:%d\n", left);
- char buff[4+1];
- int temp;
- int leftWheelVelocity, rightWheelVelocity;
-
- //pc.printf("Param:%s\n", before);
- strncpy(buff, buffer + 4, 4);
- buff[4] = '\0';
- pc.printf("%s\n", buff);
- leftWheelVelocity = atoi(buff);
- pc. printf("%d\n", leftWheelVelocity);
-
- //printf("Param:%s\n", before);
- strncpy(buff, buffer + 9, 4);//(char*)buffer[3+4]
- buff[4] = '\0';
- pc. printf("%s\n", buff);
- rightWheelVelocity = atoi(buff);
- pc. printf("%d\n", rightWheelVelocity);
+ int i = 4;
+ while (i < length) {
+ i++;
+ if (buffer[i] == 'R') {
+ pc.printf("find R index:%d\n", i);
+ break;
+ }
+ }
+ int right = atoi(buffer + i+1);
+ pc.printf("right:%d\n", right);
+
+ } else {
+ ret = false;
+ break;
+ }
+
+//
+// char buff[4+1];
+// int temp;
+// int leftWheelVelocity, rightWheelVelocity;
+//
+// while (buffer + i == 'R') {
+// i++;
+// }
+//
+// //pc.printf("Param:%s\n", before);
+// strncpy(buff, buffer + 4, 4);
+// buff[4] = '\0';
+// pc.printf("%s\n", buff);
+// leftWheelVelocity = atoi(buff);
+// pc. printf("%d\n", leftWheelVelocity);
+//
+// //printf("Param:%s\n", before);
+// strncpy(buff, buffer + 9, 4);//(char*)buffer[3+4]
+// buff[4] = '\0';
+// pc. printf("%s\n", buff);
+// rightWheelVelocity = atoi(buff);
+// pc. printf("%d\n", rightWheelVelocity);
//SendData::SendData *data = new SendData(leftWheelVelocity, rightWheelVelocity);
- data.wheelVelocity[0] = leftWheelVelocity;
- data.wheelVelocity[1] = rightWheelVelocity;
+ data.wheelVelocity[0] = left;//leftWheelVelocity;
+ data.wheelVelocity[1] = right;//rightWheelVelocity;
+
+ pc. printf("%d, %d\n", data.wheelVelocity[0], data.wheelVelocity[1]);
+
base.set(&data);
