Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于在shell中传递AT指令参数时不合理的参数解析 #32

Open
EtcFly opened this issue Jan 10, 2020 · 2 comments
Open

关于在shell中传递AT指令参数时不合理的参数解析 #32

EtcFly opened this issue Jan 10, 2020 · 2 comments

Comments

@EtcFly
Copy link

EtcFly commented Jan 10, 2020

使用shell做AT调试时发现shell中使用,和"字符会被认定为参数分隔符,不知道作者在设计的时候这个是基于什么考虑,但是个人认为貌似不太合理,比如传递一个
AT AT+CIPOPEN=0,"114.114.114.114",1883,4001
此类参数时,shell自动分解成多个参数,如

AT 
AT+CIPOPEN=0
114.114.114.114
1883
4001

这就曲解了原本参数传递的意义,一次建议使用空格做分割符而不是,和“,基于原代码shellEnter函数我做了如下修改

for (unsigned short i = 0; i < shell->length; i++)
  {
      if ((quotes != 0 ||
          (*(shell->buffer + i) != ' ' &&
          *(shell->buffer + i) != '\t')) &&
       //   *(shell->buffer + i) != ',' &&
          *(shell->buffer + i) != 0)
      {
//            if (*(shell->buffer + i) == '\"')
//            {
//                quotes = quotes ? 0 : 1;
//            #if SHELL_AUTO_PRASE == 0
//                *(shell->buffer + i) = 0;
//                continue;
//            #endif
//            }
          if (record == 1)
          {
              shell->param[paramCount++] = shell->buffer + i;
              record = 0;
          }
          if (*(shell->buffer + i) == '\\' &&
              *(shell->buffer + i) != 0)
          {
              i++;
          }
      }
@NevermindZZT
Copy link
Owner

字符串参数使用双引号包括进去,字符串中包含双引号字符的,使用\转义,逗号作为分隔符是因为原先和另一个shell的兼容

@EtcFly
Copy link
Author

EtcFly commented Jan 10, 2020

字符串参数使用双引号包括进去,字符串中包含双引号字符的,使用\转义,逗号作为分隔符是因为原先和另一个shell的兼容

建议保持与linux的shell兼容的语法规则, 一方面大多数人习惯于linux下shell语法,另一方面就是如果使用代码中的规则,没有相应的文档说明的话,很多人可能就比较迷惑了。就像RTT的FINSH,很多时候都是和linux表示兼容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants