Fix usbdbg exec script

This commit is contained in:
iabdalkader 2014-02-10 03:11:53 +02:00
parent 025f54949f
commit 567feccc66

View File

@ -4,7 +4,8 @@
#include "usbdbg.h" #include "usbdbg.h"
#define USB_TX_BUF_SIZE (64) #define USB_TX_BUF_SIZE (64)
static int frame_tx_bytes; static int xfer_bytes;
static int xfer_length;
static enum usbdbg_cmd cmd; static enum usbdbg_cmd cmd;
extern struct sensor_dev sensor; extern struct sensor_dev sensor;
@ -15,10 +16,10 @@ void usb_fb_data_in(void *buffer, int *length)
switch (cmd) { switch (cmd) {
case USBDBG_DUMP_FB: /* dump framebuffer */ case USBDBG_DUMP_FB: /* dump framebuffer */
if (frame_tx_bytes < (fb->width*fb->height*fb->bpp)) { if (xfer_bytes < (fb->width*fb->height*fb->bpp)) {
memcpy(buffer, fb->pixels+frame_tx_bytes, *length); memcpy(buffer, fb->pixels+xfer_bytes, *length);
*length = USB_TX_BUF_SIZE; *length = USB_TX_BUF_SIZE;
frame_tx_bytes += USB_TX_BUF_SIZE; xfer_bytes += USB_TX_BUF_SIZE;
} else { } else {
*length = 0; *length = 0;
} }
@ -34,6 +35,11 @@ void usb_fb_data_out(void *buffer, int length)
switch (cmd) { switch (cmd) {
case USBDBG_EXEC_SCRIPT: /* execute script */ case USBDBG_EXEC_SCRIPT: /* execute script */
vstr_add_strn(libmp_get_line(), buffer, length); vstr_add_strn(libmp_get_line(), buffer, length);
xfer_bytes += length;
if (xfer_bytes == xfer_length) {
/* interrupt do_repl */
libmp_line_feed();
}
break; break;
default: /* error */ default: /* error */
@ -47,10 +53,13 @@ void usb_fb_control(uint8_t request, int length)
switch (cmd) { switch (cmd) {
case USBDBG_DUMP_FB: /* dump framebuffer */ case USBDBG_DUMP_FB: /* dump framebuffer */
/* reset bytes counter */ /* reset bytes counter */
frame_tx_bytes = 0; xfer_bytes = 0;
break; break;
case USBDBG_EXEC_SCRIPT: /* execute script */ case USBDBG_EXEC_SCRIPT: /* execute script */
/* reset bytes counter */
xfer_bytes = 0;
xfer_length =length;
break; break;
default: /* error */ default: /* error */