logo

串口接收正常几次或一次后,openMV模块便死机

2019-02-28 15:59
0
vn1l
# Untitled - By: Administrator - 周四 二月 28 2019
import sensor, image,time,lcd
from pyb import UART,Timer,LED


sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)#320*240
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((240, 240))
sensor.skip_frames(time = 2000)
#sensor.skip_frames(30)
#sensor.set_auto_whitebal(False)      #关闭白平衡
sensor.set_auto_gain(False)          #关闭自动增益
clock = time.clock()
lcd.init()                           #Initialize the lcd screen.

uart = UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters


def sending_data():
    global uart


def recive_data():
    global uart

    if uart.any():
        tmp_data = uart.readline()
        uart.write(tmp_data)
        #print(tmp_data)

while(True):
    img = sensor.snapshot()
    img.lens_corr(0.3) # strength of 1.8 is good for the 2.8mm lens.
    sending_data()
    recive_data()
    lcd.display(img)
3c538ac9-467f-4fa1-8b41-f30723ea3777.jpg
7b6d4207-2f9d-48da-9f3f-bd720c1cb502.jpg
2019-02-28 16:29
I
网红小智智 星瞳科技

我使用串口调试扩展板发现并没有死机,OpenMV会停顿1~2S。

你说的“openMV模块便死机”具体现象是什么?

问题在与 uart.readline()这个函数上,你发送的数据又没有\r\n,为什么要用readline?

I
网红小智智 星瞳科技

https://docs.singtown.com/micropython/zh/latest/openmvcam/library/pyb.UART.html#id2

2019-02-28 16:53
0
vn1l

@kidswong999 是整个openmv程序都不运行了,openmv停止了,需要重新上电

2019-02-28 17:07
I
网红小智智 星瞳科技

我使用串口调试扩展板发现并没有死机,OpenMV会停顿1~2S。

2019-02-28 17:16
0
vn1l

@kidswong999 串口助手可以提供一下下载链接么?

I
网红小智智 星瞳科技

https://singtown.com/learn/50240/

0
vn1l

@kidswong999 大概网页那个位置下载,我是有发数据,也接收到数据,为什么OPENMV会死机我就不清楚了,换个串口助手看看

2019-02-28 18:22
0
vn1l

@kidswong999 你能不间断得发么?1s 一次这样也不死机么?

2019-02-28 23:30
I
网红小智智 星瞳科技

OpenMV会停顿1~2S是因为你的代码uart.readline()这个函数除了问题。

改成uart.read(uart.any())

当然这并不是最好的,因为我不知道你的数据的帧长帧头帧尾,这样很容易粘包。