JS 串口 16进制数据累加和取低位
JS 串口 16进制数据累加和取低位,16进制字符串所有字节加起来,再取余
function checkEnd(str) { let itotal = 0, len = str.length, num = 0; while (num < len) { let s = str.substring(num, num + 2); itotal += parseInt(s, 16); num = num + 2; } let mode = itotal % 256; let shex = mode.toString(16); let iLen = shex.length; if (iLen < 2) { shex = "0" + shex; } return shex; }