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

命令函数参数问题 #29

Open
xicser opened this issue Dec 30, 2019 · 3 comments
Open

命令函数参数问题 #29

xicser opened this issue Dec 30, 2019 · 3 comments

Comments

@xicser
Copy link

xicser commented Dec 30, 2019

命令函数的参数和终端里面输入的参数的对应关系是什么?比如定义如下函数:
void shellEepromRead(u16 addr)
{
printf("%d\r\n", addr); //如:串口终端输入65580(超出u16范围),这里依然能够正常打印,
//但是定义的是u16,范围是0 ~ 65535才对。
}
其中,u16即无符号16bit的整型,但是实际使用时发现,参数addr的范围可以超过65535,即可以超过u16类型可表示数的范围。

使用的开发环境是MDK5。

@NevermindZZT
Copy link
Owner

现在所有参数都是按照寄存器的大小传的,程序里写的u16,实际传进去的是一个int

@xicser
Copy link
Author

xicser commented Dec 30, 2019

那如果在串口终端上输入一串数字如121234,那是当字符串处理还是整型处理?
建议owner把函数参数的问题在readme里面详细讲讲。

@NevermindZZT
Copy link
Owner

作为参数,字符串原则上是要加双引号的,但是这里为了方便使用,字非数字开头的参数,比如 s123456,可以识别的情况下,也会作为字符串处理,未加双引号的数字都是作为数处理的

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