当前位置: 技术问答>linux和unix
嵌入式linux下串口采用xmodem协议 接受不成功
来源: 互联网 发布时间:2017-03-19
本文导语: 接受时总是无法接受完整的包而超出最大次数,最后退出程序, 请问是什么原因? 怎么改? int xmodemReceive(int fd, char *dest, int destsz) { unsigned char xbuff[38]; /* 1024 for XModem 1k + 3 head chars + 2 crc ...
接受时总是无法接受完整的包而超出最大次数,最后退出程序, 请问是什么原因? 怎么改?
int xmodemReceive(int fd, char *dest, int destsz)
{
unsigned char xbuff[38]; /* 1024 for XModem 1k + 3 head chars + 2 crc + nul */
//unsigned char *p;
int bufsz, crc = 0;
unsigned char c, trychar = 'C';
unsigned char packetno = 1;
int len = 0;
int retry, retrans = MAXRETRANS;
for(;;)
{
for( retry = 0; retry
int xmodemReceive(int fd, char *dest, int destsz)
{
unsigned char xbuff[38]; /* 1024 for XModem 1k + 3 head chars + 2 crc + nul */
//unsigned char *p;
int bufsz, crc = 0;
unsigned char c, trychar = 'C';
unsigned char packetno = 1;
int len = 0;
int retry, retrans = MAXRETRANS;
for(;;)
{
for( retry = 0; retry