[英]Can someone help me to understand this?
您好,我在閱讀手冊指南后嘗試獲取結果,但沒有關於 uchar、*ucbuf 的描述
有人可以幫我嗎消息校准示例
void Crc16_Ccitt(uchar *ucbuf, uchar iLen, uchar *resut_arry)
{
unsigned int crc = 0xFFFF; // initial value
unsigned int polynomial = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
for (int j = 0; j < iLen; ++j) {
for (int i = 0; i < 8; i++) {
char bit = ((ucbuf[j] >> (7-i) & 1) == 1);
char c15 = ((crc >> 15 & 1) == 1);
crc <<= 1;
if (c15 ^ bit) crc ^= polynomial;
}
}
uchar is unsigned char.
ucbuf is the message buffer.
iLen is the number of unsigned characters in the buffer
I'm guessing, that resut_arry is short for result_array.
顯示縮進代碼可能有幫助:
void Crc16_Ccitt(uchar *ucbuf, uchar iLen, uchar *resut_arry)
{
unsigned int crc = 0xFFFF; // initial value
unsigned int polynomial = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
for (int j = 0; j < iLen; ++j) {
for (int i = 0; i < 8; i++) {
char bit = ((ucbuf[j] >> (7-i) & 1) == 1);
char c15 = ((crc >> 15 & 1) == 1);
crc <<= 1;
if (c15 ^ bit) crc ^= polynomial;
}
/* missing code, that stores crc into resut_arry */
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.