def run_router_app():
"""
Do the probe/check of
"""
# as of Mat-2016/FW=6.1, PySerial is version 2.6 (2.6-pre1)
cs.CSClient().log(APP_NAME, "serial.VERSION = {}.".format(serial.VERSION))
# probe_physical = True, set False to NOT probe real physical serial ports.
# On models without physical ports, this setting is ignored.
probe_physical = True
# probe_usb = True, set False to NOT probe for USB serial ports.
probe_usb = True
# write_name = True, set False to NOT send out the port name, which is
# sent to help you identify between multiple ports.
write_name = False
# probe_directory(app_base, "/dev")
port_list = []
# confirm we are running on an 1100/1150 or 900/950, result should be "IBR1100LPE"
result = cs.CSClient().get("status/product_info/product_name").get('data')
if "IBR1100" in result or "IBR1150" in result or "IBR900" in result or "IBR950" in result:
name = "/dev/ttyS1"
cs.CSClient().log(APP_NAME, "Product Model {} has 1 builtin port:{}".format(result, name))
port_list.append(name)
elif "IBR300" in result or "IBR350" in result:
cs.CSClient().log(APP_NAME, "Product Model {} has no serial support".format(result))
return -1
if probe_physical:
# fixed ports - 1100 only?
if not IGNORE_TTYS0:
# only check S0 if 'requested' to, else ignore
name = "/dev/ttyS0"
if name not in port_list:
port_list.append(name)
for port in PORT_LIST_PHYSICAL:
name = "/dev/ttyS%d" % port
if name not in port_list:
port_list.append(name)
if probe_usb:
# try first 5 USB
for port in PORT_LIST_USB:
name = "/dev/ttyUSB%d" % port
if name not in port_list:
port_list.append(name)
# cycle through and probe the desired ports
for name in port_list:
probe_serial(name, write_name)
return 0
评论列表
文章目录