Skip to content

Commit 2dbf338

Browse files
authored
Merge pull request #18 from cpavot/cpavot_optional_params_for_binding
Support optional parameters for binding IsoTPSocketConnection
2 parents d6d2f3a + 23f5bc5 commit 2dbf338

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

udsoncan/connections.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,13 @@ class IsoTPSocketConnection(BaseConnection):
232232
:type name: string
233233
:param tpsock: An optional ISO-TP socket to use instead of creating one.
234234
:type tpsock: isotp.socket
235+
:param args: Optional parameters list passed to ISO-TP socket binding method.
236+
:type args: list
237+
:param kwargs: Optional parameters dictionary passed to ISO-TP socket binding method.
238+
:type kwargs: dict
235239
236240
"""
237-
def __init__(self, interface, rxid, txid, name=None, tpsock=None):
241+
def __init__(self, interface, rxid, txid, name=None, tpsock=None, *args, **kwargs):
238242

239243
BaseConnection.__init__(self, name)
240244

@@ -244,6 +248,8 @@ def __init__(self, interface, rxid, txid, name=None, tpsock=None):
244248
self.rxqueue = queue.Queue()
245249
self.exit_requested = False
246250
self.opened = False
251+
self.tpsock_bind_args = args
252+
self.tpsock_bind_kwargs = kwargs
247253

248254
if tpsock is None:
249255
if 'isotp' not in sys.modules:
@@ -257,7 +263,7 @@ def __init__(self, interface, rxid, txid, name=None, tpsock=None):
257263

258264

259265
def open(self):
260-
self.tpsock.bind(self.interface, rxid=self.rxid, txid=self.txid)
266+
self.tpsock.bind(self.interface, rxid=self.rxid, txid=self.txid, *self.tpsock_bind_args, **self.tpsock_bind_kwargs)
261267
self.exit_requested = False
262268
self.rxthread = threading.Thread(target=self.rxthread_task)
263269
self.rxthread.start()

0 commit comments

Comments
 (0)