8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
建议数据发送的时候,不要分两次发送;否则接收端用超时回调时,接收到的数据可能不完整。尽量不要分片发送。
The text was updated successfully, but these errors were encountered:
感谢,居然有人看。 static uint8_t frame_encode(upacker_inst_t packer, uint8_t *data, uint16_t size) {
uint8_t tmp[4] = {0}; uint8_t crc = 0;
if (size > 16384) { return 0; }
tmp[0] = 0x55; tmp[1] = size & 0xff; tmp[2] = (size >> 8) & 0x3f; //低14位用来保存size;header校验4位 crc = tmp[0] ^ tmp[1] ^ tmp[2]; tmp[2] |= (crc & 0x0C) << 4; //tmp[2][7:6]保存header检验[3:2] tmp[3] = 0x03 & (crc >> 4); //tmp[3][1:0]保存header校验[5:4] for (int i = 0; i < size; i++) { crc ^= data[i]; }
tmp[3] |= (crc & 0xfc); //tmp[3][7:2]保存data check[7:2] packer->send(tmp, 4); packer->send(data, size);
return 1; } 以下是我的想法: 1.这里send两次的原因是我想着节约内存,因为包头和payload不是连续的。 2.另外不存在数据不完整不存在,这个代码就是为了解决数据帧的粘包、分包,接收端不管收到多少数据都丢进来解析就行了。 3.关于这里的发送其实还有后续,还带一个双缓冲,然后丢到串口dma。这里send实际只是push到了缓存区。当然直接阻塞发送也是没问题的
Sorry, something went wrong.
不仅有人看 ,还有不少人在用了, 我fork了一下, 把c++ 的发送两次回调用动态申请内存改成了回调一次, c的两次回调, 我也没好办法,
No branches or pull requests
建议数据发送的时候,不要分两次发送;否则接收端用超时回调时,接收到的数据可能不完整。尽量不要分片发送。
The text was updated successfully, but these errors were encountered: