|
14 | 14 | import logging |
15 | 15 | import intelhex |
16 | 16 | import serial |
| 17 | +import can |
17 | 18 |
|
18 | 19 | import pytrinamic |
19 | 20 | from pytrinamic.connections import ConnectionManager |
20 | | -from pytrinamic.connections import UsbTmclInterface, CanTmclInterface |
| 21 | +from pytrinamic.connections import UsbTmclInterface, CanTmclInterface, IxxatTmclInterface, KvaserTmclInterface |
21 | 22 | from pytrinamic.connections.tmcl_interface import TmclInterface |
22 | 23 | from pytrinamic.tmcl import TMCLCommand |
23 | 24 |
|
@@ -101,9 +102,21 @@ def firmware_update(iface: TmclInterface, hex_file): |
101 | 102 |
|
102 | 103 | # Some TMCL-CAN based bootloaders use 0x7FF as CAN-identifier in the response frame, so we need to let it through. |
103 | 104 | 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) |
107 | 120 |
|
108 | 121 | # ############################# Bootloader entry ################################ |
109 | 122 | # Connect to the evaluation board |
|
0 commit comments