def __init__(self, configPath=None, ihexFile=None, **kwargs): self.__config = None self.__transportProtocol = None self.__P2_CAN_Client = None self.__P2_CAN_Server = None self.__loadConfiguration(configPath) self.__checkKwargs(**kwargs) self.__transportProtocol = self.__config['uds']['transportProtocol'] self.__P2_CAN_Client = float(self.__config['uds']['P2_CAN_Client']) self.__P2_CAN_Server = float(self.__config['uds']['P2_CAN_Server']) tpFactory = TpFactory() self.tp = tpFactory(self.__transportProtocol, configPath=configPath, **kwargs) # used as a semaphore for the tester present self.__transmissionActive_flag = False self.sendLock = threading.Lock() # Process any ihex file that has been associated with the ecu at initialisation self.__ihexFile = ihexFileParser( ihexFile) if ihexFile is not None else None
def __init__(self, configPath=None, ihexFile=None, **kwargs): self.__config = None self.__transportProtocol = None self.__P2_CAN_Client = None self.__P2_CAN_Server = None self.__loadConfiguration(configPath) self.__checkKwargs(**kwargs) self.__transportProtocol = self.__config['uds']['transportProtocol'] self.__P2_CAN_Client = float(self.__config['uds']['P2_CAN_Client']) self.__P2_CAN_Server = float(self.__config['uds']['P2_CAN_Server']) tpFactory = TpFactory() self.tp = tpFactory(self.__transportProtocol, configPath=configPath, **kwargs) # used as a semaphore for the tester present self.__transmissionActive_flag = False #print(("__transmissionActive_flag initialised (clear):",self.__transmissionActive_flag)) # The above flag should prevent testerPresent operation, but in case of race conditions, this lock prevents actual overlapo in the sending self.sendLock = threading.Lock() # Process any ihex file that has been associated with the ecu at initialisation self.__ihexFile = ihexFileParser( ihexFile) if ihexFile is not None else None
def transferFile(self, fileName=None, transmitChunkSize=None, compressionMethod=None): if fileName is None and self.__ihexFile is None: raise FileNotFoundError("file to transfer has not been specified") # Currently only ihex is recognised and supported if fileName[-4:] == '.hex' or fileName[-5:] == '.ihex': self.__ihexFile = ihexFileParser(fileName) return self.transferIHexFile(transmitChunkSize, compressionMethod) else: raise FileNotFoundError( "file to transfer has not been recognised as a supported type ['.hex','.ihex']" )
def ihexFile(self, value): if value is not None: self.__ihexFile = ihexFileParser(value)