diff --git a/rpc/open_xdatachannel.py b/rpc/open_xdatachannel.py index 553f76f..2684205 100755 --- a/rpc/open_xdatachannel.py +++ b/rpc/open_xdatachannel.py @@ -39,7 +39,13 @@ cfg, unknown = parser.parse_known_args() -r = rpc.XMMRPC() +r = None +try: + r = rpc.XMMRPC() +except Exception as ex: + logging.error(ex) + exit() + ipr = IPRoute() r.execute('UtaMsSmsInit') diff --git a/rpc/rpc.py b/rpc/rpc.py index 9e661d8..7fc4d78 100755 --- a/rpc/rpc.py +++ b/rpc/rpc.py @@ -15,8 +15,16 @@ def asn_int4(val): class XMMRPC(object): - def __init__(self, path='/dev/xmm0/rpc'): - self.fp = os.open(path, os.O_RDWR | os.O_SYNC) + def __init__(self, interfaces=['/dev/xmm0/rpc', '/dev/wwan0xmmrpc0']): + selected_interface = None + for interface in interfaces: + if os.path.exists(interface): + selected_interface = interface + break + if selected_interface is None: + raise IOError('XMM RPC interface does not exists') + + self.fp = os.open(selected_interface, os.O_RDWR | os.O_SYNC) # loop over 1..255, excluding 0 self.tid_gen = itertools.cycle(range(1, 256))