Openmv _thread module support?

Discussion related to "under the hood" OpenMV topics.
robin1002
Posts: 5
Joined: Thu Mar 07, 2019 8:57 am

Openmv _thread module support?

Postby robin1002 » Thu Mar 07, 2019 9:09 am

In OPENMV2 board, try to utilize the mpy thread functionality. Upset, the function is not working fine. three thread are scheduled by around 10s interval. Code as below:

Code: Select all

import pyb
import time
import _thread

def led(id, dt):
    while 1:
        pyb.LED(id).toggle()
        time.sleep(dt)

#led(2, 1000)   
_thread.start_new_thread(led, (1, 1000))
_thread.start_new_thread(led, (2, 1000))
_thread.start_new_thread(led, (3, 1000))
By comparing with pyboard, after enable the _thread module in mpconfiguration.h, the _thread func working well. thread are scheduling as multi-thread working.
in mpconfiguration.h for pyboard

Code: Select all

#define MICROPY_PY_THREAD           (1)
#define MICROPY_PY_THREAD_GIL       (1)
Thus, whether there is extra more configuration needed in OpenMV project to enable the thread function?
Kindly waiting for your support
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: Openmv _thread module support?

Postby iabdalkader » Thu Mar 07, 2019 10:37 am

Threading doesn't work very well with our code, probably due to this bug with pendsv handler:

https://github.com/micropython/micropython/issues/3842
robin1002
Posts: 5
Joined: Thu Mar 07, 2019 8:57 am

Re: Openmv _thread module support?

Postby robin1002 » Fri Mar 08, 2019 1:30 am

iabdalkader wrote:
Thu Mar 07, 2019 10:37 am
Threading doesn't work very well with our code, probably due to this bug with pendsv handler:

https://github.com/micropython/micropython/issues/3842
Hi, it here any plan of the problem fix? that is very upset the thread not work. some porting code need to adapt by this.
robin1002
Posts: 5
Joined: Thu Mar 07, 2019 8:57 am

Re: Openmv _thread module support?

Postby robin1002 » Fri Mar 08, 2019 3:36 am

Also tested on micropython trunk. mutlithread is working fine. :P
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: Openmv _thread module support?

Postby iabdalkader » Fri Mar 08, 2019 7:56 am

It works in Micropyhton because they don't use this patch, we use this patch because this bug affects the IDE (causes the camera to crash when the script is started/stopped). There's No plan to support threading before this issue is fixed in Micropython first.
robin1002
Posts: 5
Joined: Thu Mar 07, 2019 8:57 am

Re: Openmv _thread module support?

Postby robin1002 » Fri Aug 23, 2019 5:32 am

iabdalkader wrote:
Fri Mar 08, 2019 7:56 am
It works in Micropyhton because they don't use this patch,
would you help to highlight the patch. in my work, multithread support is more important than OPENMV IDE works. so I tend to remove that patch temporarily.
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: Openmv _thread module support?

Postby iabdalkader » Fri Aug 23, 2019 1:55 pm

robin1002 wrote:
Fri Aug 23, 2019 5:32 am
would you help to highlight the patch. in my work, multithread support is more important than OPENMV IDE works. so I tend to remove that patch temporarily.
https://github.com/openmv/micropython/c ... eace6cf323
robin1002
Posts: 5
Joined: Thu Mar 07, 2019 8:57 am

Re: Openmv _thread module support?

Postby robin1002 » Tue Aug 27, 2019 4:33 am

iabdalkader wrote:
Fri Aug 23, 2019 1:55 pm
robin1002 wrote:
Fri Aug 23, 2019 5:32 am
would you help to highlight the patch. in my work, multithread support is more important than OPENMV IDE works. so I tend to remove that patch temporarily.
https://github.com/openmv/micropython/c ... eace6cf323
Thanks iabdalkader, but after remove this patch, multithread in OPENMV board is still not working fine. is that so, before this patch, openmv can support multthread before? or anything else I missed

Return to “Technical Discussion”

Who is online

Users browsing this forum: MSN [Bot] and 9 guests