From fdcee878ea845b9aa821356dc0c51ddf973c32f9 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 18 Apr 2024 22:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0crc8=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- updata/prottcp.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/updata/prottcp.py b/updata/prottcp.py index 260c753..a01c51f 100644 --- a/updata/prottcp.py +++ b/updata/prottcp.py @@ -10,7 +10,17 @@ from PyQt5.QtCore import * - +def crc8(data:bytearray): + crc=0 + for j in range(len(data)): + crc^=data[j] + for i in range(8): + if((crc&0x01)!=0): + crc>>=1 + crc^=0x8c + else: + crc>>=1 + return crc