[update] take away unused function
This commit is contained in:
@@ -104,16 +104,6 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
def select(self, value: int):
|
||||
self._selector.select(value)
|
||||
|
||||
def changed(self, flip=False) -> bool:
|
||||
channel = self._selector.channel
|
||||
old = self._pin_sel_val[channel]
|
||||
value = bool(self.pin_ram_sel)
|
||||
|
||||
if flip:
|
||||
self._pin_sel_val[channel] = value
|
||||
|
||||
return value != old
|
||||
|
||||
def reset(self):
|
||||
self._spi.reset()
|
||||
|
||||
@@ -143,26 +133,6 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
else:
|
||||
return None
|
||||
|
||||
def mem_request(self):
|
||||
self.pin_request.output(False)
|
||||
sleep(0.001)
|
||||
|
||||
# count = 0
|
||||
# for i in range(300):
|
||||
# count = count + 1
|
||||
|
||||
self.pin_request.output(True)
|
||||
|
||||
# sleep(0.001) -> 1.2ms
|
||||
# no sleep -> 5us ~ 12us (central can't receive)
|
||||
|
||||
# for i in range
|
||||
# (1000) -> 500us ~ 1ms
|
||||
# (500) -> 200us ~ 500us
|
||||
# (300) -> 120us ~ 270us (seldom)
|
||||
# (200) -> 70us ~ 160us (skip req about every 64 time) x
|
||||
# (100) -> 40us ~ 100us (skip req sometimes) x
|
||||
|
||||
def compare_green_data(self, data_first: Union[bytes, List[int]], data_second: Union[bytes, List[int]], data_third: Union[bytes, List[int]], length: int):
|
||||
data = []
|
||||
data.append(255)
|
||||
@@ -403,9 +373,6 @@ class ExtMemManager:
|
||||
def __init__(self, ext_mem: MultiExtMemSpiInterface):
|
||||
self._ext_mem = ext_mem
|
||||
|
||||
def mem_request(self):
|
||||
self._ext_mem.mem_request()
|
||||
|
||||
def get_ext_mem_register(self) -> List[Tuple[Optional[int], Optional[int]]]:
|
||||
ret = [(None, None) for _ in range(Selector.SIZE)]
|
||||
|
||||
|
||||
@@ -673,52 +673,6 @@ class DataServer(SocketServer, DataAPI):
|
||||
|
||||
return ret
|
||||
|
||||
def recv_data_form_spi(self) -> bool:
|
||||
"""
|
||||
"""
|
||||
current_time = time()
|
||||
|
||||
ret = False
|
||||
|
||||
devicelist = self._configurations.keys()
|
||||
|
||||
devicelist = [4, 5, 7, 6]
|
||||
|
||||
for c in devicelist:
|
||||
sync = self._spi
|
||||
sync.select = c
|
||||
|
||||
# delay 120us ~ 270us
|
||||
count = 0
|
||||
for i in range(300):
|
||||
count = count + 1
|
||||
|
||||
if c in self._configurations.keys() and self._configurations[c] is not None:
|
||||
data = self.spi_recv(c)
|
||||
if time() - current_time > 0.1:
|
||||
print('time, spi_recv', current_time, time() - current_time)
|
||||
current_time = time()
|
||||
if data is not None:
|
||||
try:
|
||||
|
||||
if self._configurations[c].queue_flag:
|
||||
self._configurations[c].queue_flag = False
|
||||
print("q size= ", self._configurations[c]._queue_rec.qsize())
|
||||
|
||||
self._configurations[c].put_rec_queue(data)
|
||||
if time() - current_time > 0.05:
|
||||
print('time, queue', current_time, time() - current_time)
|
||||
current_time = time()
|
||||
# print('done put queue')
|
||||
except:
|
||||
return
|
||||
else:
|
||||
ret = True
|
||||
# else:
|
||||
# print('****1')
|
||||
|
||||
return ret
|
||||
|
||||
def rec_update(self) -> bool:
|
||||
|
||||
device_id = self._queue_db_error.get()
|
||||
@@ -732,139 +686,6 @@ class DataServer(SocketServer, DataAPI):
|
||||
|
||||
return True
|
||||
|
||||
def recv_data_foreach_runtime(self, device_id: int) -> bool:
|
||||
# """foreach data runtime to receive data. called by :class:`DataRuntimeThread`.
|
||||
|
||||
# :return: has runtime received data
|
||||
# """
|
||||
# q = None
|
||||
# data = None
|
||||
# try:
|
||||
# q = self._queue_spi_dict[device_id].get()
|
||||
# except:
|
||||
# return False
|
||||
|
||||
# ret = False
|
||||
|
||||
|
||||
# if self._queue_spi_dict[device_id].qsize() > 10:
|
||||
# print('qsize: ', device_id, self._queue_spi_dict[device_id].qsize())
|
||||
|
||||
# for c in self._configurations:
|
||||
# if self._configurations[c] is not None and self._configurations[c].sync_started:
|
||||
# if self._configurations[c]._device == device_id:
|
||||
# try:
|
||||
# data = self._configurations[c].sync_data(q)
|
||||
# except EODInterrupt:
|
||||
# self._configurations[c].sync_started = False
|
||||
# except:
|
||||
# # catch any error and ignore it
|
||||
# print_exception(self)
|
||||
# self._configurations[c].sync_started = False
|
||||
|
||||
# else:
|
||||
# if data is not None and len(data) > 0:
|
||||
# ret = True
|
||||
# # if self._configurations[c].sync_file_request:
|
||||
# # self._configurations[c].sync_file()
|
||||
# # for c in self._configurations:
|
||||
# # # print('_configurations', c)
|
||||
# # if c is not None and c.sync_started:
|
||||
# # if q[0] == c._device:
|
||||
# # try:
|
||||
# # # print('c.time', c._prev_data, c._prev_time_stamp, c._prev_delta_time)
|
||||
# # # c._timer_of_not_send = int(time())
|
||||
# # data = c.sync_data(q[1])
|
||||
|
||||
# # except EODInterrupt:
|
||||
# # c.sync_started = False
|
||||
|
||||
# # except:
|
||||
# # # catch any error and ignore it
|
||||
# # print_exception(self)
|
||||
# # c.sync_started = False
|
||||
|
||||
# # else:
|
||||
# # if data is not None and len(data) > 0:
|
||||
# # ret = True
|
||||
|
||||
# # if c.sync_file_request:
|
||||
# # c.sync_file()
|
||||
# del q
|
||||
# del data
|
||||
|
||||
return
|
||||
|
||||
|
||||
def spi_recv(self, device: int) -> Optional[bytes]:
|
||||
sync = self._spi
|
||||
|
||||
if sync is None:
|
||||
return None
|
||||
if self._is_usb_port(device):
|
||||
# if self._is_demo_usb_port(device):
|
||||
# self._usb will be a list when suporting multi usb device
|
||||
sync = self._usb
|
||||
|
||||
if sync is None:
|
||||
return None
|
||||
|
||||
data = sync.recv_memory()
|
||||
if data is None:
|
||||
return None
|
||||
|
||||
data_length = len(data) + 1
|
||||
header = 0xFF
|
||||
data_counter = 0x00
|
||||
data_header = [header, data_counter, data_length, device]
|
||||
data_header.extend(data)
|
||||
|
||||
return bytes(data_header)
|
||||
|
||||
else:
|
||||
sync = self._spi
|
||||
|
||||
if sync is None:
|
||||
return None
|
||||
|
||||
# sync.select = device
|
||||
|
||||
# sleep(0.003)
|
||||
|
||||
if sync.changed(flip=True):
|
||||
spi_data = sync.recv_memory(device)
|
||||
|
||||
return spi_data
|
||||
# if sync.get_wait_flag(device) is False:
|
||||
# return spi_data
|
||||
# else:
|
||||
# sync.set_wait_flag(device, False)
|
||||
# print("discard first data")
|
||||
# return None
|
||||
# return sync.recv_memory()
|
||||
else:
|
||||
sync.mem_request()
|
||||
|
||||
return None
|
||||
|
||||
def _is_usb_port(self, device: int) -> bool:
|
||||
max_spi_port_number = 8
|
||||
|
||||
if device >= max_spi_port_number:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
sync.select = device
|
||||
|
||||
if sync.changed(flip=True):
|
||||
# print('recv_memory~~~')
|
||||
return sync.recv_memory()
|
||||
else:
|
||||
# print('request_data___')
|
||||
return sync.mem_request()
|
||||
|
||||
|
||||
class DataRuntime(metaclass=abc.ABCMeta):
|
||||
__slots__ = ('_server', '_device', '_meta_file', '_data_format',
|
||||
'_sync_started', 'sync_file_request', '_writer')
|
||||
@@ -1312,12 +1133,6 @@ class DataRuntimeThread(ServerThread):
|
||||
return True
|
||||
|
||||
def routine(self, event = None) -> None:
|
||||
# start = time()
|
||||
# ret = self._server.recv_data_foreach_runtime(self._device_id)
|
||||
# self._counter += 1
|
||||
# if self._counter > 10000:
|
||||
# gc.collect()
|
||||
# self._counter = 0
|
||||
del ret
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user