增加选job指令的参数解析
authorkyz <kongyuzhong@google.com>
Thu, 18 Dec 2025 09:43:22 +0000 (17:43 +0800)
committerkyz <kongyuzhong@google.com>
Thu, 18 Dec 2025 09:43:22 +0000 (17:43 +0800)
20240801完整版/扳手下位机软件/cpbs-202103-20240423/APP/wifi.c
20240801完整版/扳手下位机软件/cpbs-202103-20240423/APP/wifi.h
20240801完整版/扳手下位机软件/cpbs-202103-20240423/test/test.py

index 6f663eda7684c3ff6565c3c91a900b230ce1bd23..b74dbbf8385031bba543bd1b3383021180f99937 100644 (file)
@@ -32,7 +32,6 @@ typedef struct{
 
 static wrench_srv_t g_srv;
 
-
 // ÃüÁî½âÎöÏà¹Ø¶¨Òå
 typedef struct {
     char mid[5];      // ÃüÁîID£¬ÈçRSVI¡¢RSTSµÈ
@@ -40,6 +39,7 @@ typedef struct {
     char sn[11];      // ÐòÁкÅ
     char tg[3];       // ×éºÅ
     char* params;     // ÆäËû²ÎÊý
+    rssp_cmd_data_t job;
 } tcp_command_t;
 
 // ÏìÓ¦Êý¾Ý¶ÓÁÐ
@@ -130,6 +130,209 @@ static void wifi_debug(const char *fmt, ...)
        return;
 }
 
+static int parse_rssp_parameter( tcp_command_t* cmd, char* params )
+{
+    char* token;
+    char* next_token;
+
+    // ½âÎöJobID    Job±àºÅ   01-250
+    token = strtok_r(params, ";", &next_token);
+    if (token) {
+        strncpy(cmd->job.JobID, token, 7);
+        cmd->job.JobID[7] = '\0';
+    } else {
+        return -1;
+    }
+
+    // ½âÎöJobName  JobÃû×Ö   "Pset"
+    token = strtok_r(NULL, ";", &next_token);
+    if (token) {
+        strncpy(cmd->job.JobName, token, 15);
+        cmd->job.JobName[15] = '\0';
+    } else {
+        return -1;
+    }
+    // ½âÎöJob Strategy  Å¡½ô²ßÂÔ£ºTC:0 TC_AM:1 AC_TM:2
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.Strategy = atoi(token);
+        }else{
+            cmd->job.Strategy = 0;
+        }
+    } else {
+        return -1;
+    }
+
+       // Rotation;     //·½Ïò£ºCW:0 CCW:1 Auto:2
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.Rotation = atoi(token);
+        }else{
+            cmd->job.Rotation = 0;
+        }
+    } else {
+        return -1;
+    }
+       // StartTorque;  //ÆðʼŤ¾Ø
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.StartTorque = atoi(token);
+        }else{
+            cmd->job.StartTorque = 0;
+        }
+    } else {
+        return -1;
+    }
+       // TorqueMin;    //Ť¾ØÏÂÏÞ
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.TorqueMin = atoi(token);
+        }else{
+            cmd->job.TorqueMin = 0;
+        }
+    } else {
+        return -1;
+    }
+       // TorqueTarget; //Ä¿±êŤ¾Ø
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.TorqueTarget = atoi(token);
+        }else{
+            cmd->job.TorqueTarget = 0;
+        }
+    } else {
+        return -1;
+    }
+       // TorqueMax;    //Ť¾ØÉÏÏÞ
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.TorqueMax = atoi(token);
+        }else{
+            cmd->job.TorqueMax = 0;
+        }
+    } else {
+        return -1;
+    }
+       // StartAngle;   //Ť¾ØÃż÷£¬¿ªÊ¼¼Æ½Ç¶È
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.StartAngle = atoi(token);
+        }else{
+            cmd->job.StartAngle = 0;
+        }
+    } else {
+        return -1;
+    }
+       // AngleMin;     //½Ç¶ÈÏÂÏÞ
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.AngleMin = atoi(token);
+        }else{
+            cmd->job.AngleMin = 0;
+        }
+    } else {
+        return -1;
+    }
+       // AngleTarget;  //½Ç¶ÈÄ¿±êÖµ
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.AngleTarget = atoi(token);
+        }else{
+            cmd->job.AngleTarget = 0;
+        }
+    } else {
+        return -1;
+    }
+       // AngleMax;     //½Ç¶ÈÉÏÏÞ
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.AngleMax = atoi(token);
+        }else{
+            cmd->job.AngleMax = 0;
+        }
+    } else {
+        return -1;
+    }
+       // BatchSize;    //´ÎÊý
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.BatchSize = atoi(token);
+        }else{
+            cmd->job.BatchSize = 0;
+        }
+    } else {
+        return -1;
+    }
+       // CycleEndTime; //Ñ­»·µÈ´ýʱ¼ä
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.CycleEndTime = atoi(token);
+        }else{
+            cmd->job.CycleEndTime = 0;
+        }
+    } else {
+        return -1;
+    }
+       // Distance;     //²¹³¥³¤¶È mm
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.Distance = atoi(token);
+        }else{
+            cmd->job.Distance = 0;
+        }
+    } else {
+        return -1;
+    }
+       // Counter;      //¼ÆÊýģʽ£º0£ºOK 1:OKNOK
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.Counter = atoi(token);
+        }else{
+            cmd->job.Counter = 0;
+        }
+    } else {
+        return -1;
+    }
+       // Repeat;       //ģʽ 0£ºLock,1:Repeat
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.Repeat = atoi(token);
+        }else{
+            cmd->job.Repeat = 0;
+        }
+    } else {
+        return -1;
+    }
+       // Repair;       //·µÐÞ´ÎÊý£º0-9
+    token = strtok_r(NULL, ";", &next_token);
+    if (token ){
+        if( strlen(token) > 0 ) {
+            cmd->job.Repair = atoi(token);
+        }else{
+            cmd->job.Repair = 0;
+        }
+    } else {
+        return -1;
+    }
+
+    return 0;
+}
+
 // ÃüÁî½âÎöº¯Êý
 static int parse_tcp_command(const char* data, int len, tcp_command_t* cmd)
 {
@@ -185,9 +388,9 @@ static int parse_tcp_command(const char* data, int len, tcp_command_t* cmd)
         cmd->tg[0] = '\0';
     }
 
