py9b/py9b/link/base.py

33 lines
639 B
Python
Raw Normal View History

2018-10-15 12:10:00 +00:00
class LinkTimeoutException(Exception):
2019-10-20 06:49:22 +00:00
pass
2018-10-15 12:10:00 +00:00
class LinkOpenException(Exception):
2019-10-20 06:49:22 +00:00
pass
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
class BaseLink(object):
DEF_TIMEOUT = 1
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
def __init__(self, timeout=DEF_TIMEOUT, dump=False):
self.dump = dump
self.timeout = timeout
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
def scan(self):
raise NotImplementedError()
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
def open(self, port):
raise NotImplementedError()
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
def close(self):
pass
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
def read(self, size):
raise NotImplementedError()
2018-10-15 12:10:00 +00:00
2019-10-20 06:49:22 +00:00
def write(self, data):
raise NotImplementedError()
2018-10-15 12:10:00 +00:00
__all__ = ["LinkTimeoutException", "LinkOpenException", "BaseLink"]