吧友们大家好,大 学毕设,题目也是ZigBee的,现在遇到问题了,我用了一个GPS定位模块,现在需要写程序采集GPS连接到串口的数据,并对数据进行处理。但我现在写的程序只能读出串口的数据,但是没法处理它,请问我该怎么写呢,而且我只需读取一次串口就好,我的代码具体如下;
void rxCB(uint8 port,uint8 event)
{
rxlen = Hal_UART_RxBufLen(HAL_UART_PORT_0);
if(rxlen)
{
HalUARTRead(0,uartbuf,sizeof(uartbuf));//数据读取
// HalLedBlink(HAL_LED_1,1,50,1000);
if((uartbuf[0]==0x01))
{
// HalLedBlink(HAL_LED_2,1,50,1000);
afAddrType_t my_DstAddr;
my_DstAddr.addrMode=(afAddrMode_t)Addr16Bit;
my_DstAddr.endPoint=GENERICAPP_ENDPOINT;
my_DstAddr.addr.shortAddr = 0x0000;
AF_DataRequest(&my_DstAddr,&GenericApp_epDesc,
GENERICAPP_CLUSTERID,
sizeof(uartbuf),
uartbuf,
&GenericApp_TransID,
AF_DISCV_ROUTE,AF_DEFAULT_RADIUS);
}
}
while(1)//本来这边是打算做数据处理的,但是好像没实现我的预期想法
{
int i;
for(i=2;i++;i<=(sizeof(uartbuf)))
{
if((uartbuf[i]==0x4E))
{
J[0]=uartbuf[i-2];
J[1]=uartbuf[i];
W[0]=uartbuf[i+2];
W[1]=uartbuf[i+4];
}
else
continue;
}break;
}
}
void rxCB(uint8 port,uint8 event)
{
rxlen = Hal_UART_RxBufLen(HAL_UART_PORT_0);
if(rxlen)
{
HalUARTRead(0,uartbuf,sizeof(uartbuf));//数据读取
// HalLedBlink(HAL_LED_1,1,50,1000);
if((uartbuf[0]==0x01))
{
// HalLedBlink(HAL_LED_2,1,50,1000);
afAddrType_t my_DstAddr;
my_DstAddr.addrMode=(afAddrMode_t)Addr16Bit;
my_DstAddr.endPoint=GENERICAPP_ENDPOINT;
my_DstAddr.addr.shortAddr = 0x0000;
AF_DataRequest(&my_DstAddr,&GenericApp_epDesc,
GENERICAPP_CLUSTERID,
sizeof(uartbuf),
uartbuf,
&GenericApp_TransID,
AF_DISCV_ROUTE,AF_DEFAULT_RADIUS);
}
}
while(1)//本来这边是打算做数据处理的,但是好像没实现我的预期想法
{
int i;
for(i=2;i++;i<=(sizeof(uartbuf)))
{
if((uartbuf[i]==0x4E))
{
J[0]=uartbuf[i-2];
J[1]=uartbuf[i];
W[0]=uartbuf[i+2];
W[1]=uartbuf[i+4];
}
else
continue;
}break;
}
}