remove pedal fw (#1872)

* remove pedal fw

* little more

* one more

* and tests

* rest of it

* little more

* fix linter

* more fix
This commit is contained in:
Adeeb Shihadeh
2024-02-16 22:58:01 -08:00
committed by GitHub
parent 39671c3dd6
commit c076a9f2f6
32 changed files with 114 additions and 936 deletions

View File

@@ -13,7 +13,6 @@ from typing import Callable, List, Optional
from .base import BaseHandle, BaseSTBootloaderHandle, TIMEOUT
from .constants import McuType, MCU_TYPE_BY_IDCODE, USBPACKET_MAX_SIZE
from .utils import crc8_pedal
try:
import spidev
@@ -35,6 +34,20 @@ XFER_SIZE = 0x40*31
DEV_PATH = "/dev/spidev0.0"
def crc8(data):
crc = 0xFF # standard init value
poly = 0xD5 # standard crc8: x8+x7+x6+x4+x2+1
size = len(data)
for i in range(size - 1, -1, -1):
crc ^= data[i]
for _ in range(8):
if ((crc & 0x80) != 0):
crc = ((crc << 1) ^ poly) & 0xFF
else:
crc <<= 1
return crc
class PandaSpiException(Exception):
pass
@@ -248,7 +261,7 @@ class PandaSpiHandle(BaseHandle):
# get response
dat = spi.readbytes(rlen + 1)
resp = dat[:-1]
calculated_crc = crc8_pedal(bytes(version_bytes + resp))
calculated_crc = crc8(bytes(version_bytes + resp))
if calculated_crc != dat[-1]:
raise PandaSpiBadChecksum
return bytes(resp)