@@ -121,7 +121,7 @@ def __init__(self, data_received_callback, name=None, **kwargs):
121121 # select controlset for viess_proto
122122 self ._controlset = self ._controlsets [self ._viess_proto ]
123123
124- # make sure we have a basic set of parameters for the TCP connection
124+ # make sure we have a basic set of parameters for the serial connection
125125 self ._params = {PLUGIN_ATTR_SERIAL_PORT : '' ,
126126 PLUGIN_ATTR_SERIAL_BAUD : self ._controlset [PLUGIN_ATTR_SERIAL_BAUD ],
127127 PLUGIN_ATTR_SERIAL_BSIZE : self ._controlset [PLUGIN_ATTR_SERIAL_BSIZE ],
@@ -136,12 +136,16 @@ def __init__(self, data_received_callback, name=None, **kwargs):
136136 PLUGIN_ATTR_CB_ON_DISCONNECT : None ,
137137 PLUGIN_ATTR_CONNECTION : CONN_SER_DIR }
138138 self ._params .update (kwargs )
139-
140139 # check if some of the arguments are usable
141140 self ._set_connection_params ()
142141
142+ if self ._params [PLUGIN_ATTR_CB_ON_CONNECT ] or self ._params [PLUGIN_ATTR_CB_ON_DISCONNECT ]:
143+ use_callbacks = True
144+ else :
145+ use_callbacks = False
146+
143147 # initialize connection
144- self ._get_connection (name = name )
148+ self ._get_connection (use_callbacks = use_callbacks , name = name )
145149
146150 # set "method pointers"
147151 self ._send_bytes = self ._connection ._send_bytes
@@ -251,7 +255,7 @@ def _send_init_on_send(self):
251255
252256 return True
253257
254- def _send (self , data_dict ):
258+ def _send (self , data_dict , ** kwargs ):
255259 """
256260 send data. data_dict needs to contain the following information:
257261
@@ -265,6 +269,9 @@ def _send(self, data_dict):
265269 :type read_response: bool
266270 :return: Response packet (bytearray) if no error occured, None otherwise
267271 """
272+ if kwargs :
273+ self .logger .debug (f'got additional kw args { kwargs } ' )
274+
268275 (packet , responselen ) = self ._build_payload (data_dict )
269276
270277 # send payload
0 commit comments