[update] fix spi reset

This commit is contained in:
Roy
2022-02-10 17:46:36 +08:00
parent a38fe5066f
commit e33b4d9a21
4 changed files with 45 additions and 60 deletions
-43
View File
@@ -506,8 +506,6 @@ class DataServer(SocketServer, DataAPI):
# start sync
for runtime in r:
if runtime is not None and not runtime.sync_started:
# if isinstance(runtime, DeviceDataRuntime):
# self.spi_flush(runtime.device)
# if client is not None:
# client.drop_data(runtime.device)
@@ -562,23 +560,6 @@ class DataServer(SocketServer, DataAPI):
self.mqtt_thread.broadcast_command('stop:' + str(c._device))
# r.append(c)
# stop sync
# for runtime in r:
# if runtime is not None and runtime.sync_started:
# self.log_info('stop_sync', runtime.device)
# self.mqtt_thread.broadcast_command('stop:' + str(runtime.device))
# try:
# runtime.shutdown()
# except:
# print_exception(self)
# # finally:
# # # self.spi_flush(runtime.device)
# # if _FLAG_DATA_LOST_STATS_:
# # if isinstance(runtime, DeviceDataRuntime):
# # runtime.log_data_receive_statistics(self)
# # runtime.shutdown()
# stop runtime, none device working
if not self.sync_started:
@@ -780,30 +761,6 @@ class DataServer(SocketServer, DataAPI):
return
def spi_flush(self, device: int):
"""clean spi buffer"""
if self._spi is not None:
self._spi.select = device
return
def spi_reset_ram_header(self, device: int):
if self._spi is not None:
self._spi.select = device
self._spi.mem_request()
sleep(0.01)
self._spi.reset()
return
def spi_send(self, device: int, address: int, data: bytes):
sync = self._spi
if sync is None:
return
sync.select = device
sync.write_memory(address, data)
return
def spi_recv(self, device: int) -> Optional[bytes]:
sync = self._spi