Skip to content

Commit ac84454

Browse files
zariiii9003christiansandberg
authored andcommitted
vector xlclass - implement XLbusParams (hardbyte#718)
1 parent c001ef2 commit ac84454

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

can/interfaces/vector/xlclass.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,58 @@ class XLcanFdConf(ctypes.Structure):
169169
("sjwDbr", ctypes.c_uint),
170170
("tseg1Dbr", ctypes.c_uint),
171171
("tseg2Dbr", ctypes.c_uint),
172-
("reserved", ctypes.c_uint * 2),
172+
("reserved", ctypes.c_ubyte),
173+
("options", ctypes.c_ubyte),
174+
("reserved1", ctypes.c_ubyte * 2),
175+
("reserved2", ctypes.c_ubyte),
176+
]
177+
178+
179+
# channel configuration structures
180+
class s_xl_bus_params_data_can(ctypes.Structure):
181+
_fields_ = [
182+
("bitRate", ctypes.c_uint),
183+
("sjw", ctypes.c_ubyte),
184+
("tseg1", ctypes.c_ubyte),
185+
("tseg2", ctypes.c_ubyte),
186+
("sam", ctypes.c_ubyte),
187+
("outputMode", ctypes.c_ubyte),
188+
("reserved", ctypes.c_ubyte * 7),
189+
("canOpMode", ctypes.c_ubyte),
190+
]
191+
192+
193+
class s_xl_bus_params_data_canfd(ctypes.Structure):
194+
_fields_ = [
195+
("arbitrationBitRate", ctypes.c_uint),
196+
("sjwAbr", ctypes.c_ubyte),
197+
("tseg1Abr", ctypes.c_ubyte),
198+
("tseg2Abr", ctypes.c_ubyte),
199+
("samAbr", ctypes.c_ubyte),
200+
("outputMode", ctypes.c_ubyte),
201+
("sjwDbr", ctypes.c_ubyte),
202+
("tseg1Dbr", ctypes.c_ubyte),
203+
("tseg2Dbr", ctypes.c_ubyte),
204+
("dataBitRate", ctypes.c_uint),
205+
("canOpMode", ctypes.c_ubyte),
173206
]
174207

175208

209+
class s_xl_bus_params_data(ctypes.Union):
210+
_fields_ = [
211+
("can", s_xl_bus_params_data_can),
212+
("canFD", s_xl_bus_params_data_canfd),
213+
("most", ctypes.c_ubyte * 12),
214+
("flexray", ctypes.c_ubyte * 12),
215+
("ethernet", ctypes.c_ubyte * 12),
216+
("a429", ctypes.c_ubyte * 28),
217+
]
218+
219+
220+
class XLbusParams(ctypes.Structure):
221+
_fields_ = [("busType", ctypes.c_uint), ("data", s_xl_bus_params_data)]
222+
223+
176224
class XLchannelConfig(ctypes.Structure):
177225
_pack_ = 1
178226
_fields_ = [
@@ -189,7 +237,7 @@ class XLchannelConfig(ctypes.Structure):
189237
("channelBusCapabilities", ctypes.c_uint),
190238
("isOnBus", ctypes.c_ubyte),
191239
("connectedBusType", ctypes.c_uint),
192-
("busParams", ctypes.c_ubyte * 32),
240+
("busParams", XLbusParams),
193241
("_doNotUse", ctypes.c_uint),
194242
("driverVersion", ctypes.c_uint),
195243
("interfaceVersion", ctypes.c_uint),

0 commit comments

Comments
 (0)