mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update debugging protocol to be more consistent.
* All commands now send a 6-bytes header followed by the payload in a separate packet.
This commit is contained in:
parent
2962c0ce0c
commit
77b82d3b76
@ -150,6 +150,18 @@ extern int py_image_descriptor_from_roi(image_t *image, const char *path, rectan
|
|||||||
void usbdbg_data_out(void *buffer, int length)
|
void usbdbg_data_out(void *buffer, int length)
|
||||||
{
|
{
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
case USBDBG_FB_ENABLE: {
|
||||||
|
uint32_t enable = *((int32_t*)buffer);
|
||||||
|
JPEG_FB()->enabled = enable;
|
||||||
|
if (enable == 0) {
|
||||||
|
// When disabling framebuffer, the IDE might still be holding FB lock.
|
||||||
|
// If the IDE is not the current lock owner, this operation is ignored.
|
||||||
|
mutex_unlock(&JPEG_FB()->lock, MUTEX_TID_IDE);
|
||||||
|
}
|
||||||
|
cmd = USBDBG_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case USBDBG_SCRIPT_EXEC:
|
case USBDBG_SCRIPT_EXEC:
|
||||||
// check if GC is locked before allocating memory for vstr. If GC was locked
|
// check if GC is locked before allocating memory for vstr. If GC was locked
|
||||||
// at least once before the script is fully uploaded xfer_bytes will be less
|
// at least once before the script is fully uploaded xfer_bytes will be less
|
||||||
@ -216,6 +228,31 @@ void usbdbg_data_out(void *buffer, int length)
|
|||||||
py_image_descriptor_from_roi(&image, path, roi);
|
py_image_descriptor_from_roi(&image, path, roi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case USBDBG_ATTR_WRITE: {
|
||||||
|
/* write sensor attribute */
|
||||||
|
int32_t attr= *((int32_t*)buffer);
|
||||||
|
int32_t val = *((int32_t*)buffer+1);
|
||||||
|
switch (attr) {
|
||||||
|
case ATTR_CONTRAST:
|
||||||
|
sensor_set_contrast(val);
|
||||||
|
break;
|
||||||
|
case ATTR_BRIGHTNESS:
|
||||||
|
sensor_set_brightness(val);
|
||||||
|
break;
|
||||||
|
case ATTR_SATURATION:
|
||||||
|
sensor_set_saturation(val);
|
||||||
|
break;
|
||||||
|
case ATTR_GAINCEILING:
|
||||||
|
sensor_set_gainceiling(val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cmd = USBDBG_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: /* error */
|
default: /* error */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -283,43 +320,18 @@ void usbdbg_control(void *buffer, uint8_t request, uint32_t length)
|
|||||||
xfer_length =length;
|
xfer_length =length;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USBDBG_ATTR_WRITE: {
|
case USBDBG_ATTR_WRITE:
|
||||||
/* write sensor attribute */
|
xfer_bytes = 0;
|
||||||
int16_t attr= *((int16_t*)buffer);
|
xfer_length =length;
|
||||||
int16_t val = *((int16_t*)buffer+1);
|
|
||||||
switch (attr) {
|
|
||||||
case ATTR_CONTRAST:
|
|
||||||
sensor_set_contrast(val);
|
|
||||||
break;
|
|
||||||
case ATTR_BRIGHTNESS:
|
|
||||||
sensor_set_brightness(val);
|
|
||||||
break;
|
|
||||||
case ATTR_SATURATION:
|
|
||||||
sensor_set_saturation(val);
|
|
||||||
break;
|
|
||||||
case ATTR_GAINCEILING:
|
|
||||||
sensor_set_gainceiling(val);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cmd = USBDBG_NONE;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case USBDBG_SYS_RESET:
|
case USBDBG_SYS_RESET:
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USBDBG_FB_ENABLE: {
|
case USBDBG_FB_ENABLE: {
|
||||||
int16_t enable = *((int16_t*)buffer);
|
xfer_bytes = 0;
|
||||||
JPEG_FB()->enabled = enable;
|
xfer_length = length;
|
||||||
if (enable == 0) {
|
|
||||||
// When disabling framebuffer, the IDE might still be holding FB lock.
|
|
||||||
// If the IDE is not the current lock owner, this operation is ignored.
|
|
||||||
mutex_unlock(&JPEG_FB()->lock, MUTEX_TID_IDE);
|
|
||||||
}
|
|
||||||
cmd = USBDBG_NONE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -128,7 +128,8 @@ def save_descriptor(x, y, w, h, path):
|
|||||||
__serial.write(buf)
|
__serial.write(buf)
|
||||||
|
|
||||||
def set_attr(attr, value):
|
def set_attr(attr, value):
|
||||||
__serial.write(struct.pack("<BBIhh", __USBDBG_CMD, __USBDBG_ATTR_WRITE, 0, attr, value))
|
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_ATTR_WRITE, 8))
|
||||||
|
__serial.write(struct.pack("<II", attr, value))
|
||||||
|
|
||||||
def get_attr(attr):
|
def get_attr(attr):
|
||||||
__serial.write(struct.pack("<BBIh", __USBDBG_CMD, __USBDBG_ATTR_READ, 1, attr))
|
__serial.write(struct.pack("<BBIh", __USBDBG_CMD, __USBDBG_ATTR_READ, 1, attr))
|
||||||
@ -163,7 +164,8 @@ def fw_version():
|
|||||||
return struct.unpack("III", __serial.read(12))
|
return struct.unpack("III", __serial.read(12))
|
||||||
|
|
||||||
def enable_fb(enable):
|
def enable_fb(enable):
|
||||||
__serial.write(struct.pack("<BBIH", __USBDBG_CMD, __USBDBG_FB_ENABLE, 0, enable))
|
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_FB_ENABLE, 4))
|
||||||
|
__serial.write(struct.pack("<I", enable))
|
||||||
|
|
||||||
def arch_str():
|
def arch_str():
|
||||||
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_ARCH_STR, 64))
|
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_ARCH_STR, 64))
|
||||||
|
|||||||
@ -170,7 +170,8 @@ def save_descriptor(port, x, y, w, h, path):
|
|||||||
def set_attr(port, attr, value):
|
def set_attr(port, attr, value):
|
||||||
try:
|
try:
|
||||||
idx = __port.index(port)
|
idx = __port.index(port)
|
||||||
__serial[idx].write(struct.pack("<BBIhh", __USBDBG_CMD, __USBDBG_ATTR_WRITE, 0, attr, value))
|
__serial[idx].write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_ATTR_WRITE, 8))
|
||||||
|
__serial[idx].write(struct.pack("<II", attr, value))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -246,7 +247,8 @@ def fw_version(port):
|
|||||||
def enable_fb(port, enable):
|
def enable_fb(port, enable):
|
||||||
try:
|
try:
|
||||||
idx = __port.index(port)
|
idx = __port.index(port)
|
||||||
__serial[idx].write(struct.pack("<BBIH", __USBDBG_CMD, __USBDBG_FB_ENABLE, 0, enable))
|
__serial[idx].write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_FB_ENABLE, 4))
|
||||||
|
__serial[idx].write(struct.pack("<I", enable))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user