2020from .util import load_config
2121from .interfaces import BACKENDS
2222
23+ from can .interfaces .socketcan .socketcan import CyclicSendTask , MultiRateCyclicSendTask
24+
2325# Required by "detect_available_configs" for argument interpretation
2426if sys .version_info .major > 2 :
2527 basestring = str
@@ -37,14 +39,6 @@ def _get_class_for_interface(interface):
3739 ImportError if there was a problem while importing the
3840 interface or the bus class within that
3941 """
40-
41- # filter out the socketcan special case
42- if interface == 'socketcan' :
43- try :
44- interface = can .util .choose_socketcan_implementation ()
45- except Exception as e :
46- raise ImportError ("Cannot choose socketcan implementation: {}" .format (e ))
47-
4842 # Find the correct backend
4943 try :
5044 module_name , class_name = BACKENDS [interface ]
@@ -175,43 +169,3 @@ def detect_available_configs(interfaces=None):
175169 result += available
176170
177171 return result
178-
179-
180- class CyclicSendTask (CyclicSendTaskABC ):
181-
182- @staticmethod
183- def __new__ (cls , channel , * args , ** kwargs ):
184-
185- config = load_config (config = {'channel' : channel })
186-
187- # Import the correct implementation of CyclicSendTask
188- if config ['interface' ] == 'socketcan_ctypes' :
189- from can .interfaces .socketcan .socketcan_ctypes import CyclicSendTask as _ctypesCyclicSendTask
190- cls = _ctypesCyclicSendTask
191- elif config ['interface' ] == 'socketcan_native' :
192- from can .interfaces .socketcan .socketcan_native import CyclicSendTask as _nativeCyclicSendTask
193- cls = _nativeCyclicSendTask
194- else :
195- raise can .CanError ("Current CAN interface doesn't support CyclicSendTask" )
196-
197- return cls (config ['channel' ], * args , ** kwargs )
198-
199-
200- class MultiRateCyclicSendTask (MultiRateCyclicSendTaskABC ):
201-
202- @staticmethod
203- def __new__ (cls , channel , * args , ** kwargs ):
204-
205- config = load_config (config = {'channel' : channel })
206-
207- # Import the correct implementation of CyclicSendTask
208- if config ['interface' ] == 'socketcan_ctypes' :
209- from can .interfaces .socketcan .socketcan_ctypes import MultiRateCyclicSendTask as _ctypesMultiRateCyclicSendTask
210- cls = _ctypesMultiRateCyclicSendTask
211- elif config ['interface' ] == 'socketcan_native' :
212- from can .interfaces .socketcan .socketcan_native import MultiRateCyclicSendTask as _nativeMultiRateCyclicSendTask
213- cls = _nativeMultiRateCyclicSendTask
214- else :
215- can .log .info ("Current CAN interface doesn't support CyclicSendTask" )
216-
217- return cls (config ['channel' ], * args , ** kwargs )
0 commit comments