ModbusRTU协议栈漏发送最后一个字节

发布于 2017-09-27 16:56:25
线程代码:
static void rt_thread_entry3(void* parameter)
{
eMBErrorCode err;
err = eMBInit(MB_RTU, 0x01, 1,115200, MB_PAR_NONE );
if(MB_ENOERR != err){
rt_kprintf("eMBInit fail...
");
goto suspend;
}
eMBEnable();
while (1)
{
err = eMBPoll();
if(MB_ENOERR != err){
rt_kprintf("eMBPoll states error...
");
goto suspend;
}
}
suspend:
rt_thread_suspend(rt_thread_self());
}



finsh/>:
| /
- RT - Thread Operating System
/ | 2.1.0 build Sep 27 2017
2006 - 2016 Copyright by rt-thread team
0, 0x00000000
finsh >list_thread()
thread pri status sp stack size max used left tick error
-------- ---- ------- ---------- ---------- ---------- ---------- ---
tshell 0x14 ready 0x0000008c 0x00000800 0x000001b0 0x00000005 000
slave trans 0x0a suspend 0x000000a8 0x00000200 0x000000a8 0x00000005 000
tidle 0x1f ready 0x00000058 0x00000400 0x00000058 0x0000000f 000
mb 0x05 suspend 0x000000c0 0x00000400 0x00000124 0x00000003 000
op 0x0b suspend 0x00000088 0x00000400 0x0000014c 0x00000005 000
led 0x19 suspend 0x00000078 0x00000100 0x00000078 0x00000005 000
0, 0x00000000
finsh >list_timer()
timer periodic timeout flag
-------- ---------- ---------- -----------
tshell 0x00000000 0x00000000 deactivated
slave timer 0x00000001 0x00000002 deactivated
slave trans 0x00000000 0x00000000 deactivated
tidle 0x00000000 0x00000000 deactivated
mb 0x00000000 0x00000000 deactivated
op 0x00000032 0x000a8658 activated
led 0x000000fa 0x000a865b activated
current tick:0x000a865b
0, 0x00000000
finsh >list_device()
device type ref count
-------- -------------------- ----------
tm16xx Character Device 0
timer0 Timer Device 0
spi30 SPI Device 0
spi3 SPI Bus 0
spi10 SPI Device 0
spi1 SPI Bus 0
pin Miscellaneous Device 0
uart1 Character Device 2
0, 0x00000000
finsh >list_mutex()
mutex owner hold suspend thread
-------- -------- ---- --------------
spi10 (NULL) 0000 0
spi3 (NULL) 0000 0
spi1 (NULL) 0000 0
0, 0x00000000
finsh >list_event()
event set suspend thread
-------- ---------- --------------
slave event 0x00000000 001:mb
slave event 0x00000000 001:slave trans
0, 0x00000000
finsh >


运行结果:
000252-Tx:01 03 00 00 00 01 84 0A
000253-Rx:01 03 00 00 00 01 84
000254-Tx:01 03 00 00 00 01 84 0A
000255-Rx:01 03 00 00 00 01 84
000256-Tx:01 03 00 00 00 01 84 0A
000257-Rx:01 03 00 00 00 01 84
000258-Tx:01 03 00 00 00 01 84 0A
000259-Rx:01 03 00 00 00 01 84
000260-Tx:01 03 00 00 00 01 84 0A
000261-Rx:01 03 00 00 00 01 84


一些疑问:
是否跟使用UART1做为CONSOLE有关?
只有一个外端子RS232接口,有没有好方法用一个接口,实现多种功能,且不互相干扰呢?

查看更多

关注者
0
被浏览
1.6k
5 个回答
aozima
aozima 2017-09-27
拒绝白嫖,拒绝键盘侠!
用485? 检查一下是否往DR写完数据就直接切了方向?
此时最后一字节才刚开始发送第一个位。

所以驱动里面要等TC(发送完成)才能切方向,
你可以看下有些BSP的更新。
songshiqun2010
songshiqun2010 2017-09-28
STM32F407ZE。这个问题应该跟Finsh回显有关,我换个串口试试。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览