Skip to content

Commit 797476f

Browse files
committed
tmclfwupload: Add special treatment for Ixxat CAN interface
1 parent 13c3299 commit 797476f

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

pytrinamic/cli/tmclfwupload.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
import logging
1515
import intelhex
1616
import serial
17+
import can
1718

1819
import pytrinamic
1920
from pytrinamic.connections import ConnectionManager
20-
from pytrinamic.connections import UsbTmclInterface, CanTmclInterface
21+
from pytrinamic.connections import UsbTmclInterface, CanTmclInterface, IxxatTmclInterface, KvaserTmclInterface
2122
from pytrinamic.connections.tmcl_interface import TmclInterface
2223
from pytrinamic.tmcl import TMCLCommand
2324

@@ -101,9 +102,21 @@ def firmware_update(iface: TmclInterface, hex_file):
101102

102103
# Some TMCL-CAN based bootloaders use 0x7FF as CAN-identifier in the response frame, so we need to let it through.
103104
if isinstance(iface, CanTmclInterface):
104-
filters = iface._connection.filters
105-
filters.append({"can_id": 0x7FF, "can_mask": 0x7FF})
106-
iface._connection.set_filters(filters)
105+
if isinstance(iface, IxxatTmclInterface):
106+
# Special treatment for Ixxat interface, as it doesn't allow to dynamically change filters.
107+
# We need to add the 0x7FF filter to the initial filter list and reconnect.
108+
iface._connection.shutdown()
109+
iface._connection = can.Bus(interface="ixxat",
110+
channel=iface._channel,
111+
bitrate=iface._bitrate,
112+
can_filters=[
113+
{"can_id": iface._host_id, "can_mask": 0x7FF},
114+
{"can_id": 0x7FF, "can_mask": 0x7FF},
115+
])
116+
else:
117+
filters = iface._connection.filters
118+
filters.append({"can_id": 0x7FF, "can_mask": 0x7FF})
119+
iface._connection.set_filters(filters)
107120

108121
# ############################# Bootloader entry ################################
109122
# Connect to the evaluation board

0 commit comments

Comments
 (0)