From 41d531242aed66ab9d8bd0c568d9779a6e166516 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 4 Sep 2014 01:02:04 +0200 Subject: [PATCH] Fix big frame size --- src/micropython | 2 +- src/omv/usbdbg.c | 6 +++--- src/omv/usbdbg.h | 2 +- usr/openmv.py | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/micropython b/src/micropython index 99b61b8ee..00b1e2b44 160000 --- a/src/micropython +++ b/src/micropython @@ -1 +1 @@ -Subproject commit 99b61b8ee4008872f61ed9849dbb7d9a1be40b80 +Subproject commit 00b1e2b44b58d84ed824c16cfbcca4dd4dd9def1 diff --git a/src/omv/usbdbg.c b/src/omv/usbdbg.c index afc2f18ae..0d114bc02 100644 --- a/src/omv/usbdbg.c +++ b/src/omv/usbdbg.c @@ -102,15 +102,15 @@ void usbdbg_control(void *buffer, uint8_t request, uint16_t length) case USBDBG_FRAME_DUMP: xfer_bytes = 0; - xfer_length = length; + xfer_length =((uint32_t)length)<<2; break; - case USBDBG_FRAME_READY: - /* return framebuffer status */ + case USBDBG_FRAME_LOCK: if (fb->ready == 0) { // no valid frame ((uint8_t*)buffer)[0] = 0; } else { + // try to lock FB, return 1 if locked ((uint8_t*)buffer)[0] = mutex_try_lock(&fb->lock); } break; diff --git a/src/omv/usbdbg.h b/src/omv/usbdbg.h index 7136fab48..9fc73d5d4 100644 --- a/src/omv/usbdbg.h +++ b/src/omv/usbdbg.h @@ -4,7 +4,7 @@ enum usbdbg_cmd { USBDBG_NONE=0, USBDBG_FRAME_SIZE, USBDBG_FRAME_DUMP, - USBDBG_FRAME_READY, + USBDBG_FRAME_LOCK, USBDBG_SCRIPT_EXEC, USBDBG_SCRIPT_STOP, USBDBG_SCRIPT_SAVE, diff --git a/usr/openmv.py b/usr/openmv.py index b48bd59dc..b2cb888f2 100755 --- a/usr/openmv.py +++ b/usr/openmv.py @@ -18,13 +18,13 @@ __INTERFACE = 0 __ALTSETTING = 1 __IN_EP =0x81 __OUT_EP =0x01 -__TIMEOUT =1000 +__TIMEOUT =3000 __FB_HDR_SIZE =12 # USB Debug commands __USBDBG_FRAME_SIZE=1 __USBDBG_FRAME_DUMP=2 -__USBDBG_FRAME_READY=3 +__USBDBG_FRAME_LOCK=3 __USBDBG_SCRIPT_EXEC=4 __USBDBG_SCRIPT_STOP=5 __USBDBG_SCRIPT_SAVE=6 @@ -82,15 +82,15 @@ def fb_size(): size = struct.unpack("III", buf) return size -def fb_ready(): +def fb_lock(): global __dev - buf = __dev.ctrl_transfer(0xC1, __USBDBG_FRAME_READY, 0, __INTERFACE, 1, __TIMEOUT) + buf = __dev.ctrl_transfer(0xC1, __USBDBG_FRAME_LOCK, 0, __INTERFACE, 1, __TIMEOUT) return struct.unpack("B", buf)[0] def fb_dump(): global __dev - if (fb_ready() == 0): + if (fb_lock() == 0): return None size = fb_size() @@ -100,7 +100,7 @@ def fb_dump(): num_bytes = size[0]*size[1]*size[2] # read fb data - __dev.ctrl_transfer(0xC1, __USBDBG_FRAME_DUMP, num_bytes, __INTERFACE, 0, __TIMEOUT) + __dev.ctrl_transfer(0xC1, __USBDBG_FRAME_DUMP, num_bytes/4, __INTERFACE, 0, __TIMEOUT) buff = __dev.read(__IN_EP, num_bytes, __INTERFACE, __TIMEOUT) if (size[2] > 2):