This commit is contained in:
2021-07-07 14:07:58 +03:00
parent e9c0b28b39
commit e17a82acf2
2 changed files with 6 additions and 6 deletions

11
kx.py
View File

@@ -49,7 +49,7 @@ class KX:
def writeToFlashK(self): def writeToFlashK(self):
messageK = can.Message(arbitration_id=0x2BB, data=[self.sbl_id, 0, 0, messageK = can.Message(arbitration_id=0x2BB, data=[self.sbl_id, 0, 0,
protocol_kx.KX_FLAG_WRITE_REQ], is_extended_id=False) protocol_kx.KX_FLAG_WRITE_REQ, 0, 0, 0, 0], is_extended_id=False)
try: try:
self.can0.send(messageK) self.can0.send(messageK)
time.sleep(0.01) time.sleep(0.01)
@@ -59,10 +59,9 @@ class KX:
def send_test_source_enable(self, enabaled): def send_test_source_enable(self, enabaled):
messageK = can.Message(arbitration_id=0x2BB, data=[self.sbl_id, protocol_kx.KDescription.K_TEST_SOURCES_ENABLED, 0, ba = bytearray(struct.pack("f", enabaled))
protocol_kx.KX_FLAG_SEND, 0, 0, 0, enabaled], is_extended_id=False) messageK = can.Message(arbitration_id=0x2BB, data=[self.sbl_id, protocol_kx.KDescription.K_TEST_SOURCES_ENABLED.value, 0,
protocol_kx.KX_FLAG_SEND, ba[0], ba[1], ba[2], ba[3]], is_extended_id=False)
self.can0.send(messageK) self.can0.send(messageK)
self.sendK() self.sendK()
self.writeToFlashK() self.writeToFlashK()
time.sleep(0.1)
self.reset()

View File

@@ -7,6 +7,7 @@ import os
can0 = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000) can0 = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000)
KXLOX = kx.KX(protocol_kx.KDescription.K_TEST_SOURCE_2_SIGLVL.value, 950, 255, can0) KXLOX = kx.KX(protocol_kx.KDescription.K_TEST_SOURCE_2_SIGLVL.value, 950, 255, can0)
KXLOX.send_test_source_enable(0) KXLOX.send_test_source_enable(0)
KXLOX.KXInit(protocol_kx.KDescription.K_SBL_ID.value, 43) KXLOX.KXInit(protocol_kx.KDescription.K_SBL_ID.value, 43)