logo

openmv rpc接口访问卡死

2022-06-25 12:54
G
Simon

openmv摄像头启动rpc服务,数据量大的接口访问后,再次访问其他接口就会hang住,一直没有返回。

数据量大的接口主要是传图片内容、上传文件等

请问这是啥原因?谢谢

2022-06-26 19:07
I
网红小智智 星瞳科技

能提供一个可以复现问题的步骤吗?

2022-07-02 09:15
G
Simon

使用的rpc协议

wlan = network.WINC(mode=network.WINC.MODE_AP)
wlan.start_ap(SSID, key=KEY, security=wlan.WEP, channel=2)
print("AP mode started. SSID: {} IP: {}".format(SSID, wlan.ifconfig()[0]))
interface = rpc.rpc_network_slave(wlan)

方法1:当code_str 字段内容较大时 接口卡死

def upload_code_str(data):
    """upload_code_str

    Args:
        data (_type_): _description_

    Returns:
        _type_: _description_
    """
    try:
        input_args = json.loads(bytes(data).decode())
        file_name = input_args["file_name"]
        code_str = input_args["code_str"]
        with open("/codes/"+file_name, "w") as f:
            f.write(code_str)
        f.close()
    except Exception as e:
        print(repr(e))
    return memoryview('success')

方法2:返回图片数据后,再调用其他接口卡死

def start_snapshoot(data):
    """start snapshoot

    Args:
        data (_type_): _description_

    Returns:
        _type_: _description_
    """
    try:
        album_name = bytes(data).decode()
        file_path = "/images/%s/%s.jpg" % (album_name, str(time.time_ns())[0:13])
        print(album_name, file_path)
        sensor.snapshot().save(file_path)
        with open(file_path, 'rb') as f:
            return bytearray(f.read())
    except Exception as e:
        print(repr(e))
    return bytes()
G
Simon

@kidswong999 已经贴了demo代码了哈,谢谢

2022-07-04 21:32
I
网红小智智 星瞳科技

@21xg_1649472218 你能提供完整的复现问题的步骤吗?完整的代码,和完成的步骤。

你的代码也不是完整的。

还有:电脑上使用什么命令,或者什么代码,来触发问题。预期什么现象,实际什么现象。

2022-07-07 21:58
B
fgdi

@kidswong999

你好,可以留一个邮箱吗?我把完整的代码和请求示例发你。

2022-07-11 16:25
I
网红小智智 星瞳科技

@fgdi 论坛上发不了吗?

2022-07-19 09:50
B
fgdi

@kidswong999 老师不让发论坛,要不我留一个邮箱,你回复一下,我发你吧。shenlanxiong@163.com

2022-07-19 20:55
I
网红小智智 星瞳科技

@fgdi 你应该把代码缩减到最少,把无关的代码都删除,只保留可以出bug的代码。