[componnets][pin]add pin operate command in MSH#5892
Conversation
| _hw_pin.parent.type = RT_Device_Class_Pin; | ||
| _hw_pin.parent.rx_indicate = RT_NULL; | ||
| _hw_pin.parent.tx_complete = RT_NULL; | ||
| _hw_pin.parent.type = RT_Device_Class_Miscellaneous; |
There was a problem hiding this comment.
这块为何改回到了RT_Device_Class_Miscellaneous
There was a problem hiding this comment.
抱歉,合并后只是检测了功能,没有认真的check diff, 我这个代码是很早已经在自已的项目中修改了,合并到这个分支中,没有用patch合并,是直接全文件copy,所以也了这样的问题。马上修改
| } | ||
| MSH_CMD_EXPORT(pinGet, get pin number from hardware pin); | ||
| #else | ||
| FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_get, pinGet, get pin number from hardware pin); |
There was a problem hiding this comment.
FINSH_FUNCTION_EXPORT_ALIAS 这个可以删掉了
| FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_mode, pinMode, set hardware pin mode); | ||
| #ifdef FINSH_USING_MSH | ||
| #define PINMODE_USAGE "\r\npinMode pin_xxx mode_xxx\r\n\tpin_xxx : 1\r\n\tmode_xxx : output or input\r\n" | ||
| static void pinMode(int argc, char *argv[]) |
There was a problem hiding this comment.
函数命名请参照RT-Thread编程规范修改。修改为小写字母加下划线的方式。
|
感谢,有一个问题,shell命令不要设置成大小写pinMode这样子,这个是区别大小写的,敲命令的时候还需要大小写转换很难受。都改成小写,pinmode |
其实我也不喜欢pinMode这样子的命名方式,我这是为了兼容之前Finsh的命令,要不再讨论下,看是不是这次把命名更合理些? |
|
之前finsh的C-Style模式已经停止维护并移除仓库了,因此可以直接重新命名新的MSH命令即可。 |
|
@Guozhanxin 郭老师命名这块有没有啥建议? |
弄一个统一的命令? |
|
命令就最好别用下划线了吧 |
|
@mysterywolf @Guozhanxin ,那改成这样? pin num PA16 |
|
我感觉可以,就是模式那里可能要在加几种 |
我觉得这种方式可以的 |
2. 在MSH中增加了PIN的操作命令 3. 为了方便在MSH命令中解析字符串,增加了一些字符串相关的函数
67ca7eb to
060deb2
Compare
mysterywolf
left a comment
There was a problem hiding this comment.
请等待郭老师的review意见后一起修改 感谢抽出时间提交代码
| rt_kprintf("\thelp\t: this help list\r\n"); | ||
| } | ||
|
|
||
| // e.g. MSH >pin num PA16 |
| value = rt_pin_read(pin); | ||
| if (value == PIN_HIGH) | ||
| { | ||
| rt_kprintf("pin[%d] = on\r\n", pin); |
| rt_bool_t rt_isint(char *strvalue); | ||
| int rt_strtoint(char *strvalue); | ||
| rt_bool_t rt_ishex(char *strvalue); | ||
| int rt_strtohex(char *strvalue); |
There was a problem hiding this comment.
我也很迷茫,但又没有找到更好的地方,郭老师有什么建议没?
| } | ||
| return value * sign; | ||
| } | ||
| RTM_EXPORT(rt_strtoint); |
There was a problem hiding this comment.
这些函数使用频次怎么样,有必要放在 kservice里,并且作为符号导出吗
There was a problem hiding this comment.
应该不用,我马上删除,当时看到其它函数好像都加了,没有注意这点
There was a problem hiding this comment.
请 在component/finish文件夹中创建 msh_parse.c/.h 文件,这几个函数把rt_前缀改成msh_前缀 放到这个里边去即可 @Guozhanxin
| #define rt_strlen(src) strlen(src) | ||
| #endif /*RT_KSERVICE_USING_STDLIB*/ | ||
|
|
||
|
|
| rt_bool_t msh_ishex(char *strvalue); | ||
| int msh_strtohex(char *strvalue); | ||
|
|
||
| #endif /* MSH_PARSE_H */ No newline at end of file |
| * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB | ||
| * 2021-12-20 Meco Man implement rt_strcpy() | ||
| * 2022-01-07 Gabriel add __on_rt_assert_hook | ||
| * 2022-04-29 WangQiang add some function for process arguments in MSH |
| } | ||
| } | ||
| MSH_CMD_EXPORT_ALIAS(pin_cmd, pin, pin operate command); | ||
| #endif |
There was a problem hiding this comment.
| #endif | |
| #endif /* FINSH_USING_MSH */ |
fdab60c to
b26324d
Compare
|
唔 这里好不人性 我来改一下 |
命令确实不人性化,应该是大小写通用,长度应该也不用在意前面的0,我在命令中做处理吧,我还限制在兼容之前命令的思路上,确实不好 |
|
xfwangqiang#2 请把这个合并一下 |
|
我测了一下 STM32下, PE.07和PE.7都是正确的 |
|
pin 框架这块没有什么问题,我已经测试过了 只需要把msh提示里加个. |
我看了下主线上开始支持这个rt_pin_get是在这个PR #3897 下,我可能前两年就在用这个特性了,没有太注意这里。 |
我感觉好像没有必要把这个rt_get_pin这个函数在Driver里实现了,可以直接在PIN架构里实现,实现只需要每个Driver里定义宏GET_PIN就可以了。按目前的思路,每个BSP里都要实现一遍,实现的代码也是一样的,完全可以复用。 @mysterywolf @Guozhanxin 两位你们觉得呢? |
|
这涉及到调整其他已经适配了的bsp 而且当时增加这个api的pr 是由官方提交到
…---Original---
From: ***@***.***>
Date: Sun, May 29, 2022 04:24 AM
To: ***@***.***>;
Cc: "Man, Jianting ***@***.******@***.***>;
Subject: Re: [RT-Thread/rt-thread] [componnets][pin]add pin operate command inMSH (PR #5892)
pin 框架这块没有什么问题,我已经测试过了 只需要把msh提示里加个.
我感觉好像没有必要把这个rt_get_pin这个函数在Driver里实现了,可以直接在PIN架构里实现,实现只需要每个Driver里定义宏GET_PIN就可以了,
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
pin 框架这块修改的没有什么问题,可以先合并我给你提的PR,然后如果AT32驱动不想加的话可以撤掉。 |
我点的“Close with comment”,怎么Close这个PR了,看到你reopen了,我才发现,搞得我一脸懵逼。 |
|
合并我的pR之后不要再force push了,否则我的PR会被冲掉,上一个给你提PR就没了 |
update codes
好像是origin的Master分支修改了,rebase后,就提交不到我的仓库了,只能force了 |
|
我知道原因了,在rebase origin前应该先rebase我的仓库,就是因为本地忘merge你的pr了
…---Original---
From: "Man, Jianting ***@***.***>
Date: Sun, May 29, 2022 17:02 PM
To: ***@***.***>;
Cc: ***@***.***>;"State ***@***.***>;
Subject: Re: [RT-Thread/rt-thread] [componnets][pin]add pin operate command inMSH (PR #5892)
合并我的pR之后不要再force push了,否则我的PR会被冲掉,上一个给你提PR就没了
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
|
xfwangqiang#3 你好 请把这个再合并一下就差不多了
我觉得你这个建议是对的 但是需要留到下一个PR,目前这块让driver去处理字符串确实可能会重复以及每个driver实现的都不一样。设备框架处理起来就很难受。 |
update codes
…hc32_pr * 'master' of https://github.com/RT-Thread/rt-thread: Hc32 pr (RT-Thread#6003) [add] winsock implement on windows simulator. (RT-Thread#6010) [spi device] remove _spi_bus_device_control (RT-Thread#5898) [net][lwip] Support windows simulator (RT-Thread#5993) [componnets][pin]add pin operate command in MSH (RT-Thread#5892) [device][adc] implement adc_get_vref (RT-Thread#5988) [drivers][hwcrypto] Correct function return value definition (RT-Thread#5984) [STM32][RTC] add support for STM32L0 series. (RT-Thread#5994) Fix bug when restarting and getting interrupts that are not processed. (RT-Thread#5997) [kernel][timer] fixed bug (RT-Thread#6004)
拉取/合并请求描述:(PR description)
[
以上修改,已经在at32f403a-start的BSP和开发板上验证通过。
]
以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in the submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use a web browser to visit PR, and check items one by one, and ticked them if no problem.
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up