@@ -121,7 +121,7 @@ class DoIPClient:
121121 :type ecu_ip_address: str
122122 :param ecu_logical_address: The logical address of the target ECU. This should be an integer. According to the
123123 specification, the correct range is 0x0001 to 0x0DFF ("VM specific"). If you don't know the logical address,
124- either use the get_entity() method OR the await_vehicle_announcement() method and power
124+ either use the get_entity() method OR the await_vehicle_announcement() method and power
125125 cycle the ECU - it should identify itself on bootup.
126126 :type ecu_logical_address: int
127127 :param tcp_port: The destination TCP port for DoIP data communication. By default this is 13400 for unsecure and
@@ -208,7 +208,9 @@ def __exit__(self, type, value, traceback):
208208 self .close ()
209209
210210 @staticmethod
211- def _create_udp_socket (ipv6 = False , udp_port = UDP_DISCOVERY , timeout = None , source_interface = None ):
211+ def _create_udp_socket (
212+ ipv6 = False , udp_port = UDP_DISCOVERY , timeout = None , source_interface = None
213+ ):
212214 if ipv6 :
213215 sock = socket .socket (socket .AF_INET6 , socket .SOCK_DGRAM )
214216
@@ -250,15 +252,20 @@ def _pack_doip(protocol_version, payload_type, payload_data):
250252 protocol_version ,
251253 0xFF ^ protocol_version ,
252254 payload_type ,
253- len (payload_data )
255+ len (payload_data ),
254256 )
255257 data_bytes += payload_data
256258
257259 return data_bytes
258260
259261 @classmethod
260262 def await_vehicle_announcement (
261- cls , udp_port = UDP_DISCOVERY , timeout = None , ipv6 = False , source_interface = None , sock = None
263+ cls ,
264+ udp_port = UDP_DISCOVERY ,
265+ timeout = None ,
266+ ipv6 = False ,
267+ source_interface = None ,
268+ sock = None ,
262269 ):
263270 """Receive Vehicle Announcement Message
264271
@@ -273,20 +280,25 @@ def await_vehicle_announcement(
273280 :type timeout: float, optional
274281 :param ipv6: Bool forcing IPV6 socket instead of IPV4 socket
275282 :type ipv6: bool, optional
276- :return: IP Address of ECU and VehicleAnnouncementMessage object
277- :rtype: tuple
278283 :param source_interface: Interface name (like "eth0") to bind to for use with IPv6. Defaults to None which
279284 will use the default interface (which may not be the one connected to the ECU). Does nothing for IPv4,
280285 which will bind to all interfaces uses INADDR_ANY.
281286 :type source_interface: str, optional
287+ :return: IP Address of ECU and VehicleAnnouncementMessage object
288+ :rtype: tuple
282289 :raises TimeoutError: If vehicle announcement not received in time
283290 """
284291 start_time = time .time ()
285292
286293 parser = Parser ()
287294
288295 if not sock :
289- sock = cls ._create_udp_socket (ipv6 = ipv6 , udp_port = udp_port , timeout = timeout , source_interface = source_interface )
296+ sock = cls ._create_udp_socket (
297+ ipv6 = ipv6 ,
298+ udp_port = udp_port ,
299+ timeout = timeout ,
300+ source_interface = source_interface ,
301+ )
290302
291303 while True :
292304 remaining = None
@@ -313,13 +325,15 @@ def await_vehicle_announcement(
313325 return addr , result
314326
315327 @classmethod
316- def get_entity (cls , ecu_ip_address = '255.255.255.255' , protocol_version = 0x02 , eid = None , vin = None ):
317- """Sends a VehicleIdentificationRequest and awaits a VehicleIdentificationResponse from the ECU,
328+ def get_entity (
329+ cls , ecu_ip_address = "255.255.255.255" , protocol_version = 0x02 , eid = None , vin = None
330+ ):
331+ """Sends a VehicleIdentificationRequest and awaits a VehicleIdentificationResponse from the ECU,
318332 either with a specified VIN, EIN, or nothing. Equivalent to the request_vehicle_identification() method
319333 but can be called without instantiation.
320334
321335 :param ecu_ip_address: This is the IP address of the target ECU for unicast. Defaults to broadcast if
322- the address is not known.
336+ the address is not known.
323337 :type ecu_ip_address: str, optional
324338 :param protocol_version: The DoIP protocol version to use for communication. Represents the version of the ISO 13400
325339 specification to follow. 0x02 (2012) is probably correct for most ECU's at the time of writing, though technically
0 commit comments