Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e7c0710b9 | |||
| 5131535bda | |||
| ac5a6ef77a |
@@ -1,7 +0,0 @@
|
||||
.DS_Store
|
||||
*.cpython-37.opt-2.pyc
|
||||
*.pyc
|
||||
*/__pycache__
|
||||
/.vscode
|
||||
/media
|
||||
python/biopro/sever/_identify.py
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -315,6 +315,14 @@ class CC2650MasterDevice(MasterDevice, metaclass=abc.ABCMeta):
|
||||
|
||||
return cls.CC2650_RESET_PIN
|
||||
|
||||
@classmethod
|
||||
def get_uart_irq_pin(cls) -> OutputPin:
|
||||
if cls.CC2650_UART_IRQ is None:
|
||||
cls.CC2650_UART_IRQ = OutputPin.get_used(P3Pin.MEM_RST, initial=True)
|
||||
|
||||
return cls.CC2650_UART_IRQ
|
||||
|
||||
|
||||
class CC2650Device(Device):
|
||||
|
||||
def __init__(self,
|
||||
@@ -947,6 +955,9 @@ class CC2650SingleMasterDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
self._cc2650.recv_util(..., when=self._cond, timeout=timeout)
|
||||
|
||||
def available_device(self) -> List[int]:
|
||||
return [0]
|
||||
|
||||
@synchronized
|
||||
def scan_callback(self, callback: Callable[[DeviceResponseInfo], None], timeout=5, all_device=False) -> bool:
|
||||
if self._scan_max_time != timeout:
|
||||
@@ -1431,6 +1442,11 @@ class CC2650MultiMasterDevice(CC2650MasterDevice, Synchronized):
|
||||
super().shutdown()
|
||||
self._selector.close()
|
||||
|
||||
def available_device(self) -> List[int]:
|
||||
return list(map(lambda it: it[0],
|
||||
filter(lambda it: it[1] is not None,
|
||||
enumerate(self._cc2650))))
|
||||
|
||||
def get_device(self, device: int) -> Optional[Device]:
|
||||
return self._device[device]
|
||||
|
||||
@@ -1926,34 +1942,44 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
self.log_verbose('reset (hardware)')
|
||||
|
||||
pin.output(False)
|
||||
# sleep(0.001)
|
||||
sleep(0.1)
|
||||
|
||||
pin.output(True)
|
||||
sleep(0.1)
|
||||
|
||||
@synchronized
|
||||
def reset_software(self):
|
||||
"""software reset cc2650 (master)"""
|
||||
# print('resettt---------14')
|
||||
# print()
|
||||
# self.log_verbose('reset (software)')
|
||||
|
||||
self.log_verbose('reset (software)')
|
||||
# try:
|
||||
# #self._cc2650.send("3B", 1, 0, 0)
|
||||
# pass
|
||||
|
||||
try:
|
||||
#self._cc2650.send("3B", 1, 0, 0)
|
||||
pass
|
||||
# except SerialTimeoutException as e:
|
||||
# raise RecvTimeout('device CC2650 reset fail') from e
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
raise RecvTimeout('device CC2650 reset fail') from e
|
||||
|
||||
finally:
|
||||
sleep(0.1)
|
||||
# finally:
|
||||
# sleep(0.1)
|
||||
print("pass")
|
||||
print()
|
||||
|
||||
|
||||
@synchronized
|
||||
def init_hardware(self, timeout=1):
|
||||
"""initialize cc2650 (master)"""
|
||||
pass
|
||||
|
||||
def available_device(self) -> List[int]:
|
||||
return [0]
|
||||
|
||||
def scan_send_ins(self):
|
||||
# send scan command
|
||||
try:
|
||||
print(':: scan_send_ins ::', self.CC2650_COMMAND_LEN, 3, 0, 0)
|
||||
print()
|
||||
self._cc2650.send(self.CC2650_COMMAND_LEN, 3, 0, 0)
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
@@ -1965,16 +1991,21 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
clean_buf = self._cc2650.receive_timeout("20B", timeout=3)
|
||||
print("clean_buf = ", clean_buf)
|
||||
|
||||
# def cc2650_uart_irq(self):
|
||||
# uart_irq = self.get_uart_irq_pin()
|
||||
# uart_irq.output(False)
|
||||
# sleep(0.001)
|
||||
# uart_irq.output(True)
|
||||
def cc2650_uart_irq(self):
|
||||
uart_irq = self.get_uart_irq_pin()
|
||||
uart_irq.output(False)
|
||||
sleep(0.001)
|
||||
uart_irq.output(True)
|
||||
|
||||
@synchronized
|
||||
def scan_callback(self, callback: Callable[[DeviceResponseInfo], None], timeout=5, all_device=False) -> bool:
|
||||
# if self._scan_max_time != timeout:
|
||||
# self.log_info('set max scan limit time', timeout)
|
||||
# self._scan_max_time = timeout
|
||||
|
||||
self._found = found = []
|
||||
self._found_with_id = []
|
||||
number_of_device = 0
|
||||
hdr_BPHS = [66, 80, 72, 83]
|
||||
scan_response: Union[Optional[tuple], Any] = None
|
||||
|
||||
@@ -1984,16 +2015,42 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
scan_ins.append(1) #length
|
||||
scan_ins.append(0xF1)
|
||||
|
||||
# print('send_scan', bytes(scan_ins))
|
||||
print('send_scan', list(scan_ins))
|
||||
self._cc2650.send("bytes", bytes(scan_ins))
|
||||
|
||||
# for wait_scan_response in range(5):
|
||||
# try:
|
||||
# scan_response = self._cc2650.recv_uart(0.2)
|
||||
# except RecvTimeout:
|
||||
# if wait_scan_response == 4:
|
||||
# self.reset_internal()
|
||||
# self.reset_hardware()
|
||||
# self._interface.flush()
|
||||
# return True
|
||||
# else:
|
||||
# self.log_info("wait for scan response")
|
||||
# continue
|
||||
|
||||
# # check if response is valid
|
||||
# if scan_response is None:
|
||||
# if wait_scan_response == 4:
|
||||
# self.reset_internal()
|
||||
# self.reset_hardware()
|
||||
# self._interface.flush()
|
||||
# else:
|
||||
# self.log_info("wait for scan response")
|
||||
# continue
|
||||
# else:
|
||||
# break
|
||||
|
||||
try:
|
||||
scan_response = self._cc2650.recv_uart(timeout)
|
||||
scan_response = self._cc2650.recv_uart(0.2)
|
||||
except RecvTimeout:
|
||||
# self.reset_internal()
|
||||
# self.reset_hardware()
|
||||
# self._interface.flush()
|
||||
return False
|
||||
self.reset_internal()
|
||||
self.reset_hardware()
|
||||
self._interface.flush()
|
||||
return True
|
||||
|
||||
|
||||
# instruction format:
|
||||
# ins[0]: get_scan_response = 0x04
|
||||
@@ -2088,35 +2145,6 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
def found(self) -> List[DeviceResponseInfo]:
|
||||
return self._found
|
||||
|
||||
def check_mem_survive(self) -> Optional[CC2650Device]:
|
||||
ack = []
|
||||
ins = bytearray()
|
||||
ins.append(10)
|
||||
ins.append(1) #length
|
||||
ins.append(0xF1)
|
||||
# print('ins', list(ins))
|
||||
|
||||
try:
|
||||
self._cc2650.send("bytes", bytes(ins))
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
raise RecvTimeout('device CC2650 check_mem_survive timeout') from e
|
||||
|
||||
else:
|
||||
try:
|
||||
ack = self._cc2650.recv_uart(0.001)
|
||||
|
||||
except RecvTimeout:
|
||||
self.log_info("no memory board")
|
||||
|
||||
# else:
|
||||
# print('ack=', ack)
|
||||
|
||||
if ack == [3]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@synchronized
|
||||
def connect(self, response: DeviceResponseInfo, direct_connect: bool = False) -> Optional[CC2650Device]:
|
||||
if self._handle is not None:
|
||||
@@ -2147,6 +2175,7 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
# send device mac and addrType
|
||||
try:
|
||||
print('send_connect..',list(connect_ins))
|
||||
self._cc2650.send("bytes", bytes(connect_ins))
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
@@ -2179,39 +2208,26 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
# send device mac and addrType
|
||||
try:
|
||||
# print('send_connect',bytes(connect_ins))
|
||||
print('send_connect',list(connect_ins))
|
||||
self._cc2650.send("bytes", bytes(connect_ins))
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
raise RecvTimeout('device CC2650 connect fail') from e
|
||||
|
||||
else:
|
||||
sleep(2)
|
||||
|
||||
# connection establish done?
|
||||
for retry_recv_ack in range(5):
|
||||
self._cc2650.send("bytes", bytes((0, 0, 0, 0)))
|
||||
|
||||
sleep(1)
|
||||
try:
|
||||
con_done = self._cc2650.recv_uart(timeout = 0.1)
|
||||
|
||||
except RecvTimeout:
|
||||
self.log_info("recv connection timeout, retry... ")
|
||||
continue
|
||||
self.log_info("recv connection timeout, fail... ")
|
||||
|
||||
# is the ack valid?
|
||||
if con_done is None:
|
||||
continue
|
||||
|
||||
elif con_done[0] is 46 and \
|
||||
if con_done[0] is 46 and \
|
||||
con_done[1] is 80 and \
|
||||
con_done[2] is 48 and \
|
||||
con_done[3] is 4:
|
||||
connected = True
|
||||
# print('con_done=', con_done)
|
||||
break
|
||||
else:
|
||||
continue
|
||||
print('con_done=', con_done)
|
||||
|
||||
# if select device is invalid or connect failed
|
||||
self._interface.flush_input()
|
||||
@@ -2232,6 +2248,36 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
return ret
|
||||
|
||||
def check_mem_survive(self) -> Optional[CC2650Device]:
|
||||
|
||||
ack = []
|
||||
ins = bytearray()
|
||||
ins.append(10)
|
||||
ins.append(1) #length
|
||||
ins.append(0xF1)
|
||||
|
||||
try:
|
||||
self._cc2650.send("bytes", bytes(ins))
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
raise RecvTimeout('device CC2650 check_mem_survive timeout') from e
|
||||
|
||||
else:
|
||||
# sleep(1)
|
||||
try:
|
||||
ack = self._cc2650.recv_uart(timeout = 0.1)
|
||||
|
||||
except RecvTimeout:
|
||||
self.log_info("no survive device")
|
||||
|
||||
else:
|
||||
print('ack=', ack)
|
||||
|
||||
if ack == [3]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@synchronized
|
||||
def disconnect(self, device: int, force=False) -> bool:
|
||||
self.log_info(DEVICE_DISCONNECTING, device)
|
||||
@@ -2242,7 +2288,7 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
ins.append(0xF1)
|
||||
|
||||
try:
|
||||
# print('send_disconnect',bytes(ins))
|
||||
print('send_disconnect',list(ins))
|
||||
self._cc2650.send("bytes", bytes(ins))
|
||||
|
||||
except RecvTimeout:
|
||||
@@ -2277,28 +2323,20 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
ins.append(handle)
|
||||
ins.append(0xF1)
|
||||
|
||||
for _ in range(2):
|
||||
try:
|
||||
# print('send_read',bytes(ins))
|
||||
self._cc2650.send("bytes", bytes(ins))
|
||||
except SerialTimeoutException:
|
||||
raise RecvTimeout('device CC2650 send read_characteristic fail')
|
||||
try:
|
||||
print('read_characteristic',list(ins))
|
||||
self._cc2650.send("bytes", bytes(ins))
|
||||
|
||||
except SerialTimeoutException:
|
||||
raise RecvTimeout('device CC2650 send read_characteristic fail')
|
||||
|
||||
try:
|
||||
ret = self._cc2650.recv_uart(timeout = 2)
|
||||
except Exception as e2:
|
||||
raise RecvTimeout()
|
||||
else:
|
||||
# print("======== read ret = ", ret)
|
||||
self._interface.flush_input()
|
||||
|
||||
# try:
|
||||
# ret = self._cc2650.recv_uart(timeout = 1)
|
||||
# except Exception as e2:
|
||||
# raise RecvTimeout()
|
||||
# else:
|
||||
# # print("read_characteristic ret = ", ret)
|
||||
# pass
|
||||
try:
|
||||
ret = self._cc2650.recv_uart(timeout = 2)
|
||||
except Exception as e2:
|
||||
raise RecvTimeout()
|
||||
else:
|
||||
# print("======== read ret = ", ret)
|
||||
self._interface.flush_input()
|
||||
|
||||
if ret is None:
|
||||
return None
|
||||
@@ -2326,23 +2364,21 @@ class CC2650SingleMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
|
||||
try:
|
||||
self._cc2650.send("bytes", bytes(data_array))
|
||||
# print('send_write',bytes(data_array))
|
||||
self._cc2650.send("bytes", list(data_array))
|
||||
print('send_write',list(data_array))
|
||||
|
||||
except SerialTimeoutException as e:
|
||||
raise RecvTimeout('device CC2650 send instruction fail') from e
|
||||
|
||||
# read error code
|
||||
try:
|
||||
ret = self._cc2650.recv_uart()
|
||||
ret = self._cc2650.recv_uart(timeout = 0.1)
|
||||
print('ret=', ret)
|
||||
|
||||
# print("_______ write ack = ", ret)
|
||||
except Exception as e2:
|
||||
pass
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
self._interface.flush_input()
|
||||
self._interface.flush_output()
|
||||
|
||||
@@ -2519,44 +2555,143 @@ class CC2650MultiMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
else:
|
||||
self.log_warn('cannot %s notify for device : %s' % (message, device.__class__.__name__))
|
||||
|
||||
# def reset(self, device: Optional[List[int]] = None, software_reset=True):
|
||||
# print('resettt---------15')
|
||||
# print()
|
||||
|
||||
# # self.log_verbose('reset')
|
||||
|
||||
# # reset hardware
|
||||
# # print("reset device = ", device)
|
||||
# print('device:', device, software_reset)
|
||||
# print('self._device', list(self._device))
|
||||
# print('self._cc2650_once:', list(self._cc2650))
|
||||
# print('|')
|
||||
# print('|')
|
||||
# for i in range(len(self._cc2650)):
|
||||
# print('i', i)
|
||||
# if device is None or i in device:
|
||||
# self._device[i] = None
|
||||
|
||||
# m = self._cc2650[i]
|
||||
|
||||
# if m is None:
|
||||
# m = CC2650SingleMasterCentralDevice(self._master, self._interface, self._options)
|
||||
|
||||
# self._interface.flush()
|
||||
# self._selector.select(i)
|
||||
|
||||
# try:
|
||||
# self.log_info('reset device', i)
|
||||
|
||||
# with m:
|
||||
# m.reset_internal()
|
||||
# m.reset_hardware()
|
||||
|
||||
# if software_reset:
|
||||
# check_mem_survive_flag = m.check_mem_survive()
|
||||
# if check_mem_survive_flag:
|
||||
# self._cc2650[i] = m
|
||||
|
||||
# except RecvTimeout:
|
||||
# self.log_warn('reset device', i, 'fail')
|
||||
# self._cc2650[i] = None
|
||||
|
||||
# print('self._cc2650::', list(self._cc2650))
|
||||
|
||||
# return
|
||||
|
||||
def reset(self, device: Optional[List[int]] = None, software_reset=True):
|
||||
print('resettt---------15')
|
||||
print()
|
||||
|
||||
# self.log_verbose('reset')
|
||||
|
||||
# reset hardware
|
||||
# print("reset device = ", device)
|
||||
print('device:', device, software_reset)
|
||||
print('self._device', list(self._device))
|
||||
print('self._cc2650_once:', list(self._cc2650))
|
||||
print('|')
|
||||
print('|')
|
||||
|
||||
for i in range(len(self._cc2650)):
|
||||
if device is None or i in device:
|
||||
if device is None:
|
||||
self._device[i] = None
|
||||
|
||||
m = self._cc2650[i]
|
||||
|
||||
if m is None:
|
||||
m = CC2650SingleMasterCentralDevice(self._master, self._interface, self._options)
|
||||
self._cc2650[i] = m
|
||||
|
||||
self._interface.flush()
|
||||
self._selector.select(i)
|
||||
|
||||
|
||||
try:
|
||||
self.log_info('reset device', i)
|
||||
|
||||
with m:
|
||||
m.reset_internal()
|
||||
m.reset_hardware()
|
||||
m.reset_software()
|
||||
|
||||
|
||||
if not software_reset:
|
||||
check_mem_survive_flag = m.check_mem_survive()
|
||||
if check_mem_survive_flag:
|
||||
self._cc2650[i] = m
|
||||
|
||||
except RecvTimeout:
|
||||
self.log_warn('reset device', i, 'fail')
|
||||
self._cc2650[i] = None
|
||||
|
||||
if not software_reset:
|
||||
return
|
||||
print('self._cc2650::', list(self._cc2650))
|
||||
|
||||
def _foreach_empty_master(self) -> Iterable[int]:
|
||||
for i in range(len(self._device)):
|
||||
return
|
||||
|
||||
def reset_empty_master(self, device: Optional[List[int]] = None, software_reset=True):
|
||||
self.log_verbose('reset')
|
||||
|
||||
# reset hardware
|
||||
# print("reset device = ", device)
|
||||
for i in range(len(self._cc2650)):
|
||||
# print(i)
|
||||
|
||||
m = self._cc2650[i]
|
||||
d = self._device[i]
|
||||
|
||||
if d is None:
|
||||
# print(m, d)
|
||||
|
||||
if m is not None and d is None:
|
||||
m = CC2650SingleMasterCentralDevice(self._master, self._interface, self._options)
|
||||
# m.set_log_level(self._cc2650_log_level)
|
||||
|
||||
self._interface.flush()
|
||||
self._selector.select(i)
|
||||
self._mem_selector.select(i)
|
||||
|
||||
try:
|
||||
self.log_info('reset device', i)
|
||||
|
||||
with m:
|
||||
m.reset_internal()
|
||||
m.reset_hardware()
|
||||
|
||||
except RecvTimeout:
|
||||
self.log_warn('reset device', i, 'fail')
|
||||
self._cc2650[i] = None
|
||||
|
||||
def available_device(self) -> List[int]:
|
||||
return list(map(lambda it: it[0],
|
||||
filter(lambda it: it[1] is not None,
|
||||
enumerate(self._cc2650))))
|
||||
|
||||
def _foreach_empty_master(self) -> Iterable[int]:
|
||||
for i in range(len(self._cc2650)):
|
||||
m = self._cc2650[i]
|
||||
d = self._device[i]
|
||||
|
||||
if m is not None and d is None:
|
||||
yield i
|
||||
|
||||
def scan_callback(self, callback: Callable[[DeviceResponseInfo], None], timeout=5, all_device=False) -> bool:
|
||||
@@ -2564,35 +2699,28 @@ class CC2650MultiMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
all_result = False
|
||||
|
||||
for device in range(len(self._cc2650)):
|
||||
for device in self._foreach_empty_master():
|
||||
self.log_verbose('use', device)
|
||||
|
||||
m = self._cc2650[device]
|
||||
d = self._device[device]
|
||||
|
||||
if d is None:
|
||||
if m is not None and d is None:
|
||||
error = None
|
||||
|
||||
with self:
|
||||
self._interface.flush()
|
||||
self._selector.select(device)
|
||||
# self._mem_selector.select(device)
|
||||
|
||||
try:
|
||||
if m.check_mem_survive() == False:
|
||||
continue
|
||||
|
||||
result = m.scan_callback(callback, timeout=0.001)
|
||||
sleep(0.0001)
|
||||
result = m.scan_callback(callback, timeout=timeout)
|
||||
|
||||
except RuntimeError as e:
|
||||
error = e
|
||||
|
||||
else:
|
||||
|
||||
if result == False:
|
||||
result = True
|
||||
all_result = all_result or result
|
||||
continue
|
||||
|
||||
all_result = all_result or result
|
||||
|
||||
if result and not all_device:
|
||||
@@ -2600,7 +2728,8 @@ class CC2650MultiMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
|
||||
if error is not None:
|
||||
self.log_warn('suppressed error : ' + str(error))
|
||||
|
||||
# self.reset(device)
|
||||
sleep(1)
|
||||
return all_result
|
||||
|
||||
def found(self) -> List[DeviceResponseInfo]:
|
||||
@@ -2653,6 +2782,7 @@ class CC2650MultiMasterCentralDevice(CC2650MasterDevice, Synchronized):
|
||||
with self:
|
||||
self._interface.flush()
|
||||
self._selector.select(master)
|
||||
# self._mem_selector.select(device)
|
||||
|
||||
sleep(0.0001)
|
||||
d = m.connect(response, direct_connect)
|
||||
|
||||
@@ -261,7 +261,8 @@ class DeviceManager(MasterDevice, Synchronized):
|
||||
|
||||
__slots__ = ('_handler', '_options',
|
||||
'_library_path', '_library',
|
||||
'_interface', '_master', '_found_history', '_found', '_device', '_master_log_level')
|
||||
'_interface', '_master', '_found_history', '_found', '_device', '_master_log_level',
|
||||
'_mem_survive_channel')
|
||||
|
||||
def __init__(self,
|
||||
options: DeviceManagerOptions,
|
||||
@@ -381,8 +382,16 @@ class DeviceManager(MasterDevice, Synchronized):
|
||||
"""reset master device"""
|
||||
self._device.clear()
|
||||
self._demo.clear()
|
||||
print('resettt---------21')
|
||||
print()
|
||||
self._centralMaster.reset(device, software_reset)
|
||||
|
||||
def get_mem_survive_channel(self):
|
||||
return self._mem_survive_channel
|
||||
|
||||
def available_device(self) -> List[int]:
|
||||
return self._centralMaster.available_device()
|
||||
|
||||
@logging_info
|
||||
def shutdown(self, release_resource=True):
|
||||
# shutdown reset memeryboard
|
||||
@@ -572,11 +581,6 @@ class DeviceManager(MasterDevice, Synchronized):
|
||||
if slave.device_id == device:
|
||||
return slave
|
||||
|
||||
elif isinstance(device, str):
|
||||
for slave in self._device:
|
||||
if ':'.join('{:02x}'.format(b) for b in slave.mac_address) == device:
|
||||
return slave
|
||||
|
||||
elif isinstance(device, DeviceInfo):
|
||||
for slave in self._device:
|
||||
if device.match(slave):
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -889,14 +889,12 @@ class I4V4Z4T4DataDecoder(RecDataDecoder):
|
||||
cycle_number = struct.unpack('>H', data[17:19])[0]
|
||||
finish_mode_falg = data[19]
|
||||
|
||||
mem_wrong_information = struct.unpack('>i', data[40:40+4])[0]
|
||||
|
||||
# print('decode', list(data[20:]))
|
||||
mem_wrong = data[40]
|
||||
mem_retry_cnt = data[41]
|
||||
mem_green_wrong = data[42]
|
||||
mem_green_retry_cnt = data[43]
|
||||
ram_num = data[44]
|
||||
mem_wrong = data[120]
|
||||
mem_retry_cnt = data[121]
|
||||
mem_green_wrong = data[122]
|
||||
mem_green_retry_cnt = data[123]
|
||||
ram_num = data[124]
|
||||
broken_flag = data[-1]
|
||||
|
||||
if (finish_mode_falg & 0b11110000 == 0b10100000):
|
||||
@@ -932,7 +930,6 @@ class I4V4Z4T4DataDecoder(RecDataDecoder):
|
||||
# '|', '{:5}'.format(mem_retry_cnt),
|
||||
# '|', '{:5}'.format(mem_green_wrong),
|
||||
# '|', '{:5}'.format(mem_green_retry_cnt),
|
||||
# '|', '{:5}'.format(mem_wrong_information),
|
||||
# '|', '{:5}'.format(ram_num),
|
||||
# '|', '{:5}'.format(broken_flag),
|
||||
# '@', str(self.device), '|')
|
||||
@@ -951,14 +948,12 @@ class I4V4Z4T4DataDecoder(RecDataDecoder):
|
||||
ret.append_data(3, cycle_number)
|
||||
|
||||
# memoryboard information
|
||||
# ret.append_data(4, mem_wrong)
|
||||
# ret.append_data(5, mem_retry_cnt)
|
||||
# ret.append_data(6, mem_green_wrong)
|
||||
# ret.append_data(7, mem_green_retry_cnt)
|
||||
ret.append_data(4, ram_num)
|
||||
ret.append_data(5, broken_flag)
|
||||
ret.append_data(6, mem_wrong_information)
|
||||
# ret.append_data(4, ram_num)
|
||||
ret.append_data(4, mem_wrong)
|
||||
ret.append_data(5, mem_retry_cnt)
|
||||
ret.append_data(6, mem_green_wrong)
|
||||
ret.append_data(7, mem_green_retry_cnt)
|
||||
ret.append_data(8, ram_num)
|
||||
ret.append_data(9, broken_flag)
|
||||
|
||||
if cycle_number != self._cycle_number:
|
||||
# notify cycle_number change
|
||||
@@ -1383,46 +1378,41 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
|
||||
index = 20
|
||||
for i in range(index, index+16, 8):
|
||||
phase_para_a.append(struct.unpack('>i', cali_coeff[i+1:i+5])[0])
|
||||
phase_para_a.append(struct.unpack('>I', cali_coeff[i+1:i+5])[0])
|
||||
phase_para_b.append(struct.unpack('>i', cali_coeff[i+5:i+9])[0])
|
||||
|
||||
index = 40
|
||||
for i in range(index, index+16, 8):
|
||||
phase_para_a.append(struct.unpack('>i', cali_coeff[i+1:i+5])[0])
|
||||
phase_para_a.append(struct.unpack('>I', cali_coeff[i+1:i+5])[0])
|
||||
phase_para_b.append(struct.unpack('>i', cali_coeff[i+5:i+9])[0])
|
||||
|
||||
#Lv[0] 160k
|
||||
index = 60
|
||||
hsrtia_a.append(struct.unpack('>i', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_a.append(struct.unpack('>I', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_b.append(struct.unpack('>i', cali_coeff[index+5:index+9])[0]/1e8)
|
||||
hsrtia_c.append(struct.unpack('>i', cali_coeff[index+9:index+13])[0]/1e4)
|
||||
hsrtia_d.append(struct.unpack('>B', cali_coeff[index+13:index+14])[0])
|
||||
|
||||
#Lv[1] 20k
|
||||
index = 80
|
||||
hsrtia_a.append(struct.unpack('>i', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_a.append(struct.unpack('>I', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_b.append(struct.unpack('>i', cali_coeff[index+5:index+9])[0]/1e8)
|
||||
hsrtia_c.append(struct.unpack('>i', cali_coeff[index+9:index+13])[0]/1e4)
|
||||
hsrtia_c.append(struct.unpack('>I', cali_coeff[index+9:index+13])[0]/1e4)
|
||||
hsrtia_d.append(struct.unpack('>B', cali_coeff[index+13:index+14])[0])
|
||||
|
||||
#Lv[2] 5k
|
||||
index = 100
|
||||
hsrtia_a.append(struct.unpack('>i', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_a.append(struct.unpack('>I', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_b.append(struct.unpack('>i', cali_coeff[index+5:index+9])[0]/1e8)
|
||||
hsrtia_c.append(struct.unpack('>i', cali_coeff[index+9:index+13])[0]/1e4)
|
||||
hsrtia_c.append(struct.unpack('>I', cali_coeff[index+9:index+13])[0]/1e4)
|
||||
hsrtia_d.append(struct.unpack('>B', cali_coeff[index+13:index+14])[0])
|
||||
|
||||
#Lv[3] 200R
|
||||
index = 120
|
||||
hsrtia_a.append(struct.unpack('>i', cali_coeff[index+1:index+5])[0]/1e8)
|
||||
hsrtia_b.append(struct.unpack('>i', cali_coeff[index+5:index+9])[0]/1e8)
|
||||
hsrtia_c.append(struct.unpack('>i', cali_coeff[index+9:index+13])[0]/1e4)
|
||||
hsrtia_d.append(struct.unpack('>B', cali_coeff[index+13:index+14])[0])
|
||||
|
||||
# hsrtia_a.append(struct.unpack('>I', cali_coeff[index+1:index+5])[0])
|
||||
# hsrtia_b.append(struct.unpack('>I', cali_coeff[index+5:index+9])[0]/1e6)
|
||||
# hsrtia_c.append(struct.unpack('>I', cali_coeff[index+9:index+13])[0]/1e5)
|
||||
# hsrtia_d.append(struct.unpack('>I', cali_coeff[index+13:index+17])[0]/1e6)
|
||||
hsrtia_a.append(struct.unpack('>I', cali_coeff[index+1:index+5])[0])
|
||||
hsrtia_b.append(struct.unpack('>I', cali_coeff[index+5:index+9])[0]/1e6)
|
||||
hsrtia_c.append(struct.unpack('>I', cali_coeff[index+9:index+13])[0]/1e5)
|
||||
hsrtia_d.append(struct.unpack('>I', cali_coeff[index+13:index+17])[0]/1e6)
|
||||
|
||||
# print('cutoff_freq', cutoff_freq)
|
||||
# print('hsrtia_a', hsrtia_a)
|
||||
@@ -1502,19 +1492,13 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
|
||||
voltage_mag = math.sqrt(img ** 2 + real ** 2) * (1 + freq ** 2 / cutoff_freq ** 2)
|
||||
|
||||
# if (gain == 3):
|
||||
# current = hsrtia_a[gain] * math.exp(hsrtia_b[gain] * voltage_mag) + hsrtia_c[gain] * math.exp(hsrtia_d[gain] * voltage_mag)
|
||||
# else:
|
||||
current = voltage_mag ** 2 * hsrtia_a[gain] + voltage_mag * hsrtia_b[gain] + hsrtia_c[gain]
|
||||
# print(current)
|
||||
# print(voltage_mag)
|
||||
# print(hsrtia_a[gain])
|
||||
# print(hsrtia_b[gain])
|
||||
# print(hsrtia_c[gain])
|
||||
if (gain == 3):
|
||||
current = hsrtia_a[gain] * math.exp(hsrtia_b[gain] * voltage_mag) + hsrtia_c[gain] * math.exp(hsrtia_d[gain] * voltage_mag)
|
||||
else:
|
||||
current = voltage_mag ** 2 * hsrtia_a[gain] + voltage_mag * hsrtia_b[gain] + hsrtia_c[gain]
|
||||
|
||||
if (current != 0):
|
||||
# impedance = voltage_amp * 1000_000 / 1.414213 / current
|
||||
impedance = voltage_amp * 707106.78 / current
|
||||
impedance = voltage_amp * 1000000 / current
|
||||
else:
|
||||
impedance = 0
|
||||
|
||||
|
||||
@@ -963,6 +963,10 @@ class MasterDevice(LoggerFlag, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def available_device(self) -> List[int]:
|
||||
pass
|
||||
|
||||
def scan(self, timeout=5, all_device=False) -> List[DeviceResponseInfo]:
|
||||
"""scan the nearby device.
|
||||
|
||||
@@ -1097,6 +1101,9 @@ class NullMasterDevice(MasterDevice):
|
||||
def shutdown(self, release_resource=True):
|
||||
pass
|
||||
|
||||
def available_device(self) -> List[int]:
|
||||
return []
|
||||
|
||||
def scan(self, timeout=5, all_device=False) -> List[DeviceResponseInfo]:
|
||||
return []
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3720,9 +3720,12 @@ class CC2650Central(LoggerFlag):
|
||||
if ret is not None and len(ret) > 0:
|
||||
return ret
|
||||
|
||||
elif _time() - start > 0.01: # read timeout
|
||||
elif _time() - start > 1:
|
||||
return None
|
||||
|
||||
else:
|
||||
sleep(0.01)
|
||||
|
||||
def _recv_event(self, timeout: Optional[float] = 1) -> Optional[list]:
|
||||
code = self._recv_byte()
|
||||
# print("code = ", code)
|
||||
|
||||
@@ -16,6 +16,8 @@ MEM_REG_READ = 0x05
|
||||
DEFAULT_REGISTER_VALUE = 0b0100_0011 # 67
|
||||
MEM_SIZE = 0x1000
|
||||
|
||||
_RUNTIME_COMPILE = False
|
||||
|
||||
_SLEEP_TIME_ = 0.001
|
||||
|
||||
|
||||
@@ -27,10 +29,9 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
MEM_INS_MARKED = [MEM_INS_WRITE, 0, 2, 1, 1]
|
||||
MEM_INS_RESET = [MEM_INS_WRITE, 0, 2, 1, 1, 0, 0xFF]
|
||||
|
||||
__slots__ = ('_selector', '_wait_for_first_data', '_spi', '_tx_buffer_header', '_tx_buffer_data',
|
||||
'pin_busy', 'pin_mem_req', 'pin_mem_sel', 'pin_ram_sel',
|
||||
__slots__ = ('_selector', '_wait_for_first_data', '_spi', '_tx_buffer', '_tx_buffer_header', '_tx_buffer_data',
|
||||
'pin_busy', 'pin_request', 'pin_reset', 'pin_sel',
|
||||
'_pin_sel_val',
|
||||
'_pin_ram_sel_value', '_pin_mem_sel_value', '_pin_mem_req_value',
|
||||
'_read_green_times','_read_red_times',
|
||||
'_elite_data_len', '_mem_header_len', '_mem_tailer_len', '_single_data_len',
|
||||
'_head_wrong_cnt')
|
||||
@@ -40,26 +41,24 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
device: Tuple[int, int] = None):
|
||||
|
||||
self._spi = HardwareImplSpiInterface(device,
|
||||
spi_speed=12_000_000)
|
||||
spi_speed=12_000_000 # XXX temp parameter
|
||||
)
|
||||
|
||||
self._elite_data_len = 40
|
||||
self._elite_data_len = 120
|
||||
self._mem_header_len = 3
|
||||
self._mem_tailer_len = 8
|
||||
self._single_data_len = self._elite_data_len + self._mem_header_len + self._mem_tailer_len
|
||||
|
||||
# buffer
|
||||
self._tx_buffer = [0] * 512
|
||||
self._tx_buffer_header = [0] * 11
|
||||
self._tx_buffer_data = [0] * (self._single_data_len * 10 + 3)
|
||||
|
||||
# memory control pin
|
||||
self.pin_busy = OutputPin.get_used(P3Pin.MEM_BZY, True)
|
||||
self.pin_mem_req = OutputPin.get_used(P3Pin.MEM_REQ, False)
|
||||
self.pin_mem_sel = OutputPin.get_used(P3Pin.MEM_RST, True) # MEM_RST -> actually which memory board is assign
|
||||
self.pin_ram_sel: Optional[InputPin] = InputPin.get_used(P3Pin.MEM_SEL) # MEM_SEL -> actually is RAM_SEL, which RAM is assign
|
||||
|
||||
self._pin_ram_sel_value = [bool(self.pin_ram_sel) for _ in range(Selector.SIZE)]
|
||||
self._pin_mem_sel_value = [bool(self.pin_mem_sel) for _ in range(Selector.SIZE)]
|
||||
self._pin_mem_req_value = [bool(self.pin_mem_req) for _ in range(Selector.SIZE)]
|
||||
self.pin_request = OutputPin.get_used(P3Pin.MEM_REQ, True)
|
||||
self.pin_reset = OutputPin.get_used(P3Pin.MEM_RST, True)
|
||||
self.pin_sel: Optional[InputPin] = InputPin.get_used(P3Pin.MEM_SEL)
|
||||
|
||||
self._read_green_times = 0
|
||||
self._read_red_times = 0
|
||||
@@ -72,28 +71,6 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
self._pin_sel_val = [False for _ in range(Selector.SIZE)]
|
||||
self._wait_for_first_data = [True for _ in range(Selector.SIZE)]
|
||||
|
||||
def set_pin_mem_req(self, value: bool):
|
||||
channel = self.select
|
||||
self.pin_mem_req.output(value)
|
||||
self._pin_mem_req_value[channel] = value
|
||||
|
||||
def set_pin_mem_sel(self, value: bool):
|
||||
channel = self.select
|
||||
self.pin_mem_sel.output(value)
|
||||
self._pin_mem_sel_value[channel] = value
|
||||
|
||||
def get_pin_mem_req(self):
|
||||
channel = self.select
|
||||
return self._pin_mem_req_value[channel]
|
||||
|
||||
def get_pin_ram_sel(self):
|
||||
channel = self.select
|
||||
if self.pin_ram_sel.input() == 0:
|
||||
self._pin_ram_sel_value[channel] = False
|
||||
else:
|
||||
self._pin_ram_sel_value[channel] = True
|
||||
return self._pin_ram_sel_value[channel]
|
||||
|
||||
@property
|
||||
def select(self) -> int:
|
||||
return self._selector.channel
|
||||
@@ -102,35 +79,71 @@ 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_sel)
|
||||
|
||||
if flip:
|
||||
self._pin_sel_val[channel] = value
|
||||
|
||||
return value != old
|
||||
|
||||
def reset(self):
|
||||
self._spi.reset()
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
self._selector.close()
|
||||
self._spi.close()
|
||||
|
||||
def flush(self):
|
||||
self.pin_reset.output(False)
|
||||
self.pin_reset.output(True)
|
||||
|
||||
def send_byte(self, data: bytes):
|
||||
raise RuntimeError()
|
||||
|
||||
def recv_byte(self, size: int) -> Optional[bytes]:
|
||||
raise RuntimeError()
|
||||
|
||||
# def flush_all(self):
|
||||
# for _ in self._selector.foreach():
|
||||
# self.pin_reset.output(False)
|
||||
# self.pin_reset.output(True)
|
||||
|
||||
def foreach(self) -> Iterable[int]:
|
||||
for channel in self._selector.foreach():
|
||||
yield channel
|
||||
|
||||
def set_wait_flag(self, spi_idx:int = None, value:bool = None):
|
||||
self._wait_for_first_data[spi_idx] = value
|
||||
|
||||
|
||||
def get_wait_flag(self, spi_idx:int = None) -> Optional[bool]:
|
||||
if spi_idx < Selector.SIZE:
|
||||
return self._wait_for_first_data[spi_idx]
|
||||
else:
|
||||
return None
|
||||
|
||||
def request_data(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)
|
||||
@@ -189,8 +202,8 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
|
||||
if (data[0] != 255 or data[1] != 255 or data[2] != 255):
|
||||
self._head_wrong_cnt[device] = self._head_wrong_cnt[device] + 1
|
||||
if (self._head_wrong_cnt[device] <= 5): # print 5 times
|
||||
print('data_first[0:3] != [255, 255, 255], device:', device, ',', self._head_wrong_cnt[device], 'times')
|
||||
if (self._head_wrong_cnt[device] < 6):
|
||||
print('data_first[0:3] != [255, 255, 255]', device)
|
||||
print(list(data[0:7]))
|
||||
|
||||
data[0:3] = [255, 255, 255]
|
||||
@@ -209,13 +222,13 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
# if (data_first[0] != 255 or data_first[1] != 255 or data_first[2] != 255):
|
||||
# self._head_wrong_cnt[device] = self._head_wrong_cnt[device] + 1
|
||||
# if (self._head_wrong_cnt[device] < 10):
|
||||
# print('data_first[0:3] != [255, 255, 255], device:', device, ',', self._head_wrong_cnt[device], 'times')
|
||||
# print('data_first[0:3] != [255, 255, 255]', device)
|
||||
# print(list(data_first[0:7]))
|
||||
|
||||
# if (data_second[0] != 255 or data_second[1] != 255 or data_second[2] != 255):
|
||||
# self._head_wrong_cnt[device] = self._head_wrong_cnt[device] + 1
|
||||
# if (self._head_wrong_cnt[device] < 10):
|
||||
# print('data_second[0:3] != [255, 255, 255], device:', device, ',', self._head_wrong_cnt[device], 'times')
|
||||
# print('data_second[0:3] != [255, 255, 255]', device)
|
||||
# print(list(data_second[0:7]))
|
||||
|
||||
# if (data_first[3:] == data_second[3:]):
|
||||
@@ -369,37 +382,39 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
|
||||
|
||||
class ExtMemManager:
|
||||
def __init__(self, ext_mem: MultiExtMemSpiInterface):
|
||||
self._mem_sel = InputPin.get_used(P3Pin.MEM_SEL, pull_up_down=True)
|
||||
self._mem_req = OutputPin.get_used(P3Pin.MEM_REQ, initial=True)
|
||||
|
||||
self._ext_mem = ext_mem
|
||||
|
||||
print('ExtMemManager.....')
|
||||
print()
|
||||
|
||||
def mem_request(self):
|
||||
self._mem_req.pulse()
|
||||
sleep(_SLEEP_TIME_)
|
||||
|
||||
def get_ext_mem_register(self) -> List[Tuple[Optional[int], Optional[int]]]:
|
||||
print('get_ext_mem_register......')
|
||||
print()
|
||||
ret = [(None, None) for _ in range(Selector.SIZE)]
|
||||
|
||||
for channel in self._ext_mem.foreach():
|
||||
r = [None, None]
|
||||
|
||||
self._ext_mem.set_pin_mem_sel(False)
|
||||
pin_value = self._ext_mem.get_pin_mem_req()
|
||||
self._ext_mem.set_pin_mem_req(not pin_value)
|
||||
|
||||
m1 = int(self._ext_mem.get_pin_ram_sel())
|
||||
self.mem_request()
|
||||
sleep(0.01)
|
||||
m1 = int(self._mem_sel)
|
||||
# print("m1 = ", m1)
|
||||
self._ext_mem.write_register(DEFAULT_REGISTER_VALUE)
|
||||
r[m1] = self._ext_mem.read_register()
|
||||
sleep(0.040)
|
||||
self._ext_mem.set_pin_mem_sel(True)
|
||||
sleep(0.200)
|
||||
|
||||
self._ext_mem.set_pin_mem_sel(False)
|
||||
pin_value = self._ext_mem.get_pin_mem_req()
|
||||
self._ext_mem.set_pin_mem_req(not pin_value)
|
||||
|
||||
m2 = int(self._ext_mem.get_pin_ram_sel())
|
||||
self.mem_request()
|
||||
sleep(0.01)
|
||||
m2 = int(self._mem_sel)
|
||||
# print("m2 = ", m2)
|
||||
self._ext_mem.write_register(DEFAULT_REGISTER_VALUE)
|
||||
r[m2] = self._ext_mem.read_register()
|
||||
sleep(0.040)
|
||||
self._ext_mem.set_pin_mem_sel(True)
|
||||
sleep(0.200)
|
||||
|
||||
ret[channel] = tuple(r)
|
||||
|
||||
@@ -426,9 +441,12 @@ class ExtMemManager:
|
||||
return 0
|
||||
|
||||
def get_available_channel(self, result: List[Tuple[Optional[int], Optional[int]]] = None) -> List[int]:
|
||||
print('get_available_channel......')
|
||||
print()
|
||||
if result is None:
|
||||
result = self.get_ext_mem_register()
|
||||
|
||||
|
||||
ret = []
|
||||
|
||||
for channel, result in enumerate(result):
|
||||
@@ -441,3 +459,4 @@ class ExtMemManager:
|
||||
ret.append(channel)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class HardwareImplSpiInterface(LowLevelHardwareInterface):
|
||||
*MISO*, *SCLK*, *GE0_N*
|
||||
"""
|
||||
|
||||
__slots__ = ('_device', '_spi', '_spi_mode', '_spi_speed')
|
||||
__slots__ = ('_device', '_spi', '_spi_mode', 'pin_request', '_spi_speed')
|
||||
|
||||
def __init__(self,
|
||||
device: Tuple[int, int] = None,
|
||||
|
||||
@@ -28,7 +28,7 @@ class UARTInterface(LowLevelHardwareInterface):
|
||||
self._serial = serial.Serial(self._port,
|
||||
baudrate=self._baudrate,
|
||||
timeout=0,
|
||||
writeTimeout=0.01)
|
||||
writeTimeout=1)
|
||||
# deprecate function name which change at version 3.0
|
||||
self._serial.flushInput()
|
||||
self._serial.flushOutput()
|
||||
|
||||
@@ -117,14 +117,14 @@ class Selector:
|
||||
self._p1.output(p[1])
|
||||
self._p2.output(p[2])
|
||||
|
||||
# if (value == 4 and self._last_sel != 6):
|
||||
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
# elif (value == 5 and self._last_sel != 4):
|
||||
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
# elif (value == 7 and self._last_sel != 5):
|
||||
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
# elif (value == 6 and self._last_sel != 7):
|
||||
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
if (value == 4 and self._last_sel != 6):
|
||||
print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
elif (value == 5 and self._last_sel != 4):
|
||||
print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
elif (value == 7 and self._last_sel != 5):
|
||||
print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
elif (value == 6 and self._last_sel != 7):
|
||||
print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
|
||||
|
||||
self._last_sel = value
|
||||
|
||||
|
||||
+17
-6
@@ -280,11 +280,14 @@ class Main(CliMain):
|
||||
@cli_command('controller')
|
||||
def _controller_server(self, command: str, argv: List[str]):
|
||||
"""controller server"""
|
||||
print(self, command, argv)
|
||||
print('##_controller_server')
|
||||
return _ControlServer
|
||||
|
||||
@cli_command('data')
|
||||
def _data_server(self, command: str, argv: List[str]):
|
||||
"""data server"""
|
||||
print('##_data_server')
|
||||
return _DataServer
|
||||
|
||||
@cli_command('export')
|
||||
@@ -302,6 +305,7 @@ class Main(CliMain):
|
||||
return LEDControlMain(command)
|
||||
|
||||
def run(self):
|
||||
print('RUN!!!!!!!!!!!!!!!!!!!')
|
||||
self.print_help()
|
||||
|
||||
|
||||
@@ -335,15 +339,16 @@ class _ServerMain(CliSubCommandMain, metaclass=abc.ABCMeta):
|
||||
def run(self):
|
||||
exit_code = 1
|
||||
|
||||
server = self.create_server()
|
||||
print('create_server')
|
||||
|
||||
if _RUNTIME_COMPILE:
|
||||
exit_code = server.main()
|
||||
else:
|
||||
with self.profiling_options.generate_profile_context():
|
||||
exit_code = server.main()
|
||||
server = self.create_server()
|
||||
exit_code = server.main()
|
||||
print('....after create_server')
|
||||
print('.. ..')
|
||||
print()
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
@@ -355,6 +360,7 @@ class _ControlServer(_ServerMain):
|
||||
from biopro.device.manager import DeviceManagerOptions
|
||||
from biopro.server.data import DataServerOptions
|
||||
from biopro.exp_pro.manager import ExpManagerOption
|
||||
print('command', command)
|
||||
|
||||
super().__init__(command)
|
||||
|
||||
@@ -456,6 +462,8 @@ class _ControlServer(_ServerMain):
|
||||
def create_server(self) -> SocketServer:
|
||||
from biopro.server.main import ControlServer
|
||||
|
||||
print('..create_server')
|
||||
|
||||
return ControlServer(self.server_device_options,
|
||||
self.server_data_options,
|
||||
self.server_controller_options,
|
||||
@@ -477,8 +485,11 @@ class _DataServer(_ServerMain):
|
||||
def create_server(self) -> SocketServer:
|
||||
from biopro.server.data import DataServer
|
||||
|
||||
print('.1.create_server')
|
||||
|
||||
return DataServer(self.server_data_options)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('START!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
Main().main()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -64,7 +64,7 @@ class RoutineConnectDeviceThread(ServerThread):
|
||||
self._current_times = 0
|
||||
self._time = time()
|
||||
|
||||
if not self.check_device_status('update') and not self.check_device_status('running') and self._current_times < 3:
|
||||
if len(self._manager._device) < len(self._manager.available_device()) and not self.check_device_status('update') and not self.check_device_status('running') and self._current_times < 3:
|
||||
self._current_times += 1
|
||||
register_device = DeviceAPI.getAll()
|
||||
if register_device is not None:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user