scara机械臂
Dependencies: MQTT SDFileSystem WIZnet_Library mbed
Fork of wmx_arm_communication by
Revision 14:6a6c6def773a, committed 2018-08-03
- Comitter:
- xmwmx
- Date:
- Fri Aug 03 10:51:17 2018 +0000
- Parent:
- 13:a6e12b4c7192
- Commit message:
- xxx
Changed in this revision
mainwmx.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/mainwmx.cpp Thu Aug 02 06:45:17 2018 +0000 +++ b/mainwmx.cpp Fri Aug 03 10:51:17 2018 +0000 @@ -65,6 +65,7 @@ bool received; bool start; bool done; +bool panduan; void rotate(int id ,int pix); void init_zero(); @@ -244,20 +245,14 @@ void on_control_cmd(const char* actuator_name, const char* control_value) { //pc.printf("Received [%s] [%s]\r\n", actuator_name, control_value); - if (strcmp(actuator_name, "move") == 0) + if (strcmp(actuator_name, "dat") == 0) { //接受到的坐标数据写入存储卡 - if(strcmp(control_value, "(255,255,255)") == 0) - { - pc.printf("received (255,255,255)\r\n"); + received=1; - fclose(fp_drawing); - } - else - { fprintf(fp_drawing, "%s", control_value); pc.printf("received %s\r\n",control_value); - } + } if (strcmp(actuator_name, "command") == 0) { @@ -299,7 +294,8 @@ //声明所有的执行器,每行一个,每个由名字、参数类型两部分组成,最后一行必须为空指针作为结尾 const char* actuators[][2] = { - "create", "", + "dat", "", + "command", "", NULL, NULL //最后一行以空指针作为结束标记 }; pc.printf("connecting...\r\n"); @@ -320,6 +316,7 @@ received=0; start=0; done=0; + panduan=0; while(1) @@ -329,13 +326,13 @@ publish_value(client, "report", "ready."); } - else if(ready&&!received) + else if(ready&&!received&&panduan==0) { pc.printf("send wait.\r\n"); fp_drawing = fopen("/sd/write.txt", "w"); pc.printf("opened\r\n"); publish_value(client, "report", "wait data."); - ready=0; + panduan=1; } else if(received&&!start) @@ -347,6 +344,7 @@ else if(start) { + fclose(fp_drawing); float x, y, z; fp_drawing = fopen("/sd/write.txt", "r"); pc.printf("reading\r\n"); @@ -361,6 +359,7 @@ received=0; start=0; done=0; + panduan=0; publish_value(client, "report", "done."); pc.printf("done.\r\n"); }