通过BC260Y模组想把十六进制RS485modbus数据发送云端,但是一碰到0X00就卡死,BC260Y_Senddata()请问如何解决?
int main(void)
{
u16 check_crc;
uint8_t sendata[100]={0xB1,0x15,0x00,0x51,0x13,0x2f,0x1a,0x56,0xff,0xff,0x66,0x66,0x66,0x66,0x66,0x66,0xf2,0xff,0x51};
// u8 sendata[]={"ɽ¶«ÐÇÖ¾ÖÇÄܽ»Í¨É豸ÓÐÏÞ¹«Ë¾"};
delay_init(); //ÑÓʱº¯Êý³õʼ»¯
NVIC_Configuration(); //ÉèÖÃNVICÖжϷÖ×é2:2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶
LED_Init(); //³õʼ»¯LED¶Ë¿Ú
uart_init(115200);//¿ÉÁ¬½ÓPC½øÐдòÓ¡Ä£¿é·µ»ØÊý¾Ý
Uart1_SendStr("´®¿Ú1³õʼ»¯³É¹¦£¡");
uart3_init(115200);//´®¿Ú2³õʼ»¯£¬ÓëBC260Y
IWDG_Init(7,625); //8SÒ»´Î
// while(DHT11_Init())
// {}
BC260Y_Init();//¶ÔÉ豸³õʼ»¯
BC260Y_CreateTCPSokcet();//´´½¨Ò»¸öSOCKETÁ¬½Ó
while(1)
{
check_crc = CRC16_MODBUS(sendata, 19);
sendata[20] = check_crc >> 8;
sendata[19] = (u8)(check_crc);
sendata[21]=0x1b;
sendata[22]=0x5A;
BC260Y_Senddata(22,sendata);//·¢Êý¾Ý£¬°´ÕÕ×Ö·û´®·½Ê½·¢ËÍ£¬Ò²Ö§³ÖÊ®Áù½øÖÆ
// BC260Y_Senddata("8","12345678");//·¢Êý¾Ý
BC260Y_RECData();//ÊÕÊý¾Ý
delay_ms(500);
// LED=!LED;
IWDG_Feed();//ι¹·
}
}
void BC260Y_Senddata(uint8_t *len,uint8_t *data)//×Ö·û´®ÐÎʽ
{
printf("AT+QISEND=0,%s,%s\r\n",len,data);
delay_ms(300);
while(strx==NULL)
{
strx=strstr((const char*)RxBuffer,(const char*)"SEND OK");//¼ì²éÊÇ·ñ·¢Ëͳɹ¦
delay_ms(100);
}
Uart1_SendStr(RxBuffer);
RxCounter=0;
}
void BC260Y_Senddatahex(uint8_t *len,uint8_t *data)//·¢ËÍÊ®Áù½øÖÆÊý¾Ý
{
printf("AT+QISENDEX=0,%s,%s\r\n",len,data);
delay_ms(300);
while(strx==NULL)
{
strx=strstr((const char*)RxBuffer,(const char*)"SEND OK");//¼ì²éÊÇ·ñ·¢Ëͳɹ¦
delay_ms(100);
}
Clear_Buffer();
}
如你截取的代码所示, 请使用BC260Y_Senddatahex()函数发送十六进制数, BC260Y_Senddata()是发送字符串的.
BC26哪来的BC260Y_Senddatahex()?没有这个函数。墨子的BC26才有Senddatahex(),BC260Y没有发送HEX的指令啊