我每隔10秒产生一个事件,在这个事件中用到了很多串口打印,调试发现每次只能打印到if(MYAPP_HEARTBEAT_FLAG3)中的第一个HalUARTWrite。串口调试助手显示共129个字节,后面的数据没有打印出来。请问该怎么办?
void MyApp_Heart_Check(void)
{
if(MYAPP_HEARTBEAT_FLAG1) //等于1,标识接收到了心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t7.txt=\"已入网\"",strlen("page1.t7.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t7.pco=31",strlen("page1.t7.pco=31")); HalUARTWrite(0,MyApp_end,3); }
else//其他标识未接收到心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t7.txt=\"未入网\"",strlen("page1.t7.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t7.pco=31",strlen("page1.t7.pco=31")); HalUARTWrite(0,MyApp_end,3); }
if(MYAPP_HEARTBEAT_FLAG2) //等于1,标识接收到了心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t8.txt=\"已入网\"",strlen("page1.t8.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t8.pco=31",strlen("page1.t8.pco=31")); HalUARTWrite(0,MyApp_end,3); }
else//其他标识未接收到心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t8.txt=\"未入网\"",strlen("page1.t8.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t8.pco=31",strlen("page1.t8.pco=31")); HalUARTWrite(0,MyApp_end,3); }
if(MYAPP_HEARTBEAT_FLAG3) //等于1,标识接收到了心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.txt=\"已入网\"",strlen("page1.t9.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.pco=31",strlen("page1.t9.pco=31")); HalUARTWrite(0,MyApp_end,3); }
else//其他标识未接收到心跳包
{ HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.txt=\"未入网\"",strlen("page1.t9.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.pco=31",strlen("page1.t9.pco=31")); HalUARTWrite(0,MyApp_end,3); }
if(MYAPP_HEARTBEAT_FLAG4) //等于1,标识接收到了心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t10.txt=\"已入网\"",strlen("page1.t10.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t10.pco=31",strlen("page1.t10.pco=31")); HalUARTWrite(0,MyApp_end,3); }
else//其他标识未接收到心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t10.txt=\"未入网\"",strlen("page1.t10.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t10.pco=31",strlen("page1.t10.pco=31")); HalUARTWrite(0,MyApp_end,3); }
if(MYAPP_HEARTBEAT_FLAG5) //等于1,标识接收到了心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t11.txt=\"已入网\"",strlen("page1.t11.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t11.pco=31",strlen("page1.t11.pco=31")); HalUARTWrite(0,MyApp_end,3);
}
else//其他标识未接收到心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t11.txt=\"未入网\"",strlen("page1.t11.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t11.pco=31",strlen("page1.t11.pco=31")); HalUARTWrite(0,MyApp_end,3); }
if(MYAPP_HEARTBEAT_FLAG6) //等于1,标识接收到了心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t12.txt=\"已入网\"",strlen("page1.t12.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t12.pco=31",strlen("page1.t12.pco=31")); HalUARTWrite(0,MyApp_end,3); }
else//其他标识未接收到心跳包
{
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t12.txt=\"未入网\"",strlen("page1.t12.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);
HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t12.pco=31",strlen("page1.t12.pco=31")); HalUARTWrite(0,MyApp_end,3); }
}
YiKai Chen:
看一下你uartConfig.tx.maxBufSize設置多大
Viki Shi:
数据能够收到说明串口通信没有问题,排查下buffer大小、速率、接线等问题
gaoyang9992006:
能发送部分,说明接线没问题,后面没有了,说明发送缓存超额了。修改一下。改成512试试看。
gaoyang9992006:
那个缓存大小,默认是128的,我记得是这样,好久没用过这个了,可以修改成256,512,1024试试看。
参考
wenku.baidu.com/…/c5c01620f61fb7360b4c65d9.html
user4711142:
回复 YiKai Chen:
uint16 HalUARTWriteISR(uint8 *buf, uint16 len)
{uint16 cnt;// Enforce all or none.if (HalUARTTxAvailISR() < len){return 0;}
for (cnt = 0; cnt < len; cnt++){isrCfg.txBuf[isrCfg.txTail] = *buf++;isrCfg.txMT = 0;
if (isrCfg.txTail >= HAL_UART_ISR_TX_MAX-1){isrCfg.txTail = 0;}else{isrCfg.txTail++;}
// Keep re-enabling ISR as it might be keeping up with this loop due to other ints.IEN2 |= UTXxIE;}
return cnt;
}
感觉跟HAL_UART_ISR_TX_MAX有关,我将HAL_UART_ISR_RX_MAX 设置为384仍没有改善
#if !defined HAL_UART_ISR_RX_MAX
#define HAL_UART_ISR_RX_MAX384
#endif
#if !defined HAL_UART_ISR_TX_MAX
#define HAL_UART_ISR_TX_MAXHAL_UART_ISR_RX_MAX
#endif
user4711142:
回复 YiKai Chen:
设置是uartConfig.tx.maxBufSize=512
YiKai Chen:
回复 user4711142:
设置uartConfig.tx.maxBufSize=512還是不行嗎?
user4711142:
回复 YiKai Chen:
對,還是不行。
我每次串口发送字节数小于30字节,只是连续调用了很多次HalUARTWrite。是不是应该中间有个延迟?
或者应该在某处,用一段代码把寄存器复位一下?
gaoyang9992006:
回复 user4711142:
把你的工程打包发出来,看看TI员工有没有这个板子,帮你测试一下。
user4711142:
回复 gaoyang9992006:
太大了,无法发送。
CC2530+Zstack3.0.2
options中:
SECURE=1
TC_LINKKEY_JOIN
xPOWER_SAVING
xLCD_SUPPORTED=DEBUG
NV_INIT
NV_RESTORE
xZTOOL_P1
xMT_TASK
xMT_APP_FUNC
xMT_SYS_FUNC
xMT_ZDO_FUNC
xMT_ZDO_MGMT
xMT_APP_CNF_FUNC
xLEGACY_LCD_DEBUG
MULTICAST_ENABLED=FALSE
ZCL_READ
ZCL_WRITE
ZCL_BASIC
ZCL_IDENTIFY
ZCL_SCENES
xZCL_GROUPS
HAL_LCD=FALSE
HAL_ADC=FALSE
HAL_KEY=FALSE
HAL_UART=TRUE
HAL_UART_ISR=1
HAL_UART_DMA=0函数很简单
1、
void zclGenericApp_Init( byte task_id )
{MyApp_UartInit(); //串口初始化……osal_start_timerEx(zclGenericApp_TaskID,MYAPP_AF_HEARTBEAT_EVT,10000);//每隔10秒检测一次
}
2、
uint16 zclGenericApp_event_loop( uint8 task_id, uint16 events )
{……if(events & MYAPP_AF_HEARTBEAT_EVT){MyApp_Heart_Check(); //检测,并串口输出osal_start_timerEx(zclGenericApp_TaskID,MYAPP_AF_HEARTBEAT_EVT,MYAPP_HEART_TIMES); //10秒检测一次return (events ^ MYAPP_AF_HEARTBEAT_EVT);}
……
}
3、
void MyApp_Heart_Check(void)//纯粹就是串口打印,只执行else中的语句
{if(MYAPP_HEARTBEAT_FLAG1) //等于1,标识接收到了心跳包{MYAPP_HEARTBEAT_FLAG1 = 0;HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t7.txt=\"已入网\"",strlen("page1.t7.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t7.pco=31",strlen("page1.t7.pco=31"));HalUARTWrite(0,MyApp_end,3);}else//其他标识未接收到心跳包{HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t7.txt=\"未入网\"",strlen("page1.t7.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t7.pco=63488",strlen("page1.t7.pco=63488"));HalUARTWrite(0,MyApp_end,3); } if(MYAPP_HEARTBEAT_FLAG2) //等于1,标识接收到了心跳包{MYAPP_HEARTBEAT_FLAG2 = 0;HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t8.txt=\"已入网\"",strlen("page1.t8.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t8.pco=31",strlen("page1.t8.pco=31"));HalUARTWrite(0,MyApp_end,3);}else//其他标识未接收到心跳包{HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t8.pco=63488",strlen("page1.t8.pco=63488"));HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t8.txt=\"未入网\"",strlen("page1.t8.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);}if(MYAPP_HEARTBEAT_FLAG3) //等于1,标识接收到了心跳包{MYAPP_HEARTBEAT_FLAG3 = 0;HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.pco=31",strlen("page1.t9.pco=31"));HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t9.txt=\"已入网\"",strlen("page1.t9.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);}else//其他标识未接收到心跳包{HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.pco=63488",strlen("page1.t9.pco=63488"));HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t9.txt=\"未入网\"",strlen("page1.t9.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);}if(MYAPP_HEARTBEAT_FLAG4) //等于1,标识接收到了心跳包{MYAPP_HEARTBEAT_FLAG4 = 0;HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t10.txt=\"已入网\"",strlen("page1.t10.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t10.pco=31",strlen("page1.t10.pco=31"));HalUARTWrite(0,MyApp_end,3);}else//其他标识未接收到心跳包{HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t10.txt=\"未入网\"",strlen("page1.t10.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t10.pco=63488",strlen("page1.t10.pco=63488"));HalUARTWrite(0,MyApp_end,3); }if(MYAPP_HEARTBEAT_FLAG5) //等于1,标识接收到了心跳包{MYAPP_HEARTBEAT_FLAG5 = 0;HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t11.txt=\"已入网\"",strlen("page1.t11.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t11.pco=31",strlen("page1.t11.pco=31"));HalUARTWrite(0,MyApp_end,3);}else//其他标识未接收到心跳包{ HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t11.txt=\"未入网\"",strlen("page1.t11.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t11.pco=63488",strlen("page1.t11.pco=63488"));HalUARTWrite(0,MyApp_end,3); }if(MYAPP_HEARTBEAT_FLAG6) //等于1,标识接收到了心跳包{MYAPP_HEARTBEAT_FLAG6 = 0;HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t12.txt=\"已入网\"",strlen("page1.t12.txt=\"已入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t12.pco=31",strlen("page1.t12.pco=31"));HalUARTWrite(0,MyApp_end,3);}else//其他标识未接收到心跳包{ HalUARTWrite(0,MyApp_end,3); HalUARTWrite(0,"page1.t12.txt=\"未入网\"",strlen("page1.t12.txt=\"未入网\"")); HalUARTWrite(0,MyApp_end,3);HalUARTWrite(0,"page1.t12.pco=63488",strlen("page1.t12.pco=63488"));HalUARTWrite(0,MyApp_end,3); }
}