cleanup pedal crc
old-commit-hash: 23e8ad73979735479131dfb303e249b861829468
This commit is contained in:
@@ -165,20 +165,6 @@ def common_fault_avoidance(fault_condition: bool, request: bool, above_limit_fra
|
||||
return above_limit_frames, request
|
||||
|
||||
|
||||
def crc8_pedal(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
|
||||
|
||||
|
||||
def make_can_msg(addr, dat, bus):
|
||||
return [addr, 0, dat, bus]
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from opendbc.can.packer import CANPacker
|
||||
from opendbc.can.parser import CANParser
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp
|
||||
from openpilot.selfdrive.car import crc8_pedal
|
||||
from openpilot.tools.sim.lib.common import SimulatorState
|
||||
|
||||
|
||||
@@ -55,8 +54,6 @@ class SimulatedCar:
|
||||
"INTERCEPTOR_GAS": simulator_state.user_gas * 2**12,
|
||||
"INTERCEPTOR_GAS2": simulator_state.user_gas * 2**12,
|
||||
}
|
||||
checksum = crc8_pedal(self.packer.make_can_msg("GAS_SENSOR", 0, values)[2][:-1])
|
||||
values["CHECKSUM_PEDAL"] = checksum
|
||||
msg.append(self.packer.make_can_msg("GAS_SENSOR", 0, values))
|
||||
|
||||
msg.append(self.packer.make_can_msg("GEARBOX", 0, {"GEAR": 4, "GEAR_SHIFTER": 8}))
|
||||
|
||||
Reference in New Issue
Block a user