for home
This commit is contained in:
41
kx.py
Normal file
41
kx.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import protocol_kx
|
||||
import can
|
||||
import cantools
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
|
||||
K = np.zeros(protocol_kx.KX_K_COUNT)
|
||||
|
||||
|
||||
class KX:
|
||||
def __init__(self, id, value, sbl_id, can):
|
||||
K[id] = value
|
||||
self.sbl_id = sbl_id
|
||||
self.can0 = can
|
||||
|
||||
|
||||
def KXInit(self, id, value):
|
||||
K[id] = value
|
||||
|
||||
|
||||
def reset(self):
|
||||
resetMsg = can.Message(arbitration_id=0xA, data=[99, self.sbl_id], is_extended_id=False)
|
||||
self.can0.send(resetMsg)
|
||||
|
||||
|
||||
def sendK(self):
|
||||
msg = protocol_kx.CANMsgK(self.sbl_id, 0, protocol_kx.KX_FLAG_SEND, K[0])
|
||||
i = 0
|
||||
for element in K:
|
||||
msg.k = element
|
||||
msg.index = i
|
||||
i = i + 1
|
||||
messageK = can.Message(protocol_kx.KX_FLAG_SEND, data=msg, is_extended_id=False)
|
||||
self.can0.send(messageK)
|
||||
|
||||
|
||||
def writeToFlashK(self):
|
||||
msg = protocol_kx.CANMsgK(self.sbl_id, 0, protocol_kx.KX_FLAG_WRITE_REQ, K)
|
||||
messageK = can.Message(protocol_kx.KX_FLAG_READ, data=msg, is_extended_id=False)
|
||||
self.can0.send(messageK)
|
||||
Reference in New Issue
Block a user