-    // ±£´æÊ£Óà²ÎÊý
-    cmd->params = next_token;
-
+    if( strcmp( cmd->mid, "RSSP" ) == 0 ){
+        parse_rssp_parameter( cmd, next_token );
+    }
     return i;
 }
 
index d6a9d24d6ca8e1e3051182a1bdd916d98d3553f0..8945704afa0e393482ebd811cde046ef4c37ee5c 100644 (file)
@@ -70,7 +70,7 @@ typedef struct{
 | Repair       | 0         | ·µÐÞ´ÎÊý£º0-9                        |
 */
 
-       uint16_t JobID;        //Job±àºÅ   01-250
+       char    JobID[8];        //Job±àºÅ   01-250
        char    JobName[16];   //JobÃû×Ö   "Pset"
        uint16_t Strategy;     //Å¡½ô²ßÂÔ£ºTC:0 TC_AM:1 AC_TM:2
        uint16_t Rotation;     //·½Ïò£ºCW:0 CCW:1 Auto:2
index ef3e5e9d655307b095cb0d1ea1998a45b25e7964..0190e0c43dc0f4caaeeb44e8574edc1f39171455 100644 (file)
@@ -400,8 +400,8 @@ class WiFiClientApp(QMainWindow, Ui_WiFiClientApp):
         ver = self.line_VER.text()
         sn = self.line_SN.text()
         tg = self.line_TG.text()
-        server = self.line_JobID.text()
-        job = self.line_JobName.text()
+        job_id = self.line_JobID.text()
+        job_name = self.line_JobName.text()
 
         # 获取参数值
         strategy = str(self.combo_Strategy.currentIndex())
@@ -417,11 +417,16 @@ class WiFiClientApp(QMainWindow, Ui_WiFiClientApp):
         param6 = self.line_AngleMin.text()
         param7 = self.line_AngleTarget.text()
         param8 = self.line_AngleMax.text()
-        param9 = self.line_BatchSize.text()
-        param10 = self.line_Repair.text()
-
-        params = [server, job, strategy, rotation, cycle_end_time, repeat,
-                  param1, param2, param3, param4, param5, param6, param7, param8, param9, param10]
+        batch_size = self.line_BatchSize.text()
+        repair = self.line_Repair.text()
+        distance = self.line_Distance.text()
+        counter = self.line_Counter.text()
+
+        params = [job_id, job_name, strategy, rotation,
+                  param1, param2, param3, param4,
+                  param5, param6, param7, param8,
+                  batch_size, cycle_end_time, distance, counter,
+                  repeat, repair  ]
         self.send_command(mid, ver, sn, tg, params)
 
     def closeEvent(self, event):