示例#1
0
    def enter(socket,  # type: _SocketUnion
              configuration,  # type: AutomotiveTestCaseExecutorConfiguration
              _  # type: Dict[str, Any]
              ):  # type: (...) -> bool
        if configuration.unittest:
            configuration["tps"] = None
            socket.sr1(UDS() / UDS_TP(), timeout=0.1, verbose=False)
            return True

        UDS_TPEnumerator.cleanup(socket, configuration)
        configuration["tps"] = UDS_TesterPresentSender(socket)
        configuration["tps"].start()
        return True
示例#2
0
def hsfz_scan(
        ip,  # type: str
        scan_range=range(0x100),  # type: Iterable[int]
        src=0xf4,  # type: int
        timeout=0.1,  # type: Union[int, float]
        verbose=True  # type: bool
):
    # type: (...) -> List[UDS_HSFZSocket]
    """
    Helper function to scan for HSFZ endpoints.

    Example:
        >>> sockets = hsfz_scan("192.168.0.42")

    :param ip: IPv4 address of target to scan
    :param scan_range: Range for HSFZ destination address
    :param src: HSFZ source address, used during the scan
    :param timeout: Timeout for each request
    :param verbose: Show information during scan, if True
    :return: A list of open UDS_HSFZSockets
    """
    results = list()
    for i in scan_range:
        with UDS_HSFZSocket(src, i, ip) as sock:
            try:
                resp = sock.sr1(UDS() / UDS_TP(),
                                timeout=timeout,
                                verbose=False)
                if resp:
                    results.append((i, resp))
                if resp and verbose:
                    print("Found endpoint %s, src=0x%x, dst=0x%x" %
                          (ip, src, i))
            except Exception as e:
                print("Error %s at destination address 0x%x" % (e, i))
    return [UDS_HSFZSocket(0xf4, dst, ip) for dst, _ in results]
示例#3
0
 def _get_initial_requests(self, **kwargs):
     # type: (Any) -> Iterable[Packet]
     return [UDS() / UDS_TP()